Text txt.file is argument and has numbers:
154 456 22 3 22
213 312 33 4325
I want to scan numbers from a test.txt and store them into array. This scanning only first 3 numbers. I have no idea why is that so.
int main(int argc,char *argv[])
{
int c[40];
int i=0;
FILE *ptr;
ptr=fopen(argv[1],"r");
do
{
fscanf(ptr,"%d",&c[i]);
i++;
}while(c[i]!=-1);
for(int k=0;k<i;k++) printf("%d ",c[k]);
fclose(ptr);
return 0;
}
How i can find EOF?
Output is: 154 456 22.