answersLogoWhite

0

The library function gets() reads a string from stdin and removes any trailing newline.

The library function puts() writes a string to stdout and adds a trailing newline.

The original intent of these functions was to provide convenient ways of reading and writing whole lines, rather than doing character I/O.

Both functions are deprecated and should not be used in new programs. They are retained for compatibility, as they are part of the ANSI C Standard Library. The gets() function, in particular, is notorious for its potential for abuse; since it has no way of knowing the capacity of the buffer in which it is storing the string, it cannot prevent buffer overruns. By overrunning the buffer, an upstream program can tamper with the memory contents of the program that uses gets(). Historically, this has led to system and application program vulnerabilities that have been exploited by many malicious programmers. Virtually all calls to gets() have been removed from production software over the last 20 years.

User Avatar

Wiki User

14y ago

What else can I help you with?

Related Questions

Functions except gets and puts in c?

printf , scanf , getchar, putchar, getc are the other operators in C except gets and puts..


What are the usage of IF statement in C plus plus program?

Conditional execution. if (1==2) puts ("Wow, 1==2"); else puts ("No, 1<>2")


C plus plus program that will count?

#include int main (void) { puts ("1 2 3"); }


Show the simple c plus plus program?

int main (void) { puts ("Hello, world"); return 0; }


How do you get your c plus up to an a?

Here are links to several questions that will help you in this task!


What is a main function in c plus plus?

It is the first function that gets called when the program is executed.


What statement would accept in C plus plus and entire line of input including spaces?

You would need a header file stdio.h(standard input output) and the function gets() Gets function takes one parameter a character array into which the entire string (including spaces will the inserted) #include<stdio.h> int main() { char test[60]; gets(test); puts(test); //for printing the string }


What happens as 'a' from'a plus b equals c' gets smaller?

Either b remains the same and c gets smaller or b gets larger so that c remains the same or both b and c change and nothing is predicatable.


Is C plus plus good for Embedded programming or not?

C and C++ programming is good for embedded programming. However, embedded implies long running, and that means the possibility of memory fragmentation. You will need to spend time working out or acquiring a method of memory management, such as the use of Smart Pointers and Garbage Collection. This is not a trivial task, but it is a necessary task.


How can you display the backslash character without the compiler interpreting it as a program command in c plus plus?

Double it: puts ("Here\\comes\\an\\example"); output: Here\comes\an\example


How do you write a program in c plus plus in which static variables are declared?

#include <stdio.h> static int myvar1, myvar2; int main (void) { puts ("It was easy"); return 0; }


C plus plus is a lot of fun and productive?

If you're into programming it is a lot of fun. It's productive because you can write a program that will save you a lot of time to accomplish a task.