I know there is a way to represent binary, octal and hex values in C, but how do you do it?

Like, say, if i wanted to specify a hex number i would do,

unsigned char i = 0xFF; or
unsigned char i = 0x32;

What if i wanted to specify the above in binary or octal?

In octal, it would be
unsigned char foo = 032; // a leading zero.

You can't specify binary constants in standard C, though some compilers designed for small embedded processors do as an extension.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.