/*In the following program i have to find the size of structure cal without making use of sizeof Operator but is incomplete, so add minimum line of  code accomplish this*/

//note :-do not make use of sizeof


struct cal


 long double d;

 float f;

 char c;


void main()


 int i;/*add code to find size*/;

 printf("the size of cal is %d",i);


<< moderator edit: added [co[u][/u]de][/co[u][/u]de] tags >>

can anyone tell me the solution for this problem

12 Years
Discussion Span
Last Post by SpS

If you had an array of at least two of the objects, and you took the address of adjacent elements, cast each address to a char* , and found the difference between each address, you would have the size of one object.


Hi Dave....i was able to solve this problem the way you told by taking two objects...but i was trying to solve it through single object....i took two char pointers as you said and made it point to the individual members of the structure....i tried to find successive differences but got stuck with last element.....is there any way to solve it....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.