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

Why cant I open a file by its explicit path?

597


What are variables c?

626


What are pointers? What are different types of pointers?

634


How to declare pointer variables?

689


is it possible to create your own header files?

648






Explain 'bit masking'?

659


Explain c preprocessor?

687


How can I manipulate individual bits?

611


What is the use of a conditional inclusion statement in C?

607


How many levels of pointers have?

602


What are the benefits of organizational structure?

577


The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.

1070


What is double pointer in c?

593


Why is c called c?

637


Why do we need arrays in c?

589