I've searched everywhere and can't find a way to split a char array by space (" ") and store each word into a vector.
For example, user inputs "House 400", splitInput [0] = House, splitInput [1] = 400.
...
1 2 3 4 5 6 7 8 9 10 11 12 13
int main()
{
string input;
vector <string> splitInput;
getline(cin, input);
char* chararray = newchar[input.length() + 1];
strcpy_s(chararray, input.length() + 1, input.c_str());
//code to split chararray by space and store into splitInput
}
int main()
{
char c[] = "the quick brown fox 1234";
int l = strlen(c);
vector<char[100]> vc(20); //you can use a push-back somewhere if you don't want to do this up front. The extras print extra lines below, but this isnt exactly code of the year anyway.
int w = 0;
int p = 0;
for(int i = 0; i <= l; i++)
{
if(c[i] != ' ' && c[i])
vc[w][p++] = c[i];
else
{
vc[w++][p] = 0;
p = 0;
}
}
for(int i = 0; i < vc.size(); i++)
cout << vc[i] << endl;
}