x****t 发帖数: 389 | 1 比如有文件如下
a 1 2
c 3 5
d 9
h 9 1
一行一行读文件,在读到第三行的时候,第三个数字没有了,我希望程序能默认这个缺
少的数字为1,如果不缺,就该多少是多少,请问在C++中如何实现?
多谢! | k**f 发帖数: 372 | 2 http://www.cplusplus.com/reference/string/operator%3E%3E.html
Get each line into a string stream first.
Get the number out of the stream using operator>>, after the 3rd operation,
check the status bits to see if the character is missing. | x****t 发帖数: 389 | 3 it works, thanks !!
,
【在 k**f 的大作中提到】 : http://www.cplusplus.com/reference/string/operator%3E%3E.html : Get each line into a string stream first. : Get the number out of the stream using operator>>, after the 3rd operation, : check the status bits to see if the character is missing.
|
|