I am trying to compile a file for a MOOC that I am taking. Without going into details, the program has to read 1000000 long ints into an array. The program works very well with smaller array lengths, but it gives me an issue here. I get a Thread 1: EXC_BAD_ACCESS (code=2,address=0x7fff5eca9ba8) error in Xcode.
Any ideas on how to fix this?
Any ideas on how to fix this?
Code:
#define LEN 999999
int x = 0;
Code:
file = fopen("address to the location on my comp", "r");
if (file == NULL)
{
printf("File not found!\n");
}
long int arr[LEN];
long int sorted[LEN];
long int temp;
int found[20001] = { 0 };
for (int x = 0; (x < LEN + 1) && !feof(file); x++)
{
fscanf(file, "%ld", &temp);
arr[x] = temp;
}
fclose(file);