struct ptr
{
int a;
char b;
int *p;
}abc;
what is d sizeof structure without using "sizeof" operator??
Answer Posted / pradeep
In Linux, its 12 bytes.
int a ------- 4 bytes
char b ------- 1 byte.
but as the next element is integer, it wont fit in the
remaining 3 bytes left after the "char b" occupies the first byte of the 4 byte chunk. so these 3 bytes wont be used for storing "int *p". these will be padded. next 4 bytes will be used for storing *p.
to prove it.
int size;
size = (&(abc.p) + sizeof(abc.p)) - &abc.a ;
printf("size = %d",size);
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
What is the use of sizeof () in c?
How to write a multi-statement macro?
Explain the difference between getch() and getche() in c?
What are qualifiers in c?
What are the application of c?
Does c have function or method?
cin.ignore(80, _ _);This statement a) ignores all input b) ignores the first 80 characters in the input c) ignores all input till end-of-line d) iteration
Can the sizeof operator be used to tell the size of an array passed to a function?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
Disadvantages of C language.
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What is putchar() function?
Which is best linux os?
how to introdu5ce my self in serco