typedef struct
{
int i:8;
char c:9;
float f:20;
}st_temp;
int getdata(st_temp *stptr)
{
stptr->i = 99;
return stptr->i;
}
main()
{
st_temp local;
int i;
local.c = 'v';
local.i = 9;
local.f = 23.65;
printf(" %d %c %f",local.i,local.c,local.f);
i = getdata(&local);
printf("\n %d",i);
getch();
}
why there there is an error during compiling the above
program?
Answer / vadivelt
1.Maximum no of bits to a bitfield variable, allocated by any
compiler is = sizeof(datatype of variable) * 8;
and minimum of 1 bit.
2.Almost all the compilers allocates 1 byte for character
datatype(not mandatory. ie., memory allocation purely
compiler dependent).
So the error found here is,
In the stucture given, For character variable 'c', you are
trying to allocate 9 bit of memory. But the variable can
hold maximum of 8 bits.
Hence error.
| Is This Answer Correct ? | 3 Yes | 1 No |
Which function in C can be used to append a string to another string?
Write a C program to fill a rectangle using window scrolling
What should malloc(0) do?
int i=~0; uint j=(uint)i; j++; printf(“%d”,j);
Which programming language is best for getting job 2020?
main() { printf("hello"); fork(); }
a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? a.infinite b.5 c.4 d.6
What does typeof return in c?
In C programming, what command or code can be used to determine if a number of odd or even?
find largest element in array w/o using sorting techniques.
What are the advantages of union?
difference between Low, Middle, High Level languages in c ?