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
What is a good data structure to use for storing lines of text?
What are qualifiers in c?
What is integer constants?
Why is c still so popular?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is variable and explain rules to declare variable in c?
What is scanf_s in c?
How to implement a packet in C
Does c have circular shift operators?
Explain what are the different data types in c?
Explain what are binary trees?
what will be the output for the following main() { printf("hi" "hello"); }
What is the usage of the pointer in c?
What is the use of c language in real life?
Why is structure important for a child?