So I'm doing a shell in c++, I'm a noobie here. My code is the following:
#include <iostream>
using namespace std;
int main()
{
string action;
bool run = true;
while (run == true) {
cout << "shell > ";
cin >> action;
if (action == "help" || action == "Help") {
cout << "Here is a list of commands: \n";
cout << "help - displays a list of useful commands.\n";
}else if (action == "echo" || action == "Echo") {
string echo_c;
cout << "What to display? ";
cin >> echo_c;
cout << echo_c << "\n";
}
}
}
It prompts me the action and I say "echo", it asks me what to display and I say "Hello world".
Output:
shell > echo
What to display? Hello World
Hello
shell > shell >
It repeats "shell > " and cuts the "world" from "Hello world".
Someone help me plese.