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 |
What is declaration and definition in c?
What is quick sort in c?
do you think its fraud or original company?
what is the difference between auto and static keywords
1 Answers cDot, College School Exams Tests, TCS,
Explain why can’t constant values be used to define an array’s initial size?
Why clrscr is used in c?
Which of these functions is safer to use : fgets(), gets()? Why?
swap 2 numbers without using third variable?
Write a program to interchange two variables without using the third variable?
17 Answers Accenture, College School Exams Tests, Infotech,
plz answer....A program that takes 3 variables e.g a,b,c in as seperate parameters and rotates the values stored so that value goes a to b, b to c and c to a .
Print all the palindrome numbers.If a number is not palindrome make it one by attaching the reverse to it. eg:123 output:123321 (or) 12321
how does the C compiler interpret the following two statements p=p+x; q=q+y; a. p=p+x; q=q+y b. p=p+xq=q+y c. p=p+xq; q=q+y d. p=p+x/q=q+y