What is return type of gets() and puts() function | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

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

6th Dec 2018, 6:27 AM
King AAA
King AAA - avatar
2 Respostas
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