November 2013
Beginner
325 pages
9h 47m
English
What if you wanted to store an address in a variable? You could stuff it into an unsigned integer that was the right size, but the compiler will help you catch your mistakes if you are more specific when you give that variable its type. For example, if you wanted a variable named ptr that holds the address where a float can be found, you would declare it like this:
float *ptr;
We say that ptr is a variable that is a pointer to a float. It does not store the value of a float; it can hold an address where a float may be stored.
Declare a new variable named addressOfI that is a pointer to an int. Assign it the address of i.
int main(int argc, const char * argv[])
{
int i = 17;
int *addressOfI = &i; printf("i ...Read now
Unlock full access