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

Explain heap and queue.

1141


What are the data types present in c?

1235


pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)

2385


How do you determine a file’s attributes?

1132


Why cant I open a file by its explicit path?

1082


Is c language still used?

1045


What are the key features in c programming language?

1125


What does node * mean?

1302


When should we use pointers in a c program?

1193


please explain every phase in the "SDLC" in the dotnet.

2667


a value that does not change during program execution a) variabe b) argument c) parameter d) none

1289


Explain the difference between strcpy() and memcpy() function?

1063


What is 1d array in c?

1156


Compare interpreters and compilers.

1114


What should malloc(0) do?

1183