With the following:
#include <stdlib.h>
int main() {
long n = 20e6;
float values[n];
for(long i = 0; i < n; i++)
values[i] = 0;
return 0;
}
I get Segmentation fault: 11
. But with the following:
#include <stdlib.h>
int main() {
long n = 20e6;
float *values = malloc(n*sizeof(float));
for(long i = 0; i < n; i++)
values[i] = 0;
return 0;
}
Not. Why?