#include <stdio.h>
int main(){
ssize_t a= -1;
size_t b = (unsigned)a;
return 0;
}
a is 8 bytes all set to 1, however b becomes a 4 byte number when casted to unsigned without doing a proper (unsigned size_t), why is that? why doesn't it turn into an 8 byte unsigned variable?
unsigned is short for writing unsigned int, so unsigned and unsigned int are the same type.
unsigned size_t does not exist; size_t is already unsigned.
why doesn't it turn into an 8 byte unsigned variable?
Because ints are commonly 32 bit or 4 bytes.
If you want fixed width integers you can use stdint.h which defines uint32_t, int32_t etc.
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