Address of I


I’m doing something wrong with this example:

[code]#include <stdio.h>

int main(int argc, const char * argv[])
int i = 17;
int *addressOfI = %i;
printf("&1 stores its value at %p\n", addressOfI);
printf(“i stores its value at %p\n”, &i);
printf(“this function starts at %p\n”, main);
return 0;


I am getting an error at:

It says “Expected expression.” I’ve looked at the sample code over and over again, it appears i’m typing it right.

(Using latest version of Xcode beta for iOS 6)


The line:

int *addressOfI = %i;

should be:

& sign means “address of”



Thanks for the reply, I cant believe I overlooked that. I guess reading a book for several hours it gets easy to overlook something like that. For me it would have been more obvious if this chapter stated that in the beginning in a sentence as simple as yours. Its a great book but some things feel like they should be simplified first and explained in detail later.

Regardless, thanks for the help. For an absolute beginner, i’m hanging in there. This is a HUGE step up from moderate HTML skills and very basic PHP understanding. I don’t expect to be programming when i’m done with this book but hopefully once finished with this book, moving through other books will be found easy and the repetition of methods from different authors will hopefully make things stick and make sense.

Really quick, at this point I am finding myself able to complete the challenges and follow the examples very easily, but I still don’t really have much of an understanding of everything that is going on or what everything means… I’m starting to learn what certain things do when you code them, but not to the point I could explain exactly what its doing in the background or how its doing it. Is this a normal stage to be at or should I go back and reread things until I know precisely whats going on and what everything i’m typing means?


I feel the exact same way! I have been able to complete all the challenges without any help, and I can follow the examples easily as well. But I don’t feel like I know when to apply this stuff or what purpose they serve in terms of how they affect a program (if that makes sense). Can someone let us know if this is normal or not? Thank you in advance for any help you can provide.


This is a long journey, and you are just starting. It is as if you said, “I’m so frustrated – I really understand the alphabet now, but I don’t know how to use these letters to write a great novel.”

Don’t worry. It will come. Keep going.


I have a decent grasp of pointers after (re)reading this chapter. I wanted to know why “addressofI” is necessary in the example provided on p. 56 if you can access it by simply using “&i.” It appears to be more efficient to write: printf(“i stores its value at %p\n”, &i);

What is the advantage of declaring: int *addressOfI = &i; and then passing it as value in the main function if the above code achieves the same? I’m sure I’m missing something…