{"id":7231,"date":"2022-12-20T19:35:55","date_gmt":"2022-12-20T22:35:55","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/gets-man3\/"},"modified":"2022-12-20T19:35:55","modified_gmt":"2022-12-20T22:35:55","slug":"gets-man3","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/gets-man3\/","title":{"rendered":"GETS (man3)"},"content":{"rendered":"<h1 align=\"center\">GETS<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#RETURN VALUE\">RETURN VALUE<\/a><br \/> <a href=\"#ATTRIBUTES\">ATTRIBUTES<\/a><br \/> <a href=\"#CONFORMING TO\">CONFORMING TO<\/a><br \/> <a href=\"#BUGS\">BUGS<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#COLOPHON\">COLOPHON<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">gets \u2212 get a string from standard input (DEPRECATED)<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <stdio.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>char *gets(char *<\/b><i>s<\/i><b>);<\/b><\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b><i>Never use this function<\/i><\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>gets<\/b>() reads a line from <i>stdin<\/i> into the buffer pointed to by <i>s<\/i> until either a terminating newline or <b>EOF<\/b>, which it replaces with a null byte (&#8216;\u0000&#8217;). No check for buffer overrun is performed (see BUGS below).<\/p>\n<h2>RETURN VALUE <a name=\"RETURN VALUE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>gets<\/b>() returns <i>s<\/i> on success, and NULL on error or when end of file occurs while no characters have been read. However, given the lack of buffer overrun checking, there can be no guarantees that the function will even return.<\/p>\n<h2>ATTRIBUTES <a name=\"ATTRIBUTES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">For an explanation of the terms used in this section, see <b>attributes<\/b>(7).<\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"> <\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"8%\"> <\/td>\n<td width=\"8%\"><\/td>\n<td width=\"7%\"><\/td>\n<td width=\"62%\"> <\/td>\n<\/tr>\n<\/table>\n<p align=\"center\"><img decoding=\"async\" src=\"grohtml-1667971.png\" alt=\"Image grohtml-1667971.png\"><\/p>\n<h2>CONFORMING TO <a name=\"CONFORMING TO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">C89, C99, POSIX.1-2001.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">LSB deprecates <b>gets<\/b>(). POSIX.1-2008 marks <b>gets<\/b>() obsolescent. ISO C11 removes the specification of <b>gets<\/b>() from the C language, and since version 2.16, glibc header files don\u2019t expose the function declaration if the <b>_ISOC11_SOURCE<\/b> feature test macro is defined.<\/p>\n<h2>BUGS <a name=\"BUGS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Never use <b>gets<\/b>(). Because it is impossible to tell without knowing the data in advance how many characters <b>gets<\/b>() will read, and because <b>gets<\/b>() will continue to store characters past the end of the buffer, it is extremely dangerous to use. It has been used to break computer security. Use <b>fgets<\/b>() instead.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">For more information, see CWE-242 (aka &#8220;Use of Inherently Dangerous Function&#8221;) at http:\/\/cwe.mitre.org\/data\/definitions\/242.html<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>read<\/b>(2), <b>write<\/b>(2), <b>ferror<\/b>(3), <b>fgetc<\/b>(3), <b>fgets<\/b>(3), <b>fgetwc<\/b>(3), <b>fgetws<\/b>(3), <b>fopen<\/b>(3), <b>fread<\/b>(3), <b>fseek<\/b>(3), <b>getline<\/b>(3), <b>getwchar<\/b>(3), <b>puts<\/b>(3), <b>scanf<\/b>(3), <b>ungetwc<\/b>(3), <b>unlocked_stdio<\/b>(3), <b>feature_test_macros<\/b>(7)<\/p>\n<h2>COLOPHON <a name=\"COLOPHON\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">This page is part of release 5.10 of the Linux <i>man-pages<\/i> project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https:\/\/www.kernel.org\/doc\/man\u2212pages\/.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  gets \u2212 get a string from standard input (DEPRECATED) <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,2055,3007],"class_list":["post-7231","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-gets","tag-man3"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7231","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7231"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7231\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7231"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7231"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7231"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}