666 SEARCHER -- C LANGUAGE VERSION
==================================
[Thanks to a CN reader for the following]
/*
| srchr.c
|
| This is a C implementation of Brian Redman's QuickBasic 666 Searcher.
| You can do whatever you want with it. If one of the things you want
| to do is compile it, then "cc -s -O srchr.c -o srchr" should work on
| both unix and dos. Enjoy!
*/
#include
main(ac, av)
int ac;
char **av;
{
int c,
x;
char *p,
*fgets(),
buf[BUFSIZ];
c = ~EOF;
do {
printf("Enter name: ");
if (fgets(buf, sizeof(buf), stdin) == (char *)NULL) break;
for (c = 0, p = buf; *p; p++) {
if (*p == '\n') {
*p = '\0'; break;
}
if ((x = *p) > 90) x -= 32;
x -= 64; x *= 6; c += x;
}
printf("%s = %d\n", buf, c);
do{
printf("Again? ");
if ((c = getchar()) != EOF)
switch (c) {
case '\n': continue;
case 'y':
case 'Y': break;
default: c = EOF;
}
while ((x = getchar()) != EOF && x != '\n');
} while (c != 'y' && c != 'Y' && c != EOF);
} while (c != EOF);
printf("Thank you for using 666 Searcher.\n");
exit(0);
}
| |