home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / OPENSTEP / UNIX / Games / fortune-mod-9708-I / util / rot.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-01  |  423 b   |  25 lines

  1. /*
  2.  * An extremely simpleminded function. Read characters from stdin,
  3.  * rot13 them, and put them on stdout.  Totally unnecessary, of course.
  4.  */
  5.  
  6. #include <stdio.h>
  7. #include <ctype.h>
  8.  
  9. int main(void)
  10. {
  11.     char a, b;
  12.  
  13.     while ((a = getchar()) != EOF)
  14.     {
  15.     if (isupper(a))
  16.         b = 'A' + (a - 'A' + 13) % 26;
  17.     else if (islower(a))
  18.         b = 'a' + (a - 'a' + 13) % 26;
  19.     else
  20.         b = a;
  21.     putchar(b);
  22.     }
  23.     exit(0);
  24. }
  25.