write a program for size of a data type without using
sizeof() operator?
Answer Posted / core_coder
#include <stdio.h>
struct node {
int x;
int y;
};
unsigned int find_size ( void* p1, void* p2 )
{
return ( (char*)p2 - (char*)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 ? | 1 Yes | 1 No |
Post New Answer View All Answers
Explain goto?
write a progrmm in c language take user interface generate table using for loop?
how to find anagram without using string functions using only loops in c programming
what value is returned to operating system after program execution?
Explain Function Pointer?
Where static variables are stored in c?
What is a #include preprocessor?
What are header files and explain what are its uses in c programming?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
How do I swap bytes?
largest Of three Number using without if condition?
Is c procedural or object oriented?
What does c mean in basketball?
Why doesnt the call scanf work?
What library is sizeof in c?