how to find the size of the data type like int,float
without using the 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 ) ) );
}
It will work for any data type
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
How can you allocate arrays or structures bigger than 64K?
What are the types of assignment statements?
What is typedef example?
we need to calculating INCOME TAX for the person. The INCOME TAX is as follows:- First $10000/- of income : 4% tax Next $10000/- of income : 8% tax Next $10000/- of income : 11.5% tax above $10, 00,00/- : 15% tax What is the Solution of this Question ?
How can I convert a number to a string?
The __________ attribute is used to announce variables based on definitions of columns in a table?
Describe the header file and its usage in c programming?
What is identifiers in c with examples?
What are derived data types in c?
What are integer variable, floating-point variable and character variable?
What are the basic data types associated with c?
Difference between constant pointer and pointer to a constant.
Is it cc or c in a letter?
What is difference between structure and union in c programming?