16,472
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
int main(void)
{
TCHAR *s = "①☆";
FILE *fd = NULL;
if ( (fd = _tfopen(_T("c:\\ok.txt"),_T("w"))) == NULL )
{
printf("open file failed\n");
return -1;
}
_fputts(s,fd);
if ( fd )
fclose(fd);
fd =NULL;
return 0;
}
try
{
char buf[] = "①☆";
CFile file(_T("E:\\11.txt"), CFile::modeCreate | CFile::modeWrite);
file.Write(buf, sizeof(buf));
file.Close();
}
catch(CFileException* e)
{
e->ReportError();
e->Delete();
}
TCHAR s[] = TEXT("①☆");
FILE* file;
_tfopen_s(&file, TEXT("d:\\1.txt"), TEXT("wt,ccs=unicode"));
_ftprintf(file, TEXT("%s\n"), s);
fclose(file);