类型说明符 字节数 输入输出格式 取值范围
char 1B %c -128~127
unsigned char 1B %cu 0~127
short int 2B %hd -32768 ~ 32767(5位十进制数)
unsigned short int 2 %hu 0 ~ 65535(5位)
int 4 %d -2147483648 ~ 2147483647(10位)
unsigned int 4 %u 0 ~ 4294967295(10位)
long int 4 %ld -2147483648 ~ 2147483647(10位)
unsigned long int 4 %lu 0 ~ 4294967295(10位)
long long int 8 %lld或%I64d -9223372036854775808 ~ 9223372036854775807(20位)
unsigned long long int 8 %llu或%I64u 0 ~ 18446744073709551615(20位)

参考:
https://blog.csdn.net/qq_43177371/article/details/105703234

程序获取以上信息

#include <stdio.h>
#include <limits.h>

int main(int argc, char const *argv[])
{
    printf("Size of char: %lu bytes\n", sizeof(char));
    printf("Minimum value of signed char: %d\n", SCHAR_MIN);
    printf("Maximum value of signed char: %d\n", SCHAR_MAX);
    printf("Minimum value of unsigned char: %u\n", 0U);
    printf("Maximum value of unsigned char: %u\n", UCHAR_MAX);
    return 0;
}

//输出如下:
Size of char: 1 bytes
Minimum value of signed char: -128
Maximum value of signed char: 127
Minimum value of unsigned char: 0
Maximum value of unsigned char: 255

参考:讯飞星火大模型

posted on 2023-06-19 15:41  西伯尔  阅读(2)  评论(0编辑  收藏  举报