By Jegathesan | February 26, 2015 [Innovation Begins Here]
Run the following code
/*Innovation Begins Here */
printf(“Enter ur name\n”);
After executing code surely you will get one warning message.
warning: the gets function is dangerous and should not be used.
Do you know why?
The gets() system call is part of the C programming language’s standard I/O library. It takes a char pointer as its only input, and will try to fill the buffer the pointer presumably points to with a line of text. It is widely considered to be a bad idea, since it will gladly overflow any buffer it is passed (BoundsChecking is not performed, in other words, and this can lead to MemoryCorruption). Most C programmers regard use of gets() as a sign of general cluelessness on the part of whoever wrote the code.fgets() is widely advocated as a drop-in replacement to gets(), as fgets() also takes as a parameter the size of the buffer. But this is not entirely satisfactory, either, since if the input exceeds the size of the buffer fgets() will simply null-terminate the string right where the buffer ends and exit, leaving unread characters on standard input.