1. Write a C program that will simulate a terminal shell. The program should hav
ID: 3620729 • Letter: 1
Question
1. Write a C program that will simulate a terminal shell. The program should have the name chshell.exe.When the program starts it should show a prompt and wait for input from the user.
If the user presses enter it should go to the next line and show the prompt again. If the user types the word exit then the program will terminate.
For example:
>chsh.exe
chsh#
chsh#exit
>
2. If the user enters any command that is not recognized by the shell it should return an error message saying "Unrecognized Command" and go back to the prompt.
/*
Explanation / Answer
#include #include #define MAXLENGTH 1000 int main() { char input[MAXLENGTH]; int symb; do { printf("chsh#"); scanf("%s", input); symb = system(input); if(symb == -0) printf("Unrecognized Command "); }while (strcmp(input, "exit")); }Related Questions
Hire Me For All Your Tutoring Needs
Quick quotes • Clear explanations • Study support
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.