##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::gets

From cppreference.com
< cpp‎ | io‎ | c

Defined in header `<cstdio>` |  |
char *gets( char *str ); |  | (deprecated)

Reads stdin into given character string until a newline character is found or end-of-file occurs.

### [edit] Parameters

str | - | character string to be written

### [edit] Return value

`str` on success, NULL on failure.

If the failure has been caused by end of file condition, additionally sets the eof indicator (see std::feof()) on stdin. If the failure has been caused by some other error, sets the error indicator (see std::ferror()) on stdin.

### [edit] Notes

The bounds checking is not performed, therefore this function is extremely vulnerable to buffer-overflow attacks. Use fgets() instead.

### [edit] See also

scanf fscanf sscanf | reads formatted input from stdin, a file stream or a buffer (function) [edit]
fgets | gets a character string from a file stream (function) [edit]
fputs | writes a character string to a file stream (function) [edit]
C documentation for gets

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/io/c/gets&oldid=65794"