#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
void main()
{
ofstream outfile("C:\\Users\\PC\\Desktop\\oooo.txt", ios::out);
if (!outfile)
{
cerr << "open text.txt error" << endl;
exit(0);
}
char c[80];
cout << "enter a sentence:";
cin.getline(c, 30);
for (int i = 0; c[i] != 0; i++)
{
outfile.put(c[i]);
}
outfile.close();
cout << c << endl;
system("pause");
}
输入字符串到文件
最新推荐文章于 2023-01-05 11:30:28 发布