Homework Help Question & Answers
PLease explain output of these two programs: 1. #include typedef struct { char *name; int…
PLease explain output of these two programs:
1.
#include
typedef struct {
char *name;
int x, y;
int h, w;
} box;
typedef struct {
unsigned int baud : 5;
unsigned int div2 : 1;
unsigned int use_external_clock : 1;
} flags;
int main(int argc, char** argv){
printf(“The size of box is %d bytesn”, sizeof(box));
printf(“The size of flags is %d bytesn”, sizeof(flags));
return 0;
}
2.
#include
#include
/* define simple structure */
struct {
unsigned int widthValidated;
unsigned int heightValidated;
} status1;
/* define a structure with bit fields */
struct {
unsigned int widthValidated : 1;
unsigned int heightValidated : 1;
} status2;
int main( ) {
printf( “Memory size occupied by status1 : %dn”, sizeof(status1));
printf( “Memory size occupied by status2 : %dn”, sizeof(status2));
return 0;
}