int8 您所在的位置:网站首页 integer的方法 int8

int8

2023-04-13 04:47| 来源: 网络整理| 查看: 265

如果类型num是,该程序将起作用int.但是当改变它时int8_t,num将永远是0 scanf().

这是因为%din scanf?

#include #include void convert(int8_t, int8_t); int main(int argc, char const *argv[]) { int8_t num; int8_t b; printf("enter a number:\n"); while (1 == scanf("%d", &num)) { scanf("%d", &b); printf("%d %d\n", num, b); printf("Code: "); convert(num, b); putchar('\n'); printf("enter a integer (q to quit):\n"); } printf("done.\n"); getchar(); return 0; } void convert(int8_t n, int8_t base) { if (n >= base) convert(n / base, base); printf("%d", n % base); return; }

ameyCU.. 5

你传递错误的参数scanf,%d期望一个地址int.

您可以使用宏SCNd8来获取输入int8_t.标题.

scanf("%"SCNd8, &b);

而宏则PRId8打印其价值.

1> ameyCU..:

你传递错误的参数scanf,%d期望一个地址int.

您可以使用宏SCNd8来获取输入int8_t.标题.

scanf("%"SCNd8, &b);

而宏则PRId8打印其价值.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有