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

What is the difference between array_name and &array_name?

1352


Explain the difference between structs and unions in c?

1068


writ a program to compare using strcmp VIVA and viva with its output.

2083


Explain what’s a signal? Explain what do I use signals for?

1252


Is register a keyword in c?

1088


What is the difference between typedef and #define?

1113


Can you write the algorithm for Queue?

2175


How many types of arrays are there in c?

1083


What are the c keywords?

1256


How can I find the modification date of a file?

1337


Differentiate between the expression “++a” and “a++”?

1309


How do you determine the length of a string value that was stored in a variable?

1170


Which is the best website to learn c programming?

1135


What does the message "automatic aggregate intialization is an ansi feature" mean?

1242


What are the standard predefined macros?

1204