ifstream gcount returns 0 on getline string overload

安稳与你 提交于 2019-12-11 05:25:30

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/28600797/ifstream-gcount-returns-0-on-getline-string-overload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!