This is the mail archive of the ecos-devel@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in fprintf/fscanf


Hello,

could someone please verify the following bug I discovered. It seems that fprintf (or fputs) fails after a fscanf call. The second fprintf call however does work as expected.
I currently use the network as stream. Maybe this bug is because I use the fdopen function but at the moment I do not have an other working file descriptor.



Follwoing Code:


   term=fdopen(clntSock, "r+");
   assert(term!=0);

while(1)
{
fprintf(term, "Type a number\n");
diag_printf("fscanf %d\n", fscanf(term, "%d",&num));
diag_printf("fprintf1 %d\n",fprintf(term, "Number was %d\n",num));
diag_printf("fprintf2 %d\n",fprintf(term, "Again - Number was %d\n",num));
}


Produces following output (with Input of 8, 9 and 10):

Type a number
8
Again - Number was 8
Type a number
9
Again - Number was 9
Type a number
10
Again - Number was 10
Type a number


With diag output of:


fscanf 1
fprintf1 0
fprintf2 21
fscanf 1
fprintf1 0
fprintf2 21
fscanf 1
fprintf1 0
fprintf2 22

The complete code is available under http://pastebin.com/8iYVkAhz

Greetings,

Martin Laabs


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]