getchar()                Read a Character from 'Stdin'
 
 #include   <stdio.h>
 
 int        getchar(void);
 
    getchar() reads a single character from the stream 'stdin'.
 
    Returns:    The character read, if successful.  'getchar' returns the
                value of EOF if there is an error or end-of-file
                condition.
 
      Notes:    Use feof() or ferror() to determine whether an error or
                end-of-file condition occurred.
 
                getchar() is equivalent to getc(stdin).
 
                getchar() is similar to fgetchar(), but 'getchar' is a
                macro, while 'fgetchar() is a function.
 
  -------------------------------- Example ---------------------------------
 
    The following statements get characters from 'stdin' and store them
    in 'string' until a new-line character is read. The string is then
    printed.
 
         #include <stdio.h>
 
         char string[81];
         int i;
         char ch;
 
         main()
         {
             i = 0;
             while ((ch = getchar()) != '\n')
                   string[i++] = ch;
             printf("\n%s\n",string);
         }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster