You really should use %u for the result of sizeof().The problem with 256 * 8192 is that it's too big for a 16 bit integer and since it is powers of 2, the result left in the lower 16 bits is all 0s.
Do yourself a favor...
If your answers are 2 4 4 instead of 4 4 8 .... you need a new compiler.Code:#include <stdio.h> int main (void) { printf("%d\n", sizeof (int)); printf("%d\n", sizeof (long int)); printf("%d\n", sizeof (long long int)); return 0; }
The biggest number you're going to put into 2 bytes is 65,535
The biggest number for 4 bytes is 4,294,967,295
The bittest number for 8 bytes is 18,446,744,073,709,551,614
Can you see why a new compiler might be a good idea?



4Likes
LinkBack URL
About LinkBacks



