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
Differentiate between full, complete & perfect binary trees.
What is the use of static variable in c?
What is 1d array in c?
What is string function c?
Explain the bubble sort algorithm.
Explain how can a program be made to print the line number where an error occurs?
A collection of data with a given structure for excepting storing and providing on demand data for multiple users a) linked list b) datastructer c) database d) preprocessor
How can you draw circles in C?
How can I determine whether a machines byte order is big-endian or little-endian?
What are file streams?
What is an arrays?
What is the use of clrscr?
What is the difference between arrays and pointers?
What is the difference between procedural and declarative language?
How to explain the final year project as a fresher please answer with sample project