0
How to use gets () & puts () ? Give me example please..
4 Respuestas
+ 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