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 the importance of c in your views?
what is the difference between unix os and linux os
HOW CAN ADD OUR FUNCTION IN LIBRARY.
Hierarchy decides which operator a) is most important b) is used first c) is fastest d) operates on largest numbers
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output?
Do you know the difference between malloc() and calloc() function?
Write a c pgm for leap year
11 Answers College School Exams Tests, IBM, TCS,
What are the functions to open and close the file in c language?
biggest of two no's with out using if condition statement
What is d'n in c?
Find duplicates in a file containing 6 digit number (like uid) in O (n) time.
What is the hardest programming language?