#include<iostream>
#include<fstream>
using namespace std;
int Append(char *fileName)
{
char name[30],ch;int number,score;
ofstream outstuf(fileName,ios::app);
if(!fileName)
{
cerr<<"File could not be open."<<endl;
return 0;
}
cout<<"would you wanna append record to"<<fileName<<"?\n((Y/N))";
cin>>ch;
while(ch=='Y'||ch=='y')
{
cout<<"Input the number ,name,score:"<<endl;
cin>>number>>name>>score;
outstuf<<number<<' '<<name<<' '<<score;
cout<<"?(y/n)\n";cin>>ch;
if(ch=='N'||ch=='n') cout<<"File closed.\n ";
}outstuf.close();
return 1;
}
int main()
{
Append("F:\\students.txt");
}
C++文件输入输出处理(3)--增加文件内容
猜你喜欢
转载自blog.csdn.net/weixin_44001521/article/details/103972982
今日推荐
周排行