Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

struct ptr
{
int a;
char b;
int *p;
}abc;
what is d sizeof structure without using "sizeof" operator??

Answer Posted / vadivel t

Hi All,
The size of any data type is depends on the compiler
(including struct, union and enum). But the question does
not mean, "what is the size of the given structure".

It actually means,
Find the size of the structure without using sizeof()
operator.

The Answer, irrespective of compiler would be,

Output of the following code.

-First printf gives the size of the structure, wthout using
size of operator.

-U can cross check the ans using sizeof() operator in the
second printf().

#include<stdio.h>
struct name
{
int a;
char b;
int *p;
}abc;

main()
{
struct name *ptr, *ptr1;
ptr = &abc;
ptr1 = ptr + 1;
printf("WITHOUT USING sizeof() OPERATOR: %d \n",((char *)
ptr1 - (char *)ptr));
printf("USING sizeof() OPERATOR: %d \n", sizeof(abc));
getch();
}

Is This Answer Correct ?    13 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give basis knowledge of web designing ...

1981


What is sizeof int?

1049


What is c token?

1012


write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);

2295


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

2045


Is a pointer a kind of array?

1115


If errno contains a nonzero number, is there an error?

1291


please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code

2131


the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?

946


How variables are declared in c?

993


How will you delete a node in DLL?

1220


What are # preprocessor operator in c?

1044


What is the newline escape sequence?

1020


What are the different types of C instructions?

1245


What is external variable in c?

1010