i am getting segmentation fault while writing data into file. here is code
int arr[N]; // where N = 1508065
f = fopen( "datafile.txt", "w" );
if (f == NULL)
{
printf("Error opening file!\n");
exit(1);
}
for( i=1;i<=N;i++)
{
arr[i]=rand()%100;
fprintf(f, "%d %d %d\n",i,1,arr[i] );
}
fclose(f);
I have tried with double arr[N] even then is a segmentation fault. It works fine when N is small.