c++ 列印簡單log資訊,輸出內容到某一檔案中
阿新 • • 發佈:2019-01-09
#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; }