Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/12/84; site mit-hermes.ARPA Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!bellcore!decvax!genrad!mit-eddie!mit-hermes!jpexg From: jpexg@mit-hermes.ARPA (John Purbrick) Newsgroups: net.unix,net.jokes Subject: Re: Saving rotated jokes unrotated Message-ID: <2398@mit-hermes.ARPA> Date: Thu, 23-May-85 12:49:08 EDT Article-I.D.: mit-herm.2398 Posted: Thu May 23 12:49:08 1985 Date-Received: Sun, 26-May-85 00:49:09 EDT References: <184@weitek.UUCP> Organization: The MIT AI Lab, Cambridge, MA Lines: 43 Xref: watmath net.unix:4641 net.jokes:12422 > Voila! rotated joke saved in readable form. > Maybe someone knows a better way. I'm listening... Maybe not better, but here's a different method. Rot-13 is simply a procedure of swapping every letter with the one 13 places forward (or back) in the alphabet (ie a<-->n, b<-->o, c<-->p etc) so a simple program will do it. I wrote one (with considerable ignorance, but I've never got around to updating it) called rotify.c which takes the contents of a file and replaces it with the rotified version, up to 10000 chars. With this you can save a rot-13 joke or make up your own with a question and an answer which is readable by hitting D. (Obviously, to do this you only rotify the answer.) John Purbrick jpexg@mit-hermes.ARPA {...decvax!genrad! ...allegra!mit-vax!} mit-eddie!mit-hermes!jpexg #define MAXBYTES 10000 main(){ int fnum, numbytes, clox; char inbuf[MAXBYTES], fname[20]; printf("What file to rotify? "); scanf("%s", fname); /* Get the file name */ fnum = open(fname, 522, 0); /* Open for reading */ numbytes = read(fnum, inbuf, MAXBYTES); /* Transfer to buffer */ close(fnum); fnum = open(fname, 1025, 0); /* Reopen for writing */ for (clox = 0; clox < numbytes; clox++) /* Rotify!! */ { if ((inbuf[clox] > ('a'-1)) && (inbuf[clox] < 'n')) inbuf[clox] += 13; else if ((inbuf[clox] > 'm') && (inbuf[clox] < ('z'+1))) inbuf[clox] -= 13; else if ((inbuf[clox] > ('A'-1)) && (inbuf[clox] < 'N')) inbuf[clox] += 13; else if ((inbuf[clox] > 'M') && (inbuf[clox] < ('Z'+1))) inbuf[clox] -= 13; else continue; /* Ignore nonalphabetics */ } write(fnum, inbuf, numbytes); /* Write the file again */ close(fnum); /* And close it */ }