[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
fgetchar() Read a Character from Stdin
#include <stdio.h>
int fgetchar(void);
fgetchar() reads a single character from 'stdin'.
Returns: The character read. EOF is returned on error or
end-of-file. However, because EOF is a legitimate integer
value that can be read by this function, feof() or
ferror() should be used to verify an end-of-file or error
condition.
Notes: fgetchar() is equivalent to fgetc(stdin).
fgetchar() is similar to getchar(), but getchar() is a
macro, while fgetchar() is a function.
-------------------------------- Example ---------------------------------
The following statements read characters from 'stdin' until a new
line is reached.
#include <stdio.h>
char buff[100];
int i, c;
main()
{
i = 0;
while ((c = fgetchar()) != '\n')
buff[i++] = c;
buff[i++] = '\0';
for (x = 0; x < i; x++)
printf("%c",buff[x]);
}
See Also:
fgetc()
getchar()
getc()
fputc()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson