I have been having a problem my code recently. i wish to be able to take an input from the user as a string then split it into substrings deliminated by whitespace. i did some research and discovered the istringstream iss() function. i tried this function with the following test code:
#include <iostream>
#include <sstream>
#include <string>
usingnamespace std;
int main()
{
string t = "Hello world this is a test";
istringstream iss(t);
string input[7];
int x = 0;
do
{
string sub;
iss >> input [x];
x++;
} while (iss);
x = 0;
while (x < 7){
cout << input [x] << " ";
x++;
}
system("PAUSE");
return 0;
}
and received the result
Hello
world
this
is
a
test
Press any key to continue...
however when i try similar code with user inputted strings:
THANK YOU SO MUCH! You have no idea how long this has taken me to figure out! is there a way to, for lack of a proper term, "thumb up" your account, so other users know how helpful you are? (Im new to this forum btw)