Path: utzoo!hoptoad!amdcad!apple!usc!elroy.jpl.nasa.gov!zardoz!mti!jarthur!jonathan From: jonathan@jarthur.Claremont.EDU (Jonathan Ball) Newsgroups: alt.sources Subject: Re: why - your helpful confidant Summary: An extended version of dave kraft's why.c Message-ID: <1689@jarthur.Claremont.EDU> Date: 9 Aug 89 18:33:55 GMT References: <1941@diamond.warwick.ac.uk> <900@lakesys.UUCP> Reply-To: jonathan@jarthur.claremont.EDU (Jonathan Ball) Organization: Harvey Mudd College, Claremont, CA Lines: 90 Here's the why.c program again, but this time with a little smarter statement to reply parser. Handles most questions well. why.c: ----------(Cute Hare)--------------(Cat Hair)--------------(Cant Hear)-------- main (argc, argv) int argc; char *argv[]; { int w; int i, r; char *p; w = argc -1; if(w) { printf("I don't know why "); if (argc >2) { if((strcmp(argv[1], "not")) && (strcmp(argv[1], "in"))) { p = argv[2]; argv[2] = argv[1]; argv[1] = p; if(!(strcmp(argv[1], "the"))) { p = argv[3]; argv[3] = argv[2]; argv[2] = p; } } } for (i=1; i <= w; i++) { if(!(strcmp(argv[i], "I") && strcmp(argv[i], "i"))) argv[i] = "you"; else if(!(strcmp(argv[i], "me"))) argv[i] = "you"; else if(!(strcmp(argv[i], "my"))) argv[i] = "your"; else if(!(strcmp(argv[i], "mine"))) argv[i] = "yours"; else if(!(strcmp(argv[i], "you"))) { argv[i] = "I"; if(!(strcmp(argv[++i], "are"))) argv[i] = "am"; } else if(!(strcmp(argv[i], "your"))) { argv[i] = "my"; p = argv[i+2]; argv[i+2] = argv[i+1]; argv[i+1] = p; } else if(!(strcmp(argv[i], "yours"))) argv[i] = "mine"; else if(!(strcmp(argv[i], "am"))) argv[i] = "are"; } for (i=1; i <= w; i++) { printf("%s ", argv[i]); } } else { if((r = (getpid() % 4)) == 0) printf("Why not?"); else if(r == 1) printf("Just because."); else if(r == 2) printf("Don't ask."); else if(r == 3) printf("Because I feel like it."); } printf("\n"); } -------(Cut Here)--------------(Cut Here)----------------(Cut Here)--------- Feel free to continue modifying this, and I would be interested in knowing about any upgrades. -- Jonathan M. Ball | A UNIX saleslady, Lenore, liked her work jonathan@jarthur.claremont.EDU | but she loved the sea more. She found a uunet!jarthur!jonathan | good way to combine work and play: jball@hmcvax.bitnet | She sells C shells at the sea shore.