String handling functions


1. Never use gets().
It is deprecated/Removed from C11.
Because it is impossible to tell without knowing data in advance,
how many characters gets() will read.
And because gets() continue to store characters past the end of the buffer.
It is dangerous to use.
It has been used to break the computer security.
We should replace use of gets() with either fgets() or getchar() or gets_s().
fgets():
fgets() have the similar behavior to gets().
fgets() acceps two additional arguments: 1. number char to read 2.input stream
When stdin is specified as the stream, fgets() can be used tp simulate the behavior of gets().
The fgets()/gets_s() function can result in a buffer overflow if the specified number of char to input
exceeds the length of the destination buffer.
Last edited on
Topic archived. No new replies allowed.