Script started on Wed Oct 29 17:29:21 2025 Restored session: Wed Oct 22 18:46:04 EDT 2025 % macbook:logs> cd ../programs/C_ch16 % macbook:C_ch16> echo attendance code 4178 attendance code 4178 % macbook:C_ch16> cat C_ch16_8_v4.c // Show the sizes of the union vs struct #include int main() { union { int i; float f; char c; double val; long L_val; } u; struct { int i; float f; char c; double val; long L_val; } s; /* s.i = 23; printf("s.i is %d \n", s.i); s.f = 4.756; printf("s.f is %f \n", s.f); u.i = 23; printf("u.i is %d \n", u.i); printf("u.i is %x in hex\n", u.i); u.f = 4.756; printf("u.f is %f \n", u.f); printf("Final values:\n"); printf("s.i is %d \n", s.i); printf("s.f is %f \n", s.f); printf("u.i is %d \n", u.i); printf("u.i is %x in hex\n", u.i); printf("u.f is %f \n", u.f); */ printf("Size of struct s is %lu\n", sizeof(s)); printf("Size of union u is %lu\n", sizeof(u)); return 0; } % macbook:C_ch16> gcc C_ch16_8_v4.c % macbook:C_ch16> ./a.out Size of struct s is 32 Size of union u is 8 % macbook:C_ch16> % macbook:C_ch16> vi question_about_losing_ptr % macbook:C_ch16> cat question_about_losing_ptr char *p; .. p = malloc(N+1); .. char a = 'A'; p = &a; free(p); // will not work % macbook:C_ch16> ls getMostFreq* zsh: no matches found: getMostFreq* % macbook:C_ch16> cd ../C_ch17 % macbook:C_ch17> ls getMostFreq* zsh: no matches found: getMostFreq* % macbook:C_ch17> grep supplied *.c C_ch17_8.c: printf("The argument supplied is %s\n", argv[1]); C_ch17_8.c: printf("Too many arguments supplied.\n"); % macbook:C_ch17> cat C_ch17_8.c #include int main( int argc, char *argv[] ) { printf("Program name %s\n", argv[0]); if ( argc == 2 ) { printf("The argument supplied is %s\n", argv[1]); } else if ( argc > 2 ) { printf("Too many arguments supplied.\n"); } return 0; } % macbook:C_ch17> gcc C_ch17_8.c % macbook:C_ch17> ./a.out Program name ./a.out % macbook:C_ch17> ./a.out apple Program name ./a.out The argument supplied is apple % macbook:C_ch17> ./a.out apple orange Program name ./a.out Too many arguments supplied. % macbook:C_ch17> which vi /usr/bin/vi % macbook:C_ch17> which nano /usr/bin/nano % macbook:C_ch17> which pico /usr/bin/pico % macbook:C_ch17> which emacs emacs not found % macbook:C_ch17> ls -l /usr/bin/nano lrwxr-xr-x 1 root wheel 4 Aug 16 14:44 /usr/bin/nano -> pico % macbook:C_ch17> echo "suppose your program says p = malloc(100);should your program do?" suppose your program says p = malloc(100); what else should your program do? % macbook:C_ch17> exit Saving session... ...saving history...truncating history files... ...completed. Script done on Wed Oct 29 18:52:59 2025