C 中 _int8 数据类型的格式说明符

Mat*_*hew 1 c integer overflow

_int8 数据类型的格式说明符是什么?

我正在使用“%hd”,但它给我一个关于堆栈损坏的错误。谢谢 :)

这是代码片段:

signed _int8 answer;

printf("----Technology Quiz----\n\n");
printf("The IPad came out in which year?\n");
printf("Year: ");
scanf("%hd", &answer);
printf("\n\n");
printf("The answer you provided was: %hd\n\n", answer);
Run Code Online (Sandbox Code Playgroud)

hex*_*ist 5

man scanf:%hhd“……但下一个指针是指向有符号字符或无符号字符的指针”。An_int8相当于signed char您将要使用的任何系统中的a scanf

signed _int8 answer;
scanf("%hhd", &answer);
printf("You entered %d\n\n", answer);
Run Code Online (Sandbox Code Playgroud)

  • 在 scanf 中使用 `%hhd`,在 printf 中使用 `%d`,我刚刚验证它有效。 (2认同)