getline() for string

This is a discussion on getline() for string within the C++ Programming forums, part of the General Programming Boards category; Is there any function to read one line from a string?
Code:
#include <string>
std::string str, str2;
std::getline(cin, str, 'p');
...

I know. I usually don't work with string and less than it string stream. I am serching for a function to read a line. That seems impossible for string. So I am going to use string stream.
How can I read from cin to string stream? I think I knew these things some day, but I can't remember.

It gets cin streambuf and puts it into stream. But this code won't work as we want because there is no delim for cin to put characters into streambuf. And because it never reaches EOF, it will get keys from keyboard forever.

It gets cin streambuf and puts it into stream. But this code won't work as we want because there is no delim for cin to put characters into streambuf. And because it never reaches EOF, it will get keys from keyboard forever.

I faked EOF by typing ctrl+z on my Windows computer, but I don't know how to get it to work any other way. Sorry. I think if you want to stop at something like 'p' from cin, you need to read a string from cin, then use the string to make a stringstream, then read from the stringstream with a different delim.

I used ctrl+z but it works crazy. It goes crazy after pressing a key. It is cin.get() that losses its functionality after reading rdbuf().

Code:

stringstream inp;
inp << cin.rdbuf();
cin.get();

Ah, isn't there a flag in cin that's set when it sees EOF? This is just a guess, but I bet it would work if you cleared it. I had that problem with a guessing game I wrote last week, and using cin.clear() fixed it all up.