Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

binary value

Status
Not open for further replies.

1Zivi

Programmer
Joined
Apr 14, 2004
Messages
1
Location
BE
Hi!

Hope you can help my.

I´d like to put a binary value into a char or int.

ex: char x = 01000110;

for hexa, I can write 0x25 for exemple.

What must I write to put a binary value into a char?

Thanks

1Zivi
 
You can't write binary constants like that in ANSI-C

But then
x = 10; // decimal
x = 0xa; // hex
x = 012; // octal

All do the same thing, so any mythical
x = 0b1010; // binary
is no different from any of the above.




--
 
Strictly speaking, char constants are octal '\012' or hexa '\x0C' form...
No difference in C where char constants have int type...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top