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
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
What does typedef struct mean?
What is the purpose of sprintf?
What are the different types of control structures in programming?
Is main a keyword in c?
What is this infamous null pointer, anyway?
Explain what are the different file extensions involved when programming in c?
Describe dynamic data structure in c programming language?
Why do we need a structure?
Explain the use of bit fieild.
What is the difference between text and binary i/o?
What are different types of pointers?
What is quick sort in c?
Who is the main contributor in designing the c language after dennis ritchie?
Why & is used in scanf in c?