简体   繁体   English

ifstream gcount在getline字符串重载时返回0

[英]ifstream gcount returns 0 on getline string overload

I'm finding that gcount on an ifstream object after a call to 我在调用后在ifstream对象上找到该gcount

  getline(istream &, string &) 

returns 0. 返回0。

Is this supposed to be the case? 应该是这样吗?

Yes, gcount() is supposed to return the number of characters extracted by the last unformatted input operation performed on the object. 是的, gcount()应该返回通过对对象执行的最后一次未格式化输入操作提取的字符数。

getline() is listed in the functions supposed to updated gcount() , but it is the member getline() of a stream and not the string getline() . getline()在应该更新gcount()的函数中列出,但它是流的成员getline()而不是字符串getline()

In case of doubt, this link tells it black on white: Behaves as UnformattedInputFunction, except that input.gcount() is not affected. 如有疑问, 此链接将其告知为黑底白字: 行为为UnformattedInputFunction, 但input.gcount()不受影响。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM