Hi,
I have prepared a file through the use of following code
Code:
fprintf(file2, "%i\t%i\t%i\t%i\t%i\t%i\n",
msg_id,
msg_size,
msg_period,
msg_deadline,
msg_producer,
msg_comsumer
);
As one can see, this file has tab separated integer entries. The file is written correctly, let us call this file "msg.txt".
I face the problem when I read this file, using fgets as follows:
Code:
char singleMessage[100];
while( fgets(singleMessage, sizeof(singleMessage), file ) )
{
puts(singleMessage);
sscanf(singleMessage, "%i\t%i\t%i\t%i\t%i\t%i\n",
&first, &second, &third, &fourth, &fifth, &sixth);
fprintf(stderr, "first: %d, second: %d, third: %d, fourth: %d, fifth: %d\, sixth: %d\n",
first, second, third, fourth, fifth, sixth);
}
but fgets only retrieves until the first, i.e, if the first line in the file reads:
78 800 4 4 2 5
fgets returns only 78.
What can be the problem here,
Does it have to do with how the file was written in the first place.
thanks,