Programmer's Wiki
Advertisement

Synopsis[]

#include <stdio.h>
int putchar();

Description[]

getchar reads one character from stdin.

On success, the read character is returned. EOF is returned on end of file or if an error occurred.

Examples[]

#include <stdio.h>

int main()
{
  int ch;

  while((ch=getchar())!=EOF) putchar(ch);

  return 0;
}

This will copy anything read from stdin to stdout

See also[]

Advertisement