Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The fgets() function is typically used to read a newline-terminated line of input from a stream. The fgets() function takes a size parameter for the destination buffer and copies, at most, size-1 characters from a stream to a string. Truncation errors can occur if the programmer blindly assumes that the last character in the destination string will be is a newline.

Non-Compliant Code Example

This non-compliant code example is intended to be used attempts to remove the trailing newline (\n) from an input line.

...