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
find out largest elemant of diagonalmatrix
How can you determine the size of an allocated portion of memory?
What is the difference between malloc() and calloc()?
When is a null pointer used?
What is the size of enum in c?
What are the uses of a pointer?
which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above
What is variables in c?
in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.
What is the difference between strcpy() and memcpy() function in c programming?
What does struct node * mean?
How can I insert or delete a line (or record) in the middle of a file?
What does static variable mean in c?
Write a program to identify if a given binary tree is balanced or not.
What is the difference between procedural and functional programming?