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 are the advantages of union?
What is the difference between volatile and const volatile?
how many errors in c explain deply
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
Is it possible to use curly brackets ({}) to enclose single line code in c program?
What is static and auto variables in c?
What is a lvalue
Is c procedural or functional?
What is the use of a ‘ ’ character?
the process of defining something in terms of itself is called (or) in C it is possible for the functions to call themselves. A function called a) nested function b) void function c) recursive function d) indifinite function
Why is c fast?
Why c is faster than c++?
What is the advantage of an array over individual variables?
What is the difference between exit() and _exit() function in c?
What is file in c language?