regarding bit field structures

S

sushant

is it possible to scan a value to a member of a stucture which is of
bit field type??? if yes then how if no then why....
 
E

Eric Sosman

sushant said:
is it possible to scan a value to a member of a stucture which is of
bit field type??? if yes then how if no then why....

If by "scan the value" you mean "read it using one of
the scanf() family of functions," the answer is no: it is
not possible.

"Why" is a question with a few layers of answers, the
topmost being that bit fields are not addressable; it is
not possible to form a pointer to a bit field. To the
next layer's "Why," the answer is that `char' is the "atom"
in C's addressing model; since a bit field may be smaller
than a `char' or may straddle `char' boundaries, C's model
of addresses cannot accommodate it. Still further levels of
"Why" stray into the realm of computer architecture design,
which I'm not qualified to discuss -- and besides, it's a
topic for some other newsgroup.
 
R

Richard Bos

sushant said:
is it possible to scan a value to a member of a stucture which is of
bit field type??? if yes then how if no then why....

What do you mean by "scan"? If you mean read the value of and use it in
an expression, then yes, in the obvious way.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top