C++中如何读取文件中指定位置的字符啊
比方说 我读入一个文件
1 1 2
1 1 3
1 1 4
1 5 6
2 1 5
怎么只把第一列的字符给读进来?
[解决办法]
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
fstream fs( "a.txt ", ios::in|ios::out);
string str;
while(!fs.eof())
{
getline(fs,str);
string::size_type ix = 0;
cout < < str[ix] < < endl;
}
system( "pause ");
return 0;
}
编译vs2005