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
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
what is the syallabus of computer science students in group- 1?
Can we increase size of array in c?
What is a memory leak? How to avoid it?
Why we use break in c?
Can you explain what keyboard debouncing is, and where and why we us it? please give some examples
What is the difference between printf and scanf in c?
What does c mean?
What is the use of volatile?
Write a program to find the biggest number of three numbers in c?
why wipro wase
What is meant by 'bit masking'?
What is #define in c?
what is a NULL Pointer? Whether it is same as an uninitialized pointer?
Is c language still used?