Prevent buffer overflows with gets [duplicate]
This question already has an answer here: Why is the gets function so dangerous that it should not be used? 11 answers The declaration of gets is: char * gets ( char * str ); Note the glaring omission of a maximum size for str . cplusplus.com says 2 : Notice that gets is quite different from fgets: not only gets uses stdin as source, but it does not include the ending newline character in the resulting string and does not allow to specify a maximum size for str ( which can lead to buffer overflows ). And also: The most recent revision of the C standard (2011) has definitively removed this