a190150302 发表于 2022-2-21 13:37:24

刚接触程序 找了半天没找到问题在哪里

//Chapter1/test5.c
#include <stdio.h>
int main(void)
{
        printf("int = %d\n", sizeof(int));
        printf("short int = %d\n", sizeof(short));
        printf("long int = %d\n", sizeof(long));
        printf ("long long int = %d\n", sizeof(long long));
        printf("char = %d\n", sizeof(char));
        printf("_Bool = %d\n", sizeof(_Bool));
        printf("float = %d\n", sizeof(float));
        printf("double = %d\n", sizeof(double));
        printf("long double = %d\n", sizeof(long double));
       
        return 0;
}

10        32        E:\360data\重要数据\桌面\1\test5.cpp        '_Bool' was not declared in this scope

isdkz 发表于 2022-2-21 13:45:42

加上 #include <stdbool.h>
#include <stdio.h>
#include <stdbool.h>      # 加上这行才能使用_Bool
int main(void)
{
      printf("int = %d\n", sizeof(int));
      printf("short int = %d\n", sizeof(short));
      printf("long int = %d\n", sizeof(long));
      printf ("long long int = %d\n", sizeof(long long));
      printf("char = %d\n", sizeof(char));
      printf("_Bool = %d\n", sizeof(_Bool));
      printf("float = %d\n", sizeof(float));
      printf("double = %d\n", sizeof(double));
      printf("long double = %d\n", sizeof(long double));
      
      return 0;
}
页: [1]
查看完整版本: 刚接触程序 找了半天没找到问题在哪里