Last active
December 14, 2015 11:28
-
-
Save jondeandres/5079426 to your computer and use it in GitHub Desktop.
C Pointers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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