Guardian C Library Calls Reference Manual
gets
3-84 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
gets
The gets function reads a string from the standard input file, stdin.
str_ptr
points to the string where gets stores the input string.
Return Value
is str_ptr if the operation is successful. If gets encounters the end of the file or an
error, it returns the pointer value NULL. To distinguish between these two cases, use
the feof or ferror function.
Usage Guidelines
•
The gets function reads until it encounters the end of the line.
•
Unlike fgets, which passes the newline character with a null character appended,
gets replaces the newline with a null.
Example
This example reads a string from the standard input file and stores it in the array named
sp:
#include <stdioh>
char *p;
char sp[200];
p = gets(sp);
#include <stdioh>
char *gets(char *str_ptr);