I have a small problem with string. How can I make the output str to be every single string
i.e:
string str="You are a good writer";
to be:
str1="you";
str2=“are";
str3="a";
str4="good";
str5="writer";
//---------my_test_code,but not working yet.
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string str;
getline(cin,str);
int i;
string::iterator It = str.begin();
while ( It != str.end() )
{
if (*It == ' ' )
*It = '\n';
cout <<*It++;
}
cout << endl;
return 0;
}