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 are the features of c languages?
What is the meaning of 2d in c?
What is modeling?
Can a pointer be static?
How can you increase the size of a statically allocated array?
In C language what is a 'dangling pointer'?
Explain what’s a signal? Explain what do I use signals for?
FILE PROGRAMMING
What is memcpy() function?
Explain the use of #pragma exit?
What is the size of array float a(10)?
How do you generate random numbers in C?
What are the ways to a null pointer can use in c programming language?
What are the basic data types associated with c?
Hello. How to write a C program to check and display president party like if i type in the console "biden" and hit enter the output shoud be : "biden is democrat" and if i type "trump" and hit enter the output shoud be: "trump is republican"