小编leg*_*nar的帖子

无法使用fwrite将int写入文件

我正在尝试格式化我的键盘输出,以便显示时间:

        t = time(0);
        now = localtime(&t);


        if(now->tm_min != prevM && now->tm_hour != prevH)
        {
            prevM = now->tm_min;
            prevH = now->tm_hour;

            fwrite("[", 1, sizeof(WCHAR), keylog);
            fwrite(&prevH, 1, sizeof(int), keylog);
            fwrite("]", 1, sizeof(WCHAR), keylog);
            fwrite(" ", 1, sizeof(WCHAR), keylog);
            fflush(keylog);
        }
Run Code Online (Sandbox Code Playgroud)

但是在我的文件中写了"[DLE NUL]"而不是可读数字,其中DLENUL是问号.

如何编写可读数字?

c fwrite

2
推荐指数
1
解决办法
3941
查看次数

标签 统计

c ×1

fwrite ×1