Programming and Problem Solving Module2
Programming and Problem Solving Module2
printf ("\n Display the Details of the Employee1 using Structure Pointer");
printf(" Name: %s", ptr1->name);
printf(" Id: %d", ptr1->id);
printf(" Age: %d\n", ptr1->age);
printf(" Gender: %s\n", ptr1->gender);
printf(" City: %s\n", ptr1->city);
return 0;
}
PROGRAMMING & PROBLEM SOLVING (MODULE 2)
5. BIT FIELDS :
C has a built-in feature called a bit-field that allows us to access a single bit.
Example :
#include <stdio.h>
#include <string.h>
struct
{
unsigned int widthValidated;
unsigned int heightValidated;
} status1;
struct
{
unsigned int widthValidated : 1;
unsigned int heightValidated : 1;
} status2;
int main( )
{
printf( "Memory size occupied by status1 : %d", sizeof(status1));
printf( "Memory size occupied by status2 : %d", sizeof(status2));
return 0;
}