Why is it usually a bad idea to use gets()? Suggest a workaround.



Why is it usually a bad idea to use gets()? Suggest a workaround...

Answer / 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

More C Interview Questions

What is the difference between int main and void main in c?

0 Answers  


What is the real difference between arrays and pointers?

27 Answers   Hexaware, Logic Pro, TCS,


How can I invoke another program from within a C program?

8 Answers  


how we do lcm of two no using c simple if while or for statement

1 Answers  


What is auto keyword in c?

0 Answers  






When can you use a pointer with a function?

0 Answers  


What are the advantages of the functions?

0 Answers  


Why c is faster than c++?

0 Answers  


Explain how can I convert a number to a string?

0 Answers  


write a program to print the one dimensional array.

1 Answers  


to find out the reverse digit of a given number

6 Answers   Infosys, Microsoft, TCS, Wipro,


What is function what are the types of function?

0 Answers  


Categories