c++對文件操作
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream ifs;
ifs.open("yyp.cpp");
ofstream ofs;
ofs.open("hello1.txt");
char a[100];
while (!ifs.eof())
{
ifs.getline(a,100);
ofs << a << endl;
}
ifs.close();
ofs.close();
system("pause");
return 0;
}
#include <fstream>
using namespace std;
int main()
{
ifstream ifs;
ifs.open("yyp.cpp");
ofstream ofs;
ofs.open("hello1.txt");
char a[100];
while (!ifs.eof())
{
ifs.getline(a,100);
ofs << a << endl;
}
ifs.close();
ofs.close();
system("pause");
return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.