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
What is the difference between array_name and &array_name?
Explain the difference between structs and unions in c?
writ a program to compare using strcmp VIVA and viva with its output.
Explain what’s a signal? Explain what do I use signals for?
Is register a keyword in c?
What is the difference between typedef and #define?
Can you write the algorithm for Queue?
How many types of arrays are there in c?
What are the c keywords?
How can I find the modification date of a file?
Differentiate between the expression “++a” and “a++”?
How do you determine the length of a string value that was stored in a variable?
Which is the best website to learn c programming?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What are the standard predefined macros?