Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site CS-Mordred Path: utzoo!watmath!clyde!burl!ulysses!mhuxj!ihnp4!inuxc!pur-ee!CS-Mordred!jad From: jad@CS-Mordred (John Dilley) Newsgroups: net.jokes,net.flame Subject: rot.c programs Message-ID: <156@CS-Mordred> Date: Fri, 5-Oct-84 19:07:19 EDT Article-I.D.: CS-Mordr.156 Posted: Fri Oct 5 19:07:19 1984 Date-Received: Sat, 6-Oct-84 05:39:27 EDT Organization: Department of Computer Science, Purdue University Lines: 57 I really can't believe someone would post a C program to rotate jokes. Most thinking beings have heard of "tr", which does this easily in one line. If you don't have "tr", get a real UNIX system. If you don't know what "tr" is, go to the manual; go directly to the manual. Do not pass the candy machine, do not collect your last paycheck. Now, if you really want to do this in a C program, here are some more C-like options ... /* ---------- rot 1 ---------- */ # include# include main() { int ch; for (ch=getchar(); ch != EOF ; ch=getchar()) if (isalpha(ch)) if (isupper(ch)) putchar(ch>'M'?ch-13:ch+13); else putchar(ch>'m'?ch-13:ch+13); else putchar(ch); } /* ---------- rot 1 (8 lines) ---------- */ Or how about ... /* ---------- rot 2 ---------- */ # include # include main() { int ch; for (ch=getchar(); ch != EOF ; ch=getchar()) !isalpha(ch)? putchar(ch): (isupper(ch)?putchar(ch>'M'?ch-13:ch+13):putchar(ch>'m'?ch-13:ch+13)); } /* ---------- rot 2 (7 lines) ---------- */ Or better yet ... /* ---------- rot 3 ---------- */ # include # include main() { int ch; for (ch=getchar(); ch != EOF ; ch=getchar()) putchar(isalpha(ch)?ch>(isupper(ch)?'M':'m')?ch-13:ch+13:ch); } /* ---------- rot 3 (5 lines) ---------- */ Now how's that for obscure? I don't think it would win the C obfuscation award, but it's not something you'd give to a pilgrim. Happy Hacking ... -- john -- a.k.a. John Dilley terrapin@purdue or purdue!terrapin or pur-ee!dilley *UNIX is a trademark of AT&T Bell Laboratories