Question about getline function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • l46kok
    New Member
    • Sep 2006
    • 3

    Question about getline function

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

    cin.getline(cha racter 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?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    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

    Comment

    Working...