i have a problem with my following code, note: this is just part of my code
when i run it, lets say i enter hello world
it will output:
hello
segmentation fault
is there a way i can fix this?
void input::read_line()
{
string command;
while(command != "exit")
{
cout <<"Enter a command" << endl;
cin >> command;
string buf;
stringstream ss(command);
vector<string> tokens;
while(ss >> buf)
tokens.push_back(buf);
cout << tokens[0] << endl;
cout << tokens[1] << endl;
}