简体   繁体   中英

Simple printf program doesn't work

This program doesn't work and I don't know why.

#include <stdio.h>

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

I am compiling in C99. Expected output is 0x1.4p+4

The а is CYRILLIC SMALL LETTER A (U+0430) , but you have to use LATIN SMALL LETTER A (U+0061) : a .

If you're using a compiler that is able to check format strings like Clang or GCC, then compile with (at least) -Wall which includes -Wformat ( GCC Warning documentation )

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

Its really wired. When I copypaste your code it turns into printf("%?", 20.0);

You should check your character encoding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM