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.
|
|