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 ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is extern storage class in c?
What is a constant?
Write a program to swap two numbers without using third variable?
Define recursion in c.
What are the different types of C instructions?
What is typedf?
How will you write a code for accessing the length of an array without assigning it to another variable?
Explain how are portions of a program disabled in demo versions?
How can I get back to the interactive keyboard if stdin is redirected?
What are terms in math?
What is c++ used for today?
Who is the founder of c language?
What is adt in c programming?
How are Structure passing and returning implemented by the complier?
Explain how do you print only part of a string?