How to use gets () & puts () ? Give me example please.. | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

How to use gets () & puts () ? Give me example please..

20th Oct 2020, 6:04 AM
SARVESH ASHOK DEVRUKHAKAR
SARVESH ASHOK DEVRUKHAKAR - avatar
4 Antworten
+ 5
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
20th Oct 2020, 6:20 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 3
gets() was removed in C11. never use it. Note from C docs: """ The gets() function does not perform bounds checking, therefore this function is extremely vulnerable to buffer-overflow attacks. It cannot be used safely (unless the program runs in an environment which restricts what can appear on stdin). For this reason, the function has been deprecated in the third corrigendum to the C99 standard and removed altogether in the C11 standard. fgets() and gets_s() are the recommended replacements. Never use gets(). """ ~ https://en.cppreference.com/w/c/io/gets
20th Oct 2020, 6:33 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 2
Search the net for 'gets function deprecated', I would not recommend the use of `gets` function for that function is considered "dangerous". `puts` function may still be used 👌
20th Oct 2020, 6:34 AM
Ipang
+ 1
check documentation of c for detailed usage
20th Oct 2020, 6:11 AM
‎ ‏‏‎Anonymous Guy