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
Explain the use of 'auto' keyword
What is abstract data structure in c?
Why can arithmetic operations not be performed on void pointers?
What is pass by value in c?
what are the 10 different models of writing an addition program in C language?
What is meant by inheritance?
What is bubble sort technique in c?
What is the difference between NULL and NUL?
What is the significance of c program algorithms?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Why doesnt that code work?
What is page thrashing?
Explain how can you determine the size of an allocated portion of memory?
What does the error message "DGROUP exceeds 64K" mean?
What are the different types of errors?