#include<iostream>
#include<sstream>
#include<fstream>
using namespace std;
int main()
{
int a = 1;
wstring aa = "abcdef";
//第一种方法 c++
ofstream fout("D:\\outtxt.txt");
fout<<a<<endl;
fout<<endl;
fout<<flush;
fout.close();
//第二种方法 c
FILE *fp = fopen("d:\\out.txt", "wt");
fprintf(fp, "%d\t", a);
fprintf(fp, "\n");
fprintf(fp, "%s", aa.c_str());
fclose(fp);
system("pause");
return 0;
}
本文介绍了一种使用C++进行文件输出的方法,包括利用ofstream和FILE指针通过fprintf的方式,并展示了具体的代码实现。

被折叠的 条评论
为什么被折叠?



