0
How to use gets () & puts () ? Give me example please..
4 Answers
+ 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
+ 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
+ 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 š
+ 1
check documentation of c for detailed usage