You cannot do this in C.
But you said you were learning C ++. In C ++, you can use BOOST_BINARY up to C ++ 0x, which will allow user-defined literals .
Please note, however, that it has become very easy to convert hex to binary and vice versa.
For a given binary number, simply group the numbers in groups of four and find out that
0000 <-> 0 0001 <-> 1 0010 <-> 2 0011 <-> 3 0100 <-> 4 0101 <-> 5 0110 <-> 6 0111 <-> 7 1000 <-> 8 1001 <-> 9 1010 <-> A 1011 <-> B 1100 <-> C 1101 <-> D 1110 <-> E 1111 <-> F
After several attempts to make this translation, it will become very convenient for you in your head. (Of course, you could do the same with octal, but hex is even more compact than octal.)
In your specific example:
1000000000 -> 10 0000 0000 -> 0010 0000 0000 -> 0x200
jason
source share