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...

write a program for size of a data type without using
sizeof() operator?

Answer Posted / sunil

This has been solved in parts. I am not sure if there are
any better method merging it.

case 1. User passes a variable as the parameter.
eg: int n;
sizeof(n);

case 2. User passes a data type as the parameter.
eg: sizeof(int)


Solution
case 1: #define GetSize(x) (char*)(&x + 1) - (char*)&x

case 2:#define GetMySize(x) (char*)((x*)10 + 1) - (char*)10

Is This Answer Correct ?    15 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?

16583


What does typedef struct mean?

1038


What is the purpose of sprintf?

1060


What are the different types of control structures in programming?

1080


Is main a keyword in c?

1081


What is this infamous null pointer, anyway?

987


Explain what are the different file extensions involved when programming in c?

1049


Describe dynamic data structure in c programming language?

1036


Why do we need a structure?

977


Explain the use of bit fieild.

1096


What is the difference between text and binary i/o?

995


What are different types of pointers?

1010


What is quick sort in c?

1014


Who is the main contributor in designing the c language after dennis ritchie?

950


Why & is used in scanf in c?

1047