Tuesday, 13 November 2012

Pointers in C in a nutshell!

Pointers are used for dynamic memory allocation in C, the quick overview:

int number = 54; //Assigns variable called number the value 54

int *pointme = 52; //Creates a pointer variable named pointme and assigns it a value of 52

int *pointme = &number; //Points pointme variable to the address in memory of the variable number

printf("Pointer address %p has a value %d", pointme, *pointme); //Print out the address and value of the pointer

No comments:

Post a Comment