On 04/06/2013 18:08, Lyle Hazelwood wrote: >>> Line 9. *argv[i] should be argv[i] >> >> Yup. that's what they are looking for. argv[] is an array of >> pointers to char. >=20 > Just for fun, what does *argv[i] return, and why does it cause > such nasty behavior? > (Yes, I have the answers, but only after plugging it in to gcc) It will segfault as it tries to print random memory. A short snippet of valgrind output illustrates this nicely: david@lenny:~$ valgrind ./a.out =3D=3D11548=3D=3D Memcheck, a memory error detector =3D=3D11548=3D=3D Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward = et al. =3D=3D11548=3D=3D Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h= for copyright info =3D=3D11548=3D=3D Command: ./a.out =3D=3D11548=3D=3D =3D=3D11548=3D=3D Invalid read of size 1 =3D=3D11548=3D=3D at 0x40250D8: __GI_strlen (mc_replace_strmem.c:284) =3D=3D11548=3D=3D by 0x407186E: vfprintf (vfprintf.c:1617) =3D=3D11548=3D=3D by 0x40783DF: printf (printf.c:35) =3D=3D11548=3D=3D by 0x8048401: main (in /home/david/a.out) =3D=3D11548=3D=3D Address 0x2e is not stack'd, malloc'd or (recently) free= 'd For a hint at where the 0x2e comes from, consider what argv[0] contains the way I ran it. Note that the line from the challenge can also be correctly written as: printf ("Argument #%d: '%s'\n", i, *(argv + i)); Pointers are fun. David --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .