Skip to content

Instantly share code, notes, and snippets.

@jondeandres
Last active December 14, 2015 11:28
Show Gist options
  • Save jondeandres/5079426 to your computer and use it in GitHub Desktop.
Save jondeandres/5079426 to your computer and use it in GitHub Desktop.
C Pointers
int main(int argc, char *argv[])
{
int *array, i;
array = malloc(sizeof(int) * 100);
memset((void *)array, 0, sizeof(int) * 100);
*(array + sizeof(int) * 30) = 4;
for(i = 0; i < 100; i++) {
int value;
value = *(array + sizeof(int) * i);
if (value == 4) {
printf("found!\n");
} else {
printf("%d: %d\n", i, value);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment