Question
#include<stdio.h>
void main()
{
struct sample
{
unsigned a:1;
unsigned b:4;
}v={0,15};
unsigned *vptr=&v.b;
printf("%d %d",v.b,*vptr);
}
What will be output if you compile following c code ?
#include<stdio.h>
void main()
{
struct sample
{
unsigned a:1;
unsigned b:4;
}v={0,15};
unsigned *vptr=&v.b;
printf("%d %d",v.b,*vptr);
}
Answer: Option A
Was this answer helpful ?
Since we cannot take the address of a bit field variable i.e. Use of pointer to access the bit fields is prohibited. Also we cannot use 'scanf' function to read values into a bit field as it requires the address of a bit field variable. Also array of bit-fields are not permitted and a function cannot return a bit field.
Was this answer helpful ?
Submit Solution