I have an array populated with integers:
#include <stdio.h>
#define MAX 4000000
int main() {
int primes[MAX + 1];
// init array with all numbers
for(int i = 1; i <= MAX; i++)
primes[i] = i;
return 0;
}
With 4 byte integers, it seems this should only use up 4M * 4 or 16 MB. But I'm getting a segmentation fault when I run this program. I don't understand why.