C-int8_t不会工作

时间:2017-01-21 05:18:05

标签: c

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

  

12 19 [错误]预期')'之前' SCNd8'
      16 19 [错误]预期')'之前' 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);

1 个答案:

答案 0 :(得分:0)

更改

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

scanf("%" SCNd8 ,&N);

这是因为SCNd8通常定义为

#define SCNd8 "hhd"

因此,您无需自己添加hhd