#include <stdio.h>ide
int i = 0;
while (i < 20)
{
i++;
WriteLog("d:\\log.txt","aaaa中國人民");
}spa
/utf-8格式 //WriteLog("d:\\log.txt", "aaaa中國人民"); void WriteLog(char* file_path,string s) { s = s + "\r\n";//換行 int len; int slength = (int)s.length() + 1; len = MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, 0, 0); wchar_t* buf = new wchar_t[len]; MultiByteToWideChar(CP_ACP, 0, s.c_str(), slength, buf, len); FILE* fp = fopen(file_path, "a,ccs=UTF-8"); fwrite(buf, sizeof(wchar_t), wcslen(buf), fp); fclose(fp); delete[]buf; }