C/How to represent a bit in C? details below?
Expert: Zlatko - 10/20/2011
Questionyou can represent a byte with a type char and for a word(32 bits) with an int. Is there any way you can represent a single bit in C or in Assembly-with any data type? thank you
AnswerHello Heni
There is no datatype that is 1 bit long, but there is a way to split a short or int into regions called bit fields. Each bit field can be accessed by its own name. Look at
http://msdn.microsoft.com/en-us/library/yszfawxh%28v=vs.80%29.aspx
and
http://www.cs.cf.ac.uk/Dave/C/node13.html
for a description and example.
Best regards