Next: Formatted Input / Up: Character Input / Previous: getchar

putchar

putchar puts its character argument on the standard output (usually the screen).

The following example program converts any typed input into capital letters. To do this it applies the function toupper from the character conversion library ctype.h to each character in turn.


  #include <ctype.h>  /* For definition of toupper */
  #include <stdio.h>  /* For definition of getchar, putchar, EOF */

  main()
  {   int ch;

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


January 1995