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 |
#include<stdio.h> #include<conio.h> int main() { int a[4][4]={{5,7,5,9}, {4,6,3,1}, {2,9,0,6}}; int *p; int (*q)[4]; p=(int*)a; q=a; printf("\n%u%u",p,q); p++; q++; printf("\n%u%u",p,q); getch(); return 0; } what is the meaning of this program?
Are c and c++ the same?
Explain how can I convert a string to a number?
Write a program that accepts a string where multiple spaces are given in between the words. Print the string ignoring the multiple spaces. Example: Input: “ We Are Student “ Output: "We Are Student"
What is true about the following C Functions (a) Need not return any value (b) Should always return an integer (c) Should always return a float (d) Should always return more than one value
Why clrscr is used after variable declaration?
program to find which character is occured more times in a string and how many times it has occured? for example in the sentence "i love india" the output should be i & 3.
#include<stdio.h> int main() { int i=2; int j=++i + ++i + i++; printf("%d\n",i); printf("%d\n",j); }
sqrt(x+sqrt(x+sqrt(x+sqrt(x))))=2; Find the value of x?
What is substring in c?
How many bytes is a struct in c?
what about "char *(*(*a[])())();"