home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 14 / lc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  889 b   |  35 lines

  1. /*
  2.         LC:     a simple character-oriented filter to translate
  3.                 all uppercase {A-Z} to lowercase {a-z} characters.
  4.  
  5.         Usage:  LC [< source] [> destination]
  6.  
  7.         Ray Duncan, June 1987
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12.  
  13. main(argc,argv)
  14. int argc;
  15. char *argv[];
  16. {       char ch;
  17.                                         /* read a character */
  18.         while ( (ch=getchar() ) != EOF )
  19.         {       ch=translate(ch);       /* perform any necessary
  20.                                            character translation */
  21.                 putchar(ch);            /* then write character */
  22.         }       
  23.         exit(0);                        /* terminate at end of file */
  24. }
  25.  
  26. /*
  27.         Translate characters A-Z to lowercase equivalents
  28. */
  29.  
  30. int translate(ch)
  31. char ch;
  32. {       if (ch >= 'A' && ch <= 'Z') ch += 'a'-'A';
  33.         return (ch);
  34. }
  35.