By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,199 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

Question about getline function

P: 3
Just wondering, for character of arrays, you can set the delimiter manually like

cin.getline(character array, size, delimeter)

But for the STL string, apparently, you have to use the following form of getline

getline(cin, string)

So my question is, is there a way to set the delimeter using the STL string without converting it to character array?
Oct 1 '06 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 8,916
You can't set the delimiter for character arrays, it is always the 0 character '\0'

You can set the delimiter for the function cin.getline( )

If you want to use the cin.getline( ) version of the function for a string you can always call the member function string::c_str
Oct 1 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.