gpt4 book ai didi

c - unsigned char i 是否等同于 unsigned j?

转载 作者:太空狗 更新时间:2023-10-29 16:42:09 28 4
gpt4 key购买 nike

在下面的程序中,我使用了 unsigned 关键字。

#include <stdio.h>

int main()
{
unsigned char i = 'A';
unsigned j = 'B';
printf(" i = %c j = %c", i, j);
}

输出:

 i = A j = B

unsigned char i是否等同于unsigned j

最佳答案

Is unsigned char i equivalent to unsigned j?

否,当省略类型说明符且任何 signedunsignedshortlong使用说明符,假定为 int

这意味着下面的声明是等价的:

long a;
long int a;

unsigned short b;
unsigned short int b;

char 的符号性问题在于,当省略 signedunsigned 时,符号性取决于实现:

char x; // signedness depends on the implementation
unsigned char y; // definitely unsigned
signed char z; // definitely signed

关于c - unsigned char i 是否等同于 unsigned j?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39341531/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com