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 ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the advantages and disadvantages of macros.

624


What is the difference between new and malloc functions?

580


Why do we use int main?

610


What is the right type to use for boolean values in c? Is there a standard type?

564


What are types of structure?

604






What is the difference between pure virtual function and virtual function?

652


Which is better malloc or calloc?

651


Is return a keyword in c?

598


write a program using linked list in which each node consists of following information. Name[30] Branch Rollno Telephone no i) Write the program to add information of students in linked list

2236


How can I sort a linked list?

635


What is the method to save data in stack data structure type?

606


write a program to find the given number is prime or not

3845


write a C program: To recognize date of any format even formats like "feb-02-2003","02-february-2003",mm/dd/yy, dd/mm/yy and display it as mm/dd/yy.

3339


what is recursion in C

616


What is a pointer in c plus plus?

696