简单的printf程序不起作用

时间:2015-03-10 10:09:03

标签: c printf

这个程序不起作用,我不知道为什么。

#include <stdio.h>

int main()
{
    printf("%а", 20.0);
}

我在C99编译。预期输出为0x1.4p + 4

2 个答案:

答案 0 :(得分:8)

аCYRILLIC SMALL LETTER A (U+0430),但您必须使用LATIN SMALL LETTER A (U+0061)a

如果您正在使用能够检查格式字符串(如Clang或GCC)的编译器,则使用({至少)-Wall进行编译,其中包括-WformatGCC Warning documentation

5 : warning: unknown conversion type character 0xffffffd0 in format [-Wformat]
5 : warning: too many arguments for format [-Wformat-extra-args]

答案 1 :(得分:0)

真的有线。当我对你的代码进行copypaste时会变成printf("%?", 20.0);

您应该检查字符编码。