write a program for size of a data type without using
sizeof() operator?
Answer Posted / abdur rab
#include <stdio.h>
struct node {
int x;
int y;
};
unsigned int find_size ( void* p1, void* p2 )
{
return ( p2 - p1 );
}
int main ( int argc, char* argv [] )
{
struct node data_node;
int x = 0;
printf ( "\n The size :%d",
find_size ( (void*) &data_node,
(void*) ( &data_node +
1 ) ) );
printf ( "\n The size :%d", find_size ( (void*) &x,
(void*) ( &x + 1 ) ) );
}
this will work for any data type
| Is This Answer Correct ? | 15 Yes | 8 No |
Post New Answer View All Answers
Describe the header file and its usage in c programming?
What does s c mean in text?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
What is the difference between struct and typedef struct in c?
List the variables are used for writing doubly linked list program.
What do you mean by a local block?
Why use int main instead of void main?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
Difference between goto, long jmp() and setjmp()?
why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above
how to make a scientific calculater ?
What is I ++ in c programming?
Once I have used freopen, how can I get the original stdout (or stdin) back?
What is the value of h?
What is scanf () in c?