| Wiki Markup |
|---|
According to C99 \[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\], if the {{fgets()}} function fails, the contents of the array it was writing to are undefined. As a result it is necessary to reset the string to a known value to avoid possible errors on subsequent string manipulation functions. |
Non-Compliant Code Example
...
In this compliant solution, buf is set to an error message after fgets fails.
...