New course! Every coder should learn Generative AI!
Try a free lesson+ 1
What is return type of gets() and puts() function
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
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);