Skip to content

Instantly share code, notes, and snippets.

@Dietr1ch
Created July 6, 2014 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dietr1ch/b41f0db836e7cdf84646 to your computer and use it in GitHub Desktop.
Save Dietr1ch/b41f0db836e7cdf84646 to your computer and use it in GitHub Desktop.
Small program to test how much memory was actually given. It crashes intentionally.
#include <stdio.h>
void fillArray(int* array){
int i=0;
while(1){
printf("Rewrote %d to %d\n", array[i], i);//This mem access should raise a SEGFAULT soon.
array[i] = i;
++i;
}
}
int myArray[10];
int main(int argc, const char *argv[]){
fillArray(myArray); //This hangs and crashed the program :c
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment