Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我为极客从极客那里复制了这段代码。
#include<stdio.h> int main() { int c; printf("geeks for %ngeeks ", &c); printf("%d", c); getchar(); return 0; }
它应该从头到尾打印字符,%n然后是打印的字符数:
%n
但是当我执行它时,它会打印:
看来问题出在老版本的MingW没有__USE_MINGW_ANSI_STDIO默认设置,新版本不是这样,你可以做的是在你的程序中手动定义:
__USE_MINGW_ANSI_STDIO
# define __USE_MINGW_ANSI_STDIO #include <stdio.h> int main() { //... }
或者直接在编译命令上使用:
gcc main.c -o main.exe -D __USE_MINGW_ANSI_STDIO