ifstream gcount returns 0 on getline string overload
Asked Answered
M

1

1

I'm finding that gcount on an ifstream object after a call to

  getline(istream &, string &) 

returns 0.

Is this supposed to be the case?

Mongrel answered 19/2, 2015 at 7:32 Comment(0)
D
2

Yes, gcount() is supposed to return the number of characters extracted by the last unformatted input operation performed on the object.

getline() is listed in the functions supposed to updated gcount(), but it is the member getline() of a stream and not the string getline().

In case of doubt, this link tells it black on white: Behaves as UnformattedInputFunction, except that input.gcount() is not affected.

Diarmid answered 19/2, 2015 at 7:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.