The function is getsnot protected from buffer overflow.
Using the format string, scanfyou can determine the maximum length of the string for reading from standard input and saving in this memory buffer. For example, when scanf("%10s\n", str);no more than 10 characters are read. The buffer strmust be 11 bytes in order to preserve the terminating NULL character.
, scanf, gets, fgets.