gets is a horrible function as it doesn't check if input entered will fit in the buffer provided possibly corrupting your program or worse. Avoid it and any resource that suggests using it.
Use fgets.
-
char buffer[BUFSIZ];
-
fgets(buffer, sizeof buffer, stdin);
-