Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> So does 'Hello World\n' need to check that printf() succeeded, or does it actually need to go further and check that printf() returned 12?

No. According to fprintf(1), when the call succeeds it returns the number of printed characters. If it fails (for example, if it could only print part of the string) then it returns a negative value.

The number of printed characters is useful to know how much space was used on the output file, not to check for success. Success is indicated by a non-negative return value.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: