Check a variable's type ?

 
char ch = 'a';


How to check ch is a char variable ? I mean how can we check the number of memory reserved for ch ?
sizeof(ch) gives you the size of ch in bytes
In this case it will always be 1 because sizeof(char) is always 1.
Thank you !
sizeof gives you the size of a type relative to sizeof(char). That doesn't mean a char is 1 byte long (although it usually is). The only thing the standard says is that char is at least 8 bits long.
That doesn't mean a char is 1 byte long (although it usually is).


I do believe that sizeof(char) is guaranteed to be 1 because it will always be one byte. However what C++ considers to be a byte may change (but will always be at least 8 bits).

So a char may be larger than 8 bits, but will not be larger than a byte.

This FAQ and the 4 or 5 after it cover it:
http://www.parashift.com/c++-faq-lite/intrinsic-types.html#faq-26.1
That's right.
Man, you all sure know where the valuable resources are.
But the number of bit depend on the machine ?

I have heard of ISCII instead of ASCII that requires more than 8-bit to represent all characters.

And 8-bit,I could imagine of mario and games in DOS.

But why need such 64-bit bytes ? Especially on 4GB RAM Computer ?
Topic archived. No new replies allowed.