regarding bit field structures

Discussion in 'C Programming' started by sushant, Jan 19, 2005.

  1. sushant

    sushant Guest

    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....
     
    sushant, Jan 19, 2005
    #1
    1. Advertising

  2. sushant

    Eric Sosman Guest

    sushant wrote:

    > 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.

    --
    Eric Sosman
    lid
     
    Eric Sosman, Jan 19, 2005
    #2
    1. Advertising

  3. sushant

    Richard Bos Guest

    "sushant" <> wrote:

    > 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
     
    Richard Bos, Jan 19, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alfonso Morra
    Replies:
    11
    Views:
    754
    Emmanuel Delahaye
    Sep 24, 2005
  2. Marcel Müller

    Bit field structures and C++

    Marcel Müller, Oct 20, 2008, in forum: C++
    Replies:
    4
    Views:
    2,280
    James Kanze
    Oct 21, 2008
  3. Thomas J. Gritzan

    Re: Serializing bit field structures

    Thomas J. Gritzan, Oct 21, 2008, in forum: C++
    Replies:
    1
    Views:
    449
    Thomas J. Gritzan
    Oct 22, 2008
  4. diamondback
    Replies:
    2
    Views:
    1,610
    Nick Keighley
    Oct 23, 2008
  5. James Kanze
    Replies:
    2
    Views:
    379
    Nick Keighley
    Oct 23, 2008
Loading...

Share This Page