Skip to content

Instantly share code, notes, and snippets.

@dagolinuxoid
Created April 21, 2017 18:38
Show Gist options
  • Save dagolinuxoid/1fcf08b3b7d4b9916bac273d65047297 to your computer and use it in GitHub Desktop.
Save dagolinuxoid/1fcf08b3b7d4b9916bac273d65047297 to your computer and use it in GitHub Desktop.
pointers are easy but syntax is sucks.
#include <stdio.h>
int main (void) {
int k = 42;
int *pointerToKadress;
pointerToKadress = &k; // an address | without asterisk
*pointerToKadress = 29; // a value placed at this address | go to this location and do something
printf("%s updated\n", *pointerToKadress == k ? "true" : "false"); // true
printf("%s updated|address %i\n", pointerToKadress == k ? "true" : "false", pointerToKadress); // false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment