String getline function

Hello, everyone!

Can anyone tell me what is the (cin, not istream) getline function for a string, with some example code if possible, please?

Thanks!
For C++ it is:-
1
2
string s;
getline(cin,s)

//if " Harry Hopkins" is now entered s = "Harry Hopkins"
Hello,

Just getting back into programming after a number of years, using C++ in Visual Studio 2010 on Windows 7 SP1 and trying to learn C++ using 'Learn C++ by Making Games' from Charles River Media.

It's apparent that there are some code differences in the provided source and what is used with VS2010. For instance, I've figured out that #include <string> is needed for a number of functions in VS2010 where the included source does not mention it.

I'm currently banging my head on the getline() function. Using the included source as well as the example in the page that Moschops referenced, it compiles and runs fine, and shows the cout requesting the input but it never actually waits for the input from getline before proceeding with the rest of the code.

Thanks in advance for any help.
So, after a bit of time, I thought of a couple better search strings for my issue and I discovered that the newline character from a previous cin statement was just waiting in the wings to blow away the getline statement.

I used cin.ignore(1) to get rid of this and the code works as intended. :)

Thanks anyhow.
Please any one can help me in this I am also stuck in this istream:: getline() issue
I studied the following link this function is useful for me. But it doesnot work in my code.
I have a tab delimited text files somewhat like this

1.2 \t 2.2 \t...so on..\n
4.4 \t........................\n

http://www.cplusplus.com/reference/string/getline/

i donot know how many rows and columns are there. hence i cannot use ifstream::getline().since it asks no of charachters. I am getting the logic to use vector class and string class and ifstream. But this function is not working.. I am stuck there to read line by line
I am using Visual C++ 6.. our applications are developed based on this.Please any one can help. I beg of you. I am breaking my head on this. Please help me. Waiting for some replies
first of all, getline for string doesn't ask for number of characters. if you just use simple geline() without setting a delimiter it will read the whole line in the string. then you can setup another stream on the string and using the eof() condition read all the numbers till the end of that line.
Yes I could get .. I was sucess ful in that aspect..
If I click on the dialog box Plot button it should goback to SDI window and start plotting the pixels code what ever written n the ONDRAW() ... Postmessage window handle has to be used someway ... Can u give any sample code.. how to use it...
Topic archived. No new replies allowed.