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
Between macros and functions,which is better to use and why?
List some of the dynamic data structures in C?
What are identifiers in c?
List a few unconditional control statement in c.
Why is extern used in c?
There seem to be a few missing operators ..
Does c have class?
What is difference between constant pointer and constant variable?
Does c have circular shift operators?
How do you redirect a standard stream?
What is the scope of global variable in c?
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
In c programming, explain how do you insert quote characters (? And ?) Into the output screen?
WHAT IS THE DEFINATION OF IN TECHNOLOGY AND OFF TECHNOLOGY ?
Tell me can the size of an array be declared at runtime?