Illustrate bit fields with structures, C/C++ Programming

Assignment Help:

C language lets us do this in a structure definition by putting: bit length after the variable that is.

struct packed_struct {
unsigned int f1:1;
unsigned int f2:1;
unsigned int f3:1;
unsigned int f4:1;
unsigned int type:4;
unsigned int funny_int:9;
} pack;

Here the packed_struct contains 6 members: Four 1 bit flags f1..f3, a 4 bit type and a 9 bit funny_int.

C language automatically packs the above bit fields as compactly as possible provided that the maximum length of the field is equal or less than to the integer word length of the computer. If this isn't the case then some compilers may permit memory overlap for the fields whilst other would store the next field in the next word.

Access members as usual via:

pack.type = 7; 


Related Discussions:- Illustrate bit fields with structures

Want a scraping program created, Want a scraping program created Project...

Want a scraping program created Project Description: We need to hire a professional developer to scrape the site for information such as *product title *Product Price

Explain about the floating point constants in c language, Explain about the...

Explain about the Floating point Constants in c language? A floating point constant is the number that contains either a fraction or decimal part. If an exponent is present its

C program for function of copy one string in other string, C Program for FU...

C Program for FUNCTION OF COPY ONE STRING IN OTHER STRING #include stdio.h> #include conio.h> int copy(char a[],char b[]); void main() {           char a[100],b[

Minimum shelf, At a shop of marbles, packs of marbles are prepared. Packets...

At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers

#title.Thick line, #questio c++ program for drawing thick line

#questio c++ program for drawing thick line

Boolean functions and simple logic design, The digital signal is one which ...

The digital signal is one which only consists of two states i.e. logic '1'   (+5 volts) and logic '0' (0 volts). Various electronic blocks use logic and these form the basis of a m

Boardcoloring., Smugglers are becoming very smart day by day. Now they have...

Smugglers are becoming very smart day by day. Now they have developed a new technique of sending their messages from one smuggler to another. In their new technology, they are send

Explain the break statement, The break statement The break statement, w...

The break statement The break statement, which was already covered in the switch.. case, can also be used in the loops. When a loop statement is encountered in the loops the co

Develop a motion sensor in altera control, Develop a Motion sensor in Alter...

Develop a Motion sensor in Altera control Project Description: I want a project written in c using Altera eclipse development tool, that controls a motion sensor ( SRF05 ) fr

Need squid web proxy with ffmpeg to convert flv to h.264, Need Squid Web Pr...

Need Squid Web Proxy with ffmpeg to convert flv to h.264 Project Description: We need a squid proxy setup with the modification that will transcode FLV to h.264 in real-time,

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd