getchar <STDIO.H>
getchar is a macro that gets a character from stdin
Declaration:
int getchar(void);
Remarks:
getchar is a macro defined as getc(stdin) getchar returns the next character
on the input stream stdin.
Return Value:
On success,
getchar returns the character read, after converting it to an int
without sign extension.
On error (and on end-of-file for getchar), both macros return EOF.
Program
#include <stdio.h>
int main(void)
{
int c;
/* Note that getchar reads from stdin and
is line buffered; this means it will
not return until you press ENTER. */
while ((c = getchar()) != '\n')
printf("%c", c);
return 0;
}
0 comments:
Post a Comment