|
getsfunction
<cstdio> char * gets ( char * str ); Get string from stdin Reads characters from stdin and stores them as a string into str until a newline character ('\n') or the End-of-File is reached.The ending newline character ('\n') is not included in the string. A null character ('\0') is automatically appended after the last character copied to str to signal the end of the C string. Notice that gets does not behave exactly as fgets does with stdin as argument: First, the ending newline character is not included with gets while with fgets it is. And second, gets does not let you specify a limit on how many characters are to be read, so you must be careful with the size of the array pointed by str to avoid buffer overflows. Parameters
Return ValueOn success, the function returns the same str parameter.If the End-of-File is encountered and no characters have been read, the contents of str remain unchanged and a null pointer is returnes. If an error occurs, a null pointer is returned. Use either ferror or feof to check whether an error happened or the End-of-File was reached. Example
See also
|