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 the size of a union variable?
Is it possible to have a function as a parameter in another function?
Differentiate between calloc and malloc.
Write a program to produce the following output: 1 2 3 4 5 6 7 8 9 10
what is diffrence between linear and binary search in array respect to operators?what kind of operator can be used in both seach methods?
What is the purpose of void pointer?
Why we use break in c?
swap 2 numbers without using third variable?
What is difference between structure and union?
Explain can the sizeof operator be used to tell the size of an array passed to a function?
What is malloc calloc and realloc in c?
Explain the concept and use of type void.
What do you know about the use of bit field?
What is difference between static and global variable in c?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler