S
Shane
So it's been a while since I've done anything in C++, but I thought I
could grab
cin >> input;
and it would go into string input, even if what's coming in happens to
be 3 words separated by spaces. I don't want to use c strings, I want
to use std::string.
So imagine the code
#include <iostream>
int main()
{
string input;
while(true)
{
cout << "Enter three words: ";
cin >> input;
cout << input;
}
}
So you would enter 3 words on the command line, but only one is spit
back at you because only the first one is stored in the string. Then
the loop continues and it actually picks up the next value for the
second loop, and so on.
What I want to happen is for input to store one string with three
words, etc.
Can someone help?
Shane
could grab
cin >> input;
and it would go into string input, even if what's coming in happens to
be 3 words separated by spaces. I don't want to use c strings, I want
to use std::string.
So imagine the code
#include <iostream>
int main()
{
string input;
while(true)
{
cout << "Enter three words: ";
cin >> input;
cout << input;
}
}
So you would enter 3 words on the command line, but only one is spit
back at you because only the first one is stored in the string. Then
the loop continues and it actually picks up the next value for the
second loop, and so on.
What I want to happen is for input to store one string with three
words, etc.
Can someone help?
Shane