here is what I want to do: The user needs to enter a command at the prompt and the program will evaluate the command to know what to do. If the command is not found then the shell will return the error "Command not found!". If the user enters the command EXIT then the program should exit. For simplicity and to avoid a problem with users pressing enter with nothing typed we will assume that users will always enter something. No empty strings will be used. I should to this with a loop here is what I want to do:
Example:
shell.exe
Shell>test
Command not found!
Shell>test2
Command not found!
Shell>exit
>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
char command[20];
while (command != "exit") {
//check with an if statement for valid commands
printf("Enter a command:\n");
gets(command);
}
if (command == "exit") {
//program should exit
}
return 0;
}