I did see about using vector, but it seemed a bit complicated. But, I did make a working version, the only way I knew how, using substr to grab char by char and check it's not a space.
Code: Select all
#include <iostream>
#include <string>
using namespace std;
int main()
{
string line;
while (getline(cin, line))
{
string input[20];
int chars = line.length(), p = 0;
for (int i = 0; i < chars; i++)
{
string c (line.substr(i, 1));
if (c != " ")
input[p] += c;
else
p++;
}
if (input[0] == "INVALID_COMMAND")
cout << "0xffccaaInvalid command \"0xaaccdd" << input[1] << "0xffccaa\" entered by 0xaaccdd" << input[2] << "0xffccaa." << endl;
}
return 0;
}