发布网友
共2个回答
热心网友
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string t;
ofstream fs("OUT.dat");
while(getline(cin,t))fs<<t<<endl;
return 0;
}追问差不多了。。。但还有个问题。。。我想输出结束后就退出程序。。。。需要加点什么代码
热心网友
#include<iostream>
#include<fstream>
using namespace std;
ofstream fout("out.txt"); //若想用二进制输出只需把 out.txt 改成 out.dat
int main()
{
char str[1000];
while(gets(str))
fout<<str<<endl;
return 0;
}追问还有个问题。。。我想输出结束后就退出程序。。。。需要加点什么代码呢?