First the code
Code:
[cdalten@localhost YAPP]$ more main.c
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char *argv[])
{
conference(&argc, &argv);
/*cleanup();*/
exit(EXIT_SUCCESS);
}
[cdalten@localhost YAPP]$
Code:
[cdalten@localhost YAPP]$ more driver.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char buf[BUFSIZ];
int strip_line(char line[]) {
int n;
for (n = strlen(line)-1; n >= 0; n--)
if (line[n] != ' ' && line[n] != '\t')
break;
line[n+1] = '\0';
return n;
}
void conference_prompt(void) {
fputs("Type Help for more information\n", stdout);
do {
strip_line(buf);
fputs("OK:", stdout);
fflush(stdout);
} while (fgets(buf, BUFSIZ, stdin) != NULL);
}
void conference(int *argc, char *argv[]) {
if (*argc == 1) {
conference_prompt();
}
}
[cdalten@localhost YAPP]$
[cdalten@localhost YAPP]$ gcc main.c driver.c -o yapp
[cdalten@localhost YAPP]$ ./yapp
Type Help for more information
OK:
What I want to do is for a user to get a help menu when they type 'h' or 'help' at the 'OK:' prompt. I looked at getopt() but that only seems to work with command line args. And the switch statement doesn't seem to want to work when it see something like 'help'. Ideas?