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
Explain Function Pointer?
What is a ternary operator in c?
What is extern variable in c with example?
Which is better pointer or array?
stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.
What is the use of sizeof () in c?
Is void a keyword in c?
What is the ANSI C Standard?
Differentiate between new and malloc(), delete and free() ?
Explain high-order bytes.
What is scope rule of function in c?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
Explain union.
Write a program to print fibonacci series without using recursion?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.