#### Let's call this one labprint.c #### Start with the following (use cut-and-paste) #include #include int main(int argc, char *argv[]) { for (int i=0; i for (int i=0; i<100; ++i) { #### Run it... This will not go well. C reads outside the box (ok, array). #### Type the command "env" to see where these values came from $$$$ env #### Modify your program to print the pointer, not its value. Here's a diff 6c6 < printf("arg %3d is %s\n", i, argv[i]) ; --- > printf("arg %3d is %d\n", i, argv[i]) ; #### You get a "pedantic" error. Go ahead and run it! #### Let`s get rid of the 100. Replace it with argc to eliminate the faults. #### Take a *long* look at the man page for printf. $$$$ man printf #### Change the format to print argv[i] as a pointer. (Use %p.) #### Hmmm -- hex... Try %x. #### Ugh -- Try to cast argv[i] to (int) #### Ugh -- Try to cast argv[i] to (void *), the "generic" pointer #### Ugh -- Try to cast argv[i] to (int)(void *) #### Ugh -- Different sizes... Try (long)(void *) #### Ugh -- Or maybe (unsigned long)(void *) #### Ugh -- Change format specifier to %ld [Or is that %lu?] #### Wait... I liked the HEX better than that. Go to %lx. #### But it's 64 bits... that`s 4*16. Add a length -- %16lx #### ALL CAPS would look better. Try %16lX #### Let's have some leading zero's. That's %016lX #### Let's add the string back in. The output should be something like: arg 0 is at 00007FFCD9248D59 and is ./funlab arg 1 is at 00007FFCD9248D62 and is do arg 2 is at 00007FFCD9248D65 and is me arg 3 is at 00007FFCD9248D68 and is ri