在c++中怎样按行读取数据并保存到相应字符串数组中

我已经把数据写到文件中,怎样读取其中的文件保存起来。

第1个回答  2008-05-27
#include<fstream>
#include<iostream>
using namespace std;

int main()
{
ifstream ifs;
char ch[100][100]={0};
ifs.open("c:\\1.txt");
for(int i=0;!ifs.eof();i++)
{
ifs.getline(ch[i],100);
cout<<ch[i]<<endl;
}
ifs.close();
return 0;
}本回答被提问者采纳
相似回答
大家正在搜