C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 08-14-2009, 12:58 AM   #1
Registered User
 
Join Date: May 2009
Location: Chennai, India
Posts: 17
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

Code:
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
-BalaC-
cbalu is offline   Reply With Quote
Old 08-14-2009, 01:08 AM   #2
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,923
It's called a bitfield.
Sebastiani is offline   Reply With Quote
Old 08-17-2009, 11:03 AM   #3
Making mistakes
 
Join Date: Dec 2008
Posts: 347
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.
__________________
Look at this: Community Project
And this: Ascent - Programmer needed
Brafil is offline   Reply With Quote
Reply

Tags
struct, structure

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Structure and Linked List User Input Question kevndale79 C Programming 16 10-05-2006 11:09 AM
structure ...solution plz???? hegdeshashi C Programming 4 07-24-2006 09:57 AM
Binary Search Trees Part III Prelude A Brief History of Cprogramming.com 16 10-02-2004 03:00 PM
Doubt -- Structures bmsar C Programming 0 12-25-2002 11:55 PM


All times are GMT -6. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22