我给你写一个,看对吗?你要到 EXE 文件相同目录下找那个 f1.txt文件
#include<fstream>
#include<iostream>
using namespace std;
int main()
{
char a[20];
ofstream outfile("f1.txt");
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
//cout<<"enter / if you want to break:"<<endl;
char c;
while(cin.get(c))
{
if(c=='/')break;
outfile.put(c);
}
outfile.close();
return 0;
}