Quote:
Originally Posted by bebop1111116
Are any of these lines valid code?
i;
Only if there is a variable 'i' declared in scope. But while valid, it's totally useless, the statement has no effect.
Quote:
short int s;
long int L;
long long LL;
The first two are valid. 'long int' is redundant, since 'long L' will declare the same type of variable. The actual sizes of the integers varies from platform to platform, but the order of sizes is always:
sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(void *) <= sizeof(long)
Note how sizeof(int) isn't guaranteed to be equal to siezof(void *) -- it can also be smaller. It's usually the same on 32-bit platforms, but assuming it's safe to cast pointer to int has caused many headaches on 64-bit systems, where pointers are suddenly twice as large!
If fixed sizes are needed for integers, like a guaranteed 32-bit type, use the types declared in stdint.h.
'long long' is a gcc extension for 64-bit integers on 32-bit platforms. Different compilers have different ways of doing this. Again, use the 64-bit type from stdint.h instead.