Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site fortune.UUCP Path: utzoo!linus!wivax!decvax!harpo!seismo!hao!hplabs!hpda!fortune!berry From: berry@fortune.UUCP Newsgroups: net.games.trivia Subject: how to unrot13 - (nf) Message-ID: <1187@fortune.UUCP> Date: Fri, 24-Jun-83 23:02:32 EDT Article-I.D.: fortune.1187 Posted: Fri Jun 24 23:02:32 1983 Date-Received: Mon, 27-Jun-83 03:14:10 EDT Sender: notes@fortune.UUCP Organization: Fortune Systems, San Carlos, CA Lines: 73 #N:fortune:4500006:000:1203 fortune!berry Jun 24 19:00:00 1983 Don't feel to bad, I'm sure most/all of the rest of us had to ask at one time. When I did I received half a dozen letters on what and how to undo rot13. The easiest way is: tr a-zA-Z n-za-mN-ZA-M or you can use the following program: /* * do a rot * * rot [shift factor] [files] * shift factor defaults to 13 * files " " stdin */ #include#include #define ROT 13 main(argc, argv) int argc; char *argv[]; { int rot; char c; if((argc < 2) || ((rot = atoi(argv[1])) == 0)) rot = ROT; else { argc--; ++argv; } while(*++argv) { if(freopen(*argv, "r", stdin) == NULL) perror(*argv); else rotate(rot); } if(argc == 1) rotate(rot); exit(0); } rotate(rot) int rot; { char c; while((c=getchar()) != EOF) { if(isupper(c)) c = 'A' + (c - 'A' + rot) % 26; else if(islower(c)) c = 'a' + (c - 'a' + rot) % 26; putchar(c); } } The above was received in one of the letters I received and then heavily modified by me. Whoever sent it I appreciate it and apologize for not having the foresight/courtesy to jot down your name to reference. David W. Berry hpda!fortune!berry harpo!fortune!berry ihnp4!fortune!berry ----------