由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - C++读文件
相关主题
[转载] Mac C++ program questionerror while building gcc
C/C++ __int64和long long, cross platform问题cost time of shift operation?
bit count in value from 0 - 255Binary GCD algorithm
谢谢大家!One More Question! Re: C 程序计算结果reverse bits 的题目
贡献一下:本版上搜集的 Google 面试题 (转载)问个C的问题
一道c++ 题, 找出duplicate numbers谁知道
How to encode YYYY-MM-DD?What is "number of bits set"?
Embedded C 编程问题求助10G文件的排序问题
相关话题的讨论汇总
话题: c++话题: 文件话题: get话题: 一行话题: 数字
进入Programming版参与讨论
1 (共1页)
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.

1 (共1页)
进入Programming版参与讨论
相关主题
10G文件的排序问题贡献一下:本版上搜集的 Google 面试题 (转载)
structure to integer一道c++ 题, 找出duplicate numbers
怎么产生全排列?How to encode YYYY-MM-DD?
problem with C# serial port programmingEmbedded C 编程问题求助
[转载] Mac C++ program questionerror while building gcc
C/C++ __int64和long long, cross platform问题cost time of shift operation?
bit count in value from 0 - 255Binary GCD algorithm
谢谢大家!One More Question! Re: C 程序计算结果reverse bits 的题目
相关话题的讨论汇总
话题: c++话题: 文件话题: get话题: 一行话题: 数字