Hi,
Recently I have a text file which contain a bunch of numbers :-
1,0,0,1,0................
1,0,1,1,1................
I would like to read these numbers line by line and stored into an array.
However, I get seg fault for this.
char filename[5000];
char dump;
strcpy(filename,argv[2]);
while(!feof(tfPtr))
{
for (i=0; i<16; i++)
{
fscanf(filename, "%d", t[i]);
fscanf(filename, "%c", dump);
}
sum=t[3]+t[5];
sum2=t[2]+t[4];
}
fclose(tfPtr);
exit(0);
When I compile together with filename
./test.exe test.txt
Segmentation fault (core dumped)
Please help or you guys have any other suggestion ? Thanks.