+ 9
The schedule shows the sizeof int as 2 bytes while it should be 4 ....
correction
8 Respuestas
+ 8
char is guaranteed 1 byte. short, long, and long long are guaranteed at least 2, 4, 8 bytes. int is guaranteed at least 2 bytes but is usually implemented as 4 bytes.
Use int8_t, int16_t, int32_t and int64_t if you need guaranteed width.
Correction: apparently char isn't guaranteed either.
Edit: I am finding conflicting information about wether or not char is guaranteed as 1 byte so if anyone has an answer that'd be great. However, it doesn't matter because you won't find an implementation with anything else anyway.
+ 6
deae Jamie , dear Vlad, I thank both of you for your detailed answers and support, İt is really kind of you
+ 4
yes, exactly , C++ here in SL
+ 3
@Ankit there are different compilers and each compiler works differently. some goes from left to right and while other goes from right to left . so to see that just run the code. pre is earlier there performing operation. post after the operation . hope you get the result
+ 2
I see , is it the same for the other types?
thank you so much
+ 2
@Vlad Serbu:
char is definitely 1 byte
Unicode uses 2 bytes (wchar) to circumvent the ASCII limits (256 unsigned: 0-255). When working with a raw file/buffer, it doesn't matter unless you need to interpret the data.
@OP:
int is a very generic type that assumes the size the compiler gives it. This was to help C be portable back in the day. SL are using a virtual machine and compiler AFAIK. Use the fixed-width types as suggested. The reason for SL's decision is likely reducing memory use.
+ 2
on different compilers the value of int is different. but mostly it is 4 bytes on most of the platform
+ 1
Well Martin's test clarifies it all. Perhaps an error in OP's code? Unless changes made during an update (unlikely). OP, just try running your code again. I also tried and get 4 bytes for int.