【发布时间】:2020-03-04 16:02:41
【问题描述】:
我使用 mac 的终端来编译 .c 文件。 终端指令作为流程: gcc output0.c; ./a.out;
代码:
#include <stdio.h>
int main(void) {
int n;
n = 1;
printf("fix 3: %c \n",n);
return 0;
}
结果为流: 修复 3:
问题:为什么不显示变量1。
MacOs 版本:10.13.4 高山
gcc信息: 配置: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM 版本 10.0.0 (clang-1000.10.44.4) 目标:x86_64-apple-darwin17.5.0 线程模型:posix 安装目录:/Library/Developer/CommandLineTools/usr/bin
【问题讨论】:
-
%c是 char 而非 int (%i) 的格式,0x01不是可打印字符,它是“标题开头”的控制字符 -
1 != '1'。这是了解原因的好机会!
标签: c