Basically, I want the program to allow the user to input say, 2 words, and then split it into a vector. Like, if the user inputs: "Hello world," the program will take the words "Hello," and "world," and store them in a vector. The problem is, I'm not very experienced with vectors, so I have no clue where to start. Here's my code so far:
#include <iostream>
#include <vector>
using namespace std;
void command_case();
string userIn;
int x = 0;
int main()
{
    while(userIn != "QUIT")
    {
        cout << "What shall I do?" << endl;
        cin >> userIn;
        cout << "Your raw command was: " << userIn << endl;
        command_case();
    }
}
void command_case()
{
    vector<char> Search;
    vector<string> command;
    char space = ' ';
    for(int i = 0; i < userIn.size(); ++i)
    {
        if(userIn[i] != space)
        {
            userIn[i] = toupper(userIn[i]);
        }
        if(userIn[i] == space)
        {
            Search.push_back(userIn[i]);
        }
    }
    command.push_back(userIn);
    cout << command[x] << endl;
}
If I input "Hello world," I get this:
What shall I do?
Hello world
Your raw command was: Hello
HELLO
What shall I do?
Your raw command was: world
WORLD
but I would be looking for this:
What shall I do?
Hello world
Your raw command was: Hello world
HELLO WORLD
Could anyone explain to me what I'm doing wrong?
 
    