when I write code:
void main(void) {
FILE * fp;
int number;
char temp[100];
//int pdata1[7201]; does not work but 5000 works, is there a upper limit for array size???
int * pdata1 = malloc(sizeof(int)*50000);
int counter1 = 0;
char filename[] = "file1.txt";
fp = fopen(filename,"r");
if ( fp == NULL)
{
printf("Error opening file %s\n",filename);
return ;
}
else
printf("Success opening file %s\n",filename);
while (fgets(temp,10,fp) != NULL)
{
counter1++;
pdata1[counter1] = atoi(temp);
}
printf("%d ",pdata1[2]);
fclose(fp);
return;
}
It does not print out the pdata1[2] line, Only opening file line is print out. Why does this happen?
Jingrui