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 output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }
what is the difference between normal variables and pointer variables..............
15 Answers HP, Infosys, Satyam, Vivekanand Education Society,
#include<stdio.h> main() { char s1[]="Ramco"; char s2[]="Systems"; s1=s2; printf("%s",s1); } what will happen if you executed this code?
Is main an identifier in c?
long int size a) 4 bytes b) 2 bytes c) compiler dependent d) 8 bytes
18 Answers Acropolis, HCL, Intel, TCS,
how to swap 4 number without using temporary number?
Explain high-order and low-order bytes.
What is the difference between pure virtual function and virtual function?
What is the difference b/w Structure & Union?
A stack can be implemented only using array?if not what is used?
program to find the magic square
Write a program to compute the similarity between two strings - The program should get the two strings as input - Then it will output one single number which is the percentage of similarity between the two strings