小编Tim*_*Tim的帖子

ANSI C(ISO C90):scanf可以读取/接受unsigned char吗?

简单的问题:scanf可以读取/接受"小整数"到ANSI C中的unsigned char吗?

示例代码un_char.c:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    unsigned char character;

    scanf("%hhu", &character);

    return EXIT_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)

编译为:

$ gcc -Wall -ansi -pedantic -o un_char un_char.c
un_char.c: In function ‘main’:
un_char.c:8: warning: ISO C90 does not support the ‘hh’ gnu_scanf length modifier
Run Code Online (Sandbox Code Playgroud)

hhISO C90不支持.那么在这种情况下可以使用什么scanf转换?

c gcc scanf c89

15
推荐指数
2
解决办法
5713
查看次数

标签 统计

c ×1

c89 ×1

gcc ×1

scanf ×1