由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - How to read a simple csv file in C++?
相关主题
关于文件读取的C++ 问题?how to read a sentence into a vector of string?
有人能解释一下这段C++代码吗C++ Q 99-102 (转载)
How to read binary(data) file generated by Fortran in C/C++ (转载)请教一个C++的问题
C++文件读取数值问题C++中如何数据文件一起build进exe文件中?
C++: How to read until the end of file?Urgent question
这个面试题有什么trick?C++ 在 windows 上 结果正确, 在 linux 上结果总是不一样,怎
C++读文本文件怎么判断换行?这样读多个文件对吗?
问一个C++文件读取的问题Re: [转载] 这样读多个文件对吗?
相关话题的讨论汇总
话题: c++话题: file话题: simple话题: line话题: word1
进入Programming版参与讨论
1 (共1页)
c**********e
发帖数: 2007
1
The file is in very simple format:
345,Dan Smith
312,Jannifer E Lee
100050,Phillips
......
Basically, the first variable is an integer, and the second is a string.
The two are separated by a comma. Each line is one observation. Thanks.
r*******y
发帖数: 290
2
std::ifstream ifs;
ifs.open("file_name");
char line[256];
std::string word1, word2;
while(ifs.getline(line, 256, ',') {
word1 = line;
ifs.getline(line, 256);
word2 = line;
std::cout << "word1 is" << word1 << "\t"
<< "word2 is" << word2 < }

【在 c**********e 的大作中提到】
: The file is in very simple format:
: 345,Dan Smith
: 312,Jannifer E Lee
: 100050,Phillips
: ......
: Basically, the first variable is an integer, and the second is a string.
: The two are separated by a comma. Each line is one observation. Thanks.

1 (共1页)
进入Programming版参与讨论
相关主题
Re: [转载] 这样读多个文件对吗?C++: How to read until the end of file?
[转载] Re: [转载] 这样读多个文件对吗?这个面试题有什么trick?
读取数据求教C++读文本文件怎么判断换行?
问一个打开文件的问题问一个C++文件读取的问题
关于文件读取的C++ 问题?how to read a sentence into a vector of string?
有人能解释一下这段C++代码吗C++ Q 99-102 (转载)
How to read binary(data) file generated by Fortran in C/C++ (转载)请教一个C++的问题
C++文件读取数值问题C++中如何数据文件一起build进exe文件中?
相关话题的讨论汇总
话题: c++话题: file话题: simple话题: line话题: word1