Sunday, 29 September 2013

Fscanf inside while keeps crashing?

Fscanf inside while keeps crashing?

I have the following text:
ASDCASDSA255878 Jack Jhon 1988 12
ASDCASDSA255878 Bill Smith 1977 12
And i have the following code:
inputFile = fopen(fileName,"r");
char id[50];
char fname[50];
char lname[50];
char year[50];
char month[50];
while(fscanf(inputFile, "%s %s %s %s %s\n",id,fname,lname,year,month) == 5)
{
}
fclose(inputFile);
The file gets opened and if i put a printf statment inside the while loop
i could see it and after that it crashes.
I tried changing the ==5 to !=EOF but same problem.

No comments:

Post a Comment