Why is it usually a bad idea to use gets()? Suggest a workaround.
Answer Posted / hrpynux@gmail.com
The function gets() reads characters from the stdin and stores them at the provided input buffer. However, gets() will keep reading until it encounters a newline character. Unless the buffer is large enough, or the length of the line being read is known ahead of time, gets() can potentially overflow the input buffer and start overwriting memory it is not supposed to, wreaking havoc or opening security vulnerabilities.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Explain the advantages and disadvantages of macros.
What is the difference between new and malloc functions?
Why do we use int main?
What is the right type to use for boolean values in c? Is there a standard type?
What are types of structure?
What is the difference between pure virtual function and virtual function?
Which is better malloc or calloc?
Is return a keyword in c?
write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list
How can I sort a linked list?
What is the method to save data in stack data structure type?
write a program to find the given number is prime or not
write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.
what is recursion in C
What is a pointer in c plus plus?