What is return type of gets() and puts() function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is return type of gets() and puts() function

6th Dec 2018, 6:27 AM
King AAA
King AAA - avatar
2 Answers
0
Library function, gets(s) reads a string from the standard input into an array pointed to by s; and, puts(s) writes a string pointed to by s to the standard output. ... If reading is successful,gets() returns the pointer to the string; otherwise, it returns a NULL pointer, i.e. a pointer whose value is zero. Here is an detailed example https://www.javatpoint.com/c-gets-puts
6th Dec 2018, 6:29 AM
MsJ
MsJ - avatar
0
Generally gets should be not used it gives the buffer overflow problem because in c overflow condition not checked so if you have defined Char buf[20]; gets(buf); Scanf("%s",buf); Then if you put more than 20 characters then it starting overwriting which cause loose of data so fgets should be preferred fgets(buf,20,stdin);
6th Dec 2018, 6:43 AM
MsJ
MsJ - avatar