Skip to content

Instantly share code, notes, and snippets.

@moiz-frost
Last active December 25, 2019 01:52
Show Gist options
  • Save moiz-frost/2e80a71068a2ad5e21930ba6cbd33a1e to your computer and use it in GitHub Desktop.
Save moiz-frost/2e80a71068a2ad5e21930ba6cbd33a1e to your computer and use it in GitHub Desktop.
Basic pointer usage
#include <stdio.h>
#include <string.h>
int main() {
int val = 123;
int* valPtr = &val;
printf("address of &val = %p\n", &val);
printf("value of val = %d\n", val);
printf("value of valPtr = %p\n", valPtr);
printf("address of &valPtr = %p\n", &valPtr);
printf("dereferenced value of valPtr = %d\n", *valPtr);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment