On the coercion of C language

programming encountered such an error

error: aggregate value used where an integer was expected
printf(“t1 = %d\n”,(unsigned char)t1;
error: aggregate value used where an integer was expected
printf(“t1 = %d\n”,(unsigned char)t1;

the reason is that
C language Type casting can only be converted between quantitative types. The structural types (including union and struct) are not Scalar types, so the casting cannot be performed.

quantitative types include arithmetic types and pointer types, and arithmetic types include integer types and floating point types.

can use union instead of data conversion

I generally use union instead of type conversion

union {
long l;
struct {
long a:10;
loing b: 10;

long c: 12} bits;
}

Read More: