avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Standard IO - function fwrite


From: Marjan Fojkar
Subject: Re: [avr-gcc-list] Standard IO - function fwrite
Date: Fri, 08 Jun 2007 17:16:14 +0200
User-agent: Thunderbird 1.5.0.10 (X11/20070301)



Joerg Wunsch wrote:
Marjan Fojkar <address@hidden> wrote:

  
I expected that if one byte is successfully written then the
function returns 1 if byte is not written then it returns 0.
    

This is how it works.

  
In case of error it returns e.g. EOF.
    

No, it returns a `short write count' (less than requested), i.e.  it
could only be zero in your case since you only request one object.

This is exactly how the C standard requires it.

Of course, this all depends whether your backend put() function can
actually return an error indication.

  
Yes you are right. But if you use this function for binary data it doesn't work. Function fwrite enters into for loop and stays there until putc returns zero or all data have been written. If data contain zero values the fwrite will exit on first zero value.
I think that fwrite should abandon for loop when putc returns an error.

Marjan

reply via email to

[Prev in Thread] Current Thread [Next in Thread]