Skip to content

Instantly share code, notes, and snippets.

@aaronmoodie
Last active August 29, 2015 14:01
Show Gist options
  • Save aaronmoodie/40b91bd673df634bfd55 to your computer and use it in GitHub Desktop.
Save aaronmoodie/40b91bd673df634bfd55 to your computer and use it in GitHub Desktop.
int main(int argc, const char * argv[])
{
int x = 0;
int *pointer_to_x = &x; // * is used to do declaration (use & to get the address of x in memory)
*pointer_to_x = 1; // * is a dereference operator
//x is now equal to 1
printf("*pointer_to_x points to the value %i\n", *pointer_to_x);
printf("pointer_to_x is located at the address %p\n\n", pointer_to_x);
printf("x stores the value %i\n", x);
printf("x is located at the address %p\n\n", &x);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment