In following program I used unsigned
keyword.
#include <stdio.h>
int main()
{
unsigned char i = 'A';
unsigned j = 'B';
printf(" i = %c j = %c", i, j);
}
Output:
i = A j = B
Is unsigned char i
equivalent to unsigned j
?
Is
unsigned char i
equivalent tounsigned j
?
No, when the type specifier is omitted and any of the signed
, unsigned
, short
or long
specifiers are used, int
is assumed.
This means that the following declarations are equivalent:
long a;
long int a;
unsigned short b;
unsigned short int b;
The issue with the signedness of char
is that when signed
or unsigned
is omitted, the signedness is up to the implementation:
char x; // signedness depends on the implementation
unsigned char y; // definitely unsigned
signed char z; // definitely signed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With