This is because you are reading a string using
cin >> command;
The >>
operator stops at the space, so your command ends up with no spaces in it. The next iteration of the loop picks up the first argument and tries to parse it; then the next iteration does the same with the last argument.
You can make your code work by using std::getline
instead:
getline(cin, command);
But an easier way to do the same thing is to use >>
operator correctly:
cin >> parsedStr[0];
cin >> parsedStr[1];
cin >> parsedStr[2];