1GETS(3)                    Linux Programmer's Manual                   GETS(3)
2
3
4

NAME

6       gets - get a string from standard input (DEPRECATED)
7

SYNOPSIS

9       #include <stdio.h>
10
11       char *gets(char *s);
12

DESCRIPTION

14       Never use this function.
15
16       gets()  reads  a  line from stdin into the buffer pointed to by s until
17       either a terminating newline or EOF, which it replaces with a null byte
18       ('\0').  No check for buffer overrun is performed (see BUGS below).
19

RETURN VALUE

21       gets()  returns  s  on  success,  and NULL on error or when end of file
22       occurs while no characters have been read.  However, given the lack  of
23       buffer  overrun  checking, there can be no guarantees that the function
24       will even return.
25

ATTRIBUTES

27       For  an  explanation  of  the  terms  used   in   this   section,   see
28       attributes(7).
29
30       ┌──────────┬───────────────┬─────────┐
31Interface Attribute     Value   
32       ├──────────┼───────────────┼─────────┤
33gets()    │ Thread safety │ MT-Safe │
34       └──────────┴───────────────┴─────────┘
35

CONFORMING TO

37       C89, C99, POSIX.1-2001.
38
39       LSB deprecates gets().  POSIX.1-2008 marks gets() obsolescent.  ISO C11
40       removes the specification of gets() from the C language, and since ver‐
41       sion  2.16, glibc header files don't expose the function declaration if
42       the _ISOC11_SOURCE feature test macro is defined.
43

BUGS

45       Never use gets().  Because it is impossible to tell without knowing the
46       data  in  advance  how  many  characters  gets() will read, and because
47       gets() will continue to store characters past the end of the buffer, it
48       is  extremely  dangerous  to  use.   It has been used to break computer
49       security.  Use fgets() instead.
50
51       For more information, see CWE-242 (aka  "Use  of  Inherently  Dangerous
52       Function") at http://cwe.mitre.org/data/definitions/242.html
53

SEE ALSO

55       read(2), write(2), ferror(3), fgetc(3), fgets(3), fgetwc(3), fgetws(3),
56       fopen(3),  fread(3),  fseek(3),   getline(3),   getwchar(3),   puts(3),
57       scanf(3), ungetwc(3), unlocked_stdio(3), feature_test_macros(7)
58

COLOPHON

60       This  page  is  part of release 5.02 of the Linux man-pages project.  A
61       description of the project, information about reporting bugs,  and  the
62       latest     version     of     this    page,    can    be    found    at
63       https://www.kernel.org/doc/man-pages/.
64
65
66
67GNU                               2017-09-15                           GETS(3)
Impressum