#include
#include
using namespace std;
int main()
{
int n;
ofstream fout("a:\\xxk1.dat");
while(1)
{
cin>>n;
if(n==-1)break;
fout<
}
include
#include
#include
using namespace std;
void main()
{
FILE *fp;
char ch,filename[10];
cin>>filename;
if((fp=fopen(filename,"w"))==NULL)
{cout<<"can't open the file."<
cin>>ch;
while(ch!='#')
{
fputc(ch,fp);putchar(ch);
ch=getchar();
}
cout<
}
我还是觉得你用#做终止输入的标志较好;
输入时把你想写进磁盘的名字输进去,譬如:xxk1.dat
#include
#include
using namespace std;
void main()
{
ofstream fout;
fout.open("a:\\xxk1.dat");
int n;
while(cin>>n&&n!=-1)
{
fout<
}
最还是把结果放到.txt文件 再改回后缀