The following code, when compiled and run, gives me a segmentation fault. Why is this?
#include <stdio.h>
#include <limits.h>
int main(void)
{
int fat_array[INT_MAX];
return 0;
}
The following code, when compiled and run, gives me a segmentation fault. Why is this?
#include <stdio.h>
#include <limits.h>
int main(void)
{
int fat_array[INT_MAX];
return 0;
}
What you are requesting is to have about 2,147,483,647
integer spaces allocated to you. Each integer is usually four bytes so that's 8,589,934,588
bytes which is 8 gigabytes of memory. This is likely above the allowed amount of memory a single process is allowed to reserve, and for good reason, so you get an error.