Why is gets() more dangerous than scanf()?
c
Solution
The `gets` function is not protected against buffer overflows.
With the `scanf` format string you can define the maximal length of the string to read from standard input and store in the given memory buffer. For example with `scanf("%10s\n", str);` a maximum of 10 characters will be read. The `str` buffer should be of 11 bytes to store the NULL terminating character.
Performance wise, if you only use `scanf` to workaround the buffer overflow issues of `gets`, prefer using the `fgets` function instead.
Problem
It seems to me that both have the potential to overflow the buffer. Yet I'm adviced to never use gets() but still encouraged to use scanf(). Is it just because of the formatting arguments allowed in scanf() or is there any other reason?