Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
getchar(3)
Edit
PageHistory
Diff
Info
LikePages
GETS !!!GETS NAME SYNOPSIS DESCRIPTION RETURN VALUE CONFORMING TO BUGS SEE ALSO ---- !!NAME fgetc, fgets, getc, getchar, gets, ungetc - input of characters and strings !!SYNOPSIS __#include __''stream''__); char *fgets(char *__''s''__, int__ ''size''__, FILE *__''stream''__); int getc(FILE *__''stream''__); int getchar(void); char *gets(char *__''s''__); int ungetc(int__ ''c''__, FILE *__''stream''__); __ !!DESCRIPTION __fgetc()__ reads the next character from ''stream'' and returns it as an __unsigned char__ cast to an __int__, or __EOF__ on end of file or error. __getc()__ is equivalent to __fgetc()__ except that it may be implemented as a macro which evaluates ''stream'' more than once. __getchar()__ is equivalent to __getc(__''stdin''__)__. __gets()__ reads a line from ''stdin'' into the buffer pointed to by ''s'' until either a terminating newline or __EOF__, which it replaces with __'0'__. No check for buffer overrun is performed (see __BUGS__ below). __fgets()__ reads in at most one less than ''size'' characters from ''stream'' and stores them into the buffer pointed to by ''s''. Reading stops after an __EOF__ or a newline. If a newline is read, it is stored into the buffer. A __'0'__ is stored after the last character in the buffer. __ungetc()__ pushes ''c'' back to ''stream'', cast to __unsigned char__, where it is available for subsequent read operations. Pushed - back characters will be returned in reverse order; only one pushback is guaranteed. Calls to the functions described here can be mixed with each other and with calls to other input functions from the __stdio__ library for the same input stream. !!RETURN VALUE __fgetc()__, __getc()__ and __getchar()__ return the character read as an __unsigned char__ cast to an __int__ or __EOF__ on end of file or error. __gets()__ and __fgets()__ return ''s'' on success, and __NULL__ on error or when end of file occurs while no characters have been read. __ungetc()__ returns ''c'' on success, or __EOF__ on error. !!CONFORMING TO ANSI - C, POSIX.1 !!BUGS Never use __gets()__. Because it is impossible to tell without knowing the data in advance how many characters __gets()__ will read, and because __gets()__ 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 __fgets()__ instead. It is not advisable to mix calls to input functions from the __stdio__ library with low - level calls to __read()__ for the file descriptor associated with the input stream; the results will be undefined and very probably not what you want. !!SEE ALSO read(2), write(2), fopen(3), fread(3), scanf(3), puts(3), fseek(3), ferror(3) ----
One page links to
getchar(3)
:
Man3g
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.