Trying to make CommandLine-terminal clone

Hello. Im trying to make a commandline-terminal clone but some parts of code doesnt work. It compiles but when i type help or exit it doesnt show anything and hangs. Can you help me?
Here is the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
using namespace std;
int main(){

char selection;
char close;
cout << "Command line-Terminal clone" << endl;
cout << "To see commands type help" << endl;
string root = "Root> ";
cout << root;
cin >> selection;
    if (selection == 'help'){
	    cout << "Available commands are:" << endl;
	    //command lists will be here.
            //And it doesnt shows anything. It just stops program.
        }
    else if (selection == close){
    	cout << "exiting." << endl;
    	//exit code here
    }
    
}
	
Last edited on
closed account (21vXjE8b)
Line 5 --> char selection; to string selection;
Line 12 --> selection == 'help' to selection == "help"
Line 17 --> selection == close to selection == "close"
Maybe changing this the code will work
Thank you so much man! I'm still learning and this helped me so much :)
Topic archived. No new replies allowed.