The message was a warning from the compiler. gets is a dangerous method because gets does not know the size of the buffer passed in. Take a look at this sample program:
Code:
#include <stdio.h>
main()
{
char szBufferOverrun[5];
if (( gets( szBufferOverrun )) == NULL )
{
perror( "gets failed" );
}
printf( "szBufferOverrun is [%s]\n", szBufferOverrun );
}
How well this program run is completely up to the user filling up the gets buffer. If you run this program and type in < 5 charcters the program is fine. If you type in > 5 characters, all bets are off. When I ran the program and typed in about 30 characters, the program printed out my string, then seg faulted.
Buffer overruns are a serious problem and a small bug, in a program, like the one in my example can often comprimise the security of an entire machine.
It is better to use a method like fgets and pass in STDINFILENO as the file pointer instead of using gets.