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

Html, world wide web

world wide web

Tells the operators one can override; which operators , Q:  Tells the opera...

Q:  Tells the operators one can override; which operators should he override? A: Bottom line: don't puzzle your users. Remember the reason of operator overloading: to decreas

Fill an array of randomly generated integers, The task consists of two part...

The task consists of two parts which are both preferably implemented in one source file. Towards the end of this document you will find a code skeleton that you must assume. Start

Gross pay, Develop a C++ program that uses a while to determine the gross p...

Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by eac

Data structure and algorithm, implement two stacks in one array A[1...n] in...

implement two stacks in one array A[1...n] in such a way that neither stack overflows unless the total number of elements in both stacks together is n. For this you need to produce

Area, find area uder the curve y=f(x) between x=a and x=b   #incl...

find area uder the curve y=f(x) between x=a and x=b   #include float start_point, /* GLOBAL VARIABLES */ end_point, total_area; in

What is difference among macro and template?, A: In C++ there is a main dif...

A: In C++ there is a main difference among a template and a macro. Merely a macro is a string which the compiler replaces along with the value that was defined. For example #define

C, algo of stack using two queue

algo of stack using two queue

Develop a complex app, Project Description: I would like to be building ...

Project Description: I would like to be building regarding a complex mobile application build as we require the signing of an NDA. My firm in based in Montreal Canada and we are

Heating and thermodynamic, i want software to calculate heating or use ther...

i want software to calculate heating or use thermodynamic equation , pleas help me

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