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 4 types of organizational structures?
Why are all header files not declared in every c program?
about c language
Can include files be nested?
Write a code to determine the total number of stops an elevator would take to serve N number of people.
What is a nested loop?
Is c programming hard?
Why is python slower than c?
Write the test cases for checking a variable having value in range -10.0 to +10.0?
What does the message "automatic aggregate intialization is an ansi feature" mean?
Are pointers really faster than arrays?
What is 1d array in c?
a function gets called when the function name is followed by a a) semicolon (;) b) period(.) c) ! d) none of the above
What does. int *x[](); means ?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.