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

Explain the use of 'auto' keyword

1120


What is abstract data structure in c?

1037


Why can arithmetic operations not be performed on void pointers?

1038


What is pass by value in c?

1067


what are the 10 different models of writing an addition program in C language?

1893


What is meant by inheritance?

1086


What is bubble sort technique in c?

973


What is the difference between NULL and NUL?

1290


What is the significance of c program algorithms?

1145


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

4283


Why doesnt that code work?

1171


What is page thrashing?

1081


Explain how can you determine the size of an allocated portion of memory?

1106


What does the error message "DGROUP exceeds 64K" mean?

1215


What are the different types of errors?

1136