string and stream input

Is it possible to use stream input(for example cin.get, cin.getline...)with a string? I see only that these are used with character arrays; for example:


int main
{
char word [20];
cin.get(word, 5);
cout<<word;
return 0;

}
if it's possible, how?
Yes you can.

1
2
3
4
5
6
7
8
9
string str;
	
// Read one word.
// http://www.cplusplus.com/reference/string/string/operator%3E%3E/
cin >> str;
	
// Read the whole line.
// http://www.cplusplus.com/reference/string/string/getline/
getline(cin, str);
Topic archived. No new replies allowed.