#include<iostream>//.h
#include<fstream>
using namespace std;
class uer
{
public:
string name,pwd;
void save(string s)
{
ofstream out;
out.open("data.txt",ios::app);
out<<s<<endl;
cout<<s<<endl;
out.close();
}
void get()
{
ifstream get("data.txt",ios::in);
ofstream write("get.txt",ios::app);
char st[1000];
while(!write.eof())
{
get.getline(st,sizeof(st),'\n');
write<<st<<endl;
cout<<st<<endl;
}
write.close();
get.close();
}
};
#include<fstream>//.cpp
#include<iostream>
#include"uer.h"
using namespace std;
int main()
{
int n,m;
string s="123,deng";
int p=s.find(',',0);
string s1=s.substr(0,p);
string s2=s.substr(p+1,s.size());
uer u;
u.save(s1);
u.save(s2);
u.get();
return 0;
}
c++中文件的读写(从一个文件读到另一个文件)
最新推荐文章于 2025-01-04 09:22:35 发布