Thread: Basic doubt in C structure

  1. #1
    VIM addict
    Join Date
    May 2009
    Chennai, India

    Basic doubt in C structure

    Hi all,

    I was navigating inside linux kernel code and inside that one i have seen few structures which are very strange (for me). The structure is of the following form

    struct dummy {
         int a:1;
         unsigned long b:5;
    In the above structure does anyone explain me what is the number after the : will do.

    Thanks in advance

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Waterloo, Texas
    It's called a bitfield.

  3. #3
    Making mistakes
    Join Date
    Dec 2008
    a is a bitfield (like an int or char, but with one bit). b too, but with five bits. "a = 2" will probably give 0, since the upper bits are chopped off.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  2. structure ...solution plz????
    By hegdeshashi in forum C Programming
    Replies: 4
    Last Post: 07-24-2006, 09:57 AM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Doubt -- Structures
    By bmsar in forum C Programming
    Replies: 0
    Last Post: 12-25-2002, 11:55 PM

Tags for this Thread