Versions Compared

Key

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

...

This non-compliant code example is intended to be used to remove the trailing newline (\n) from an input line. The fgets() function is typically used to read a newline-terminated line of input from a stream, .  It takes a size parameter for the destination buffer and copies, at most, size-1 characters from a stream to a string.

...

However, if the first character in buf is a NULLnull character, strlen(buf) will return 0 and a write-outside-array-bounds error will occur.

...