[Courses] Re: [C] Beginner's Lesson 12: another answer to Exercise 1 (Simple Pointers)

Morgon Kanter admin at surgo.net
Mon Nov 25 16:40:49 EST 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Your code won't work:
>   for (i = 0; i < SIZE; i++)
>   {
>     array[*(ptr + 1)] = 0;     /* use pointer arithmetic to get to  */
>     printf("%3d", *(ptr + 1)); /* the next element in the array     */
>   }

rather, try:
array[(*ptr + i)] = 0;
printf("%3d", (*ptr + i));

Because in your code, your just setting the exact same thing equal to 0.
- -- 
Fetch my UPDATEd public key from http://www.surgo.net/pubkey.asc

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (GNU/Linux)

iQEVAwUBPeKK4Q+aqp0pfOpbAQJsNwf/ShlaExerXvd+2GLobXvQB9/4R7wIy2O4
wJIrp6fnILwz2kXcVQiFRXgtRUbig42FOeSXp8N1r0XakeXUx/zqmzp2CmkBLCjm
lTMm08NvFpm3gYVHUqUEs3XGaVLKk/0KG8JT4kZBqlWHMrTYbGKjGIzJjXNWzaDR
+1QldeSCnIKkq3VYggcrr6oOYW6wmtLYe9kbZ1oODZ3FDZrsZr40pg3mKmw/jArA
KPk+Q4nSbe6VhUDF2TXvmGT+CDP3lveQ/dpydMPuSAMYIL2rTsDqDAjF4Ewli+Va
z6nx5N1GFHQW6nOkttrt2bkvhYazhBtoxZxLeUW6N+Tz2ILhnpaMww==
=1vsX
-----END PGP SIGNATURE-----



More information about the Courses mailing list