what would be the code to ask enter a command?
and if the answer is hello then make it run another .cpp file called hello
then after it runs that command it will run the file that asked enter a command
I will be compiling this to an a.out file. if thats what its called.
plz help
while(true)
{
std::string command;
std::cout << "enter a command: ";
std::cin >> command;
if(command == "hello")
system(".\hello.exe"); // name of the programm you want to start
if(command == "quit")
break;
}
so what you're trying to do is you want to create a command line, kinda like terminal or Cmd.
put all the code in a while loop.(the condition should always be true, else the command wont work).
the code inside the loop should look like this:
1 2 3 4 5 6
string mycommand;
cout << "Enter A Command:";
cin >> mycommand; //here you type your command,for example the "hello" command
if(mycommand == "hello") { //or any other command
system(".\hello.exe") //destination of the program you want to start
}