C-int8_t 不会工作

标签 c

我在执行下面提到的代码时遇到问题。我在使用 int8_t 时遇到错误,但在使用 int16_t 时却没有。我在使用 int8_t 时遇到的错误是:

12 19 [Error] expected ')' before 'SCNd8'
16 19 [Error] expected ')' before 'SCNd8'

谁能帮我解决这个问题?

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


int main()
{
int8_t N,D,quotient,remainder;
 D=0;
    printf("enter the Numerator between 0-255: \n");
    scanf("%hhd" SCNd8 ,&N);
    printf("enter the Denominator between 1-255: \n");

    do{
        scanf("%hhd"SCNd8 ,&D);
        if (D==0)
           {
               printf("denominator cant be 0 \n");
               printf("enter the Denominator between 1-255: \n");
           }
    }while(D==0);

        quotient=N/D;
        remainder=N%D;
printf("The quotient is %"PRId8"\n",quotient);
printf("The remainder is %"PRId8"\n",remainder);

最佳答案

改变

scanf("%hhd" SCNd8 ,&N);

scanf("%" SCNd8 ,&N);

这是因为 SCNd8 通常被定义为

#define SCNd8 "hhd"

所以,你不需要自己添加hhd

关于C-int8_t 不会工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41775996/

相关文章:

c - OMAP3 上奇怪的 SD 卡是 omap_hsmmc 驱动程序吗?

c - 如何使用 C 线程从头到尾读取文件?

c - 如何将 char * 分配给字符数组?

c++ - 嵌入式编程中宏值之间的比较是否不好?

c++ - 给定这两个值的函数会产生第三个值?

c++ - 为什么 C++ 标准不弃用递增/递减运算符?

c - 长长C型分割线

c - 双字段的 calloc() 是否总是计算为 0.0?

c - 错误 LNK2019 : unresolved external symbol when using SendInput()

c - 使用 fgets() 和跳行从另一个 CSV 写入 CSV