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
What is a built-in function in C?
What will be the outcome of the following conditional statement if the value of variable s is 10?
Why we use break in c?
Explain what standard functions are available to manipulate strings?
what is recursion in C
What is a protocol in c?
a single linked list consists of nodes a to z .print the nodes in reverse order from z to a using recursion
What are different types of operators?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
What is function pointer c?
Explain what will be the outcome of the following conditional statement if the value of variable s is 10?
how should functions be apportioned among source files?
What does it mean when the linker says that _end is undefined?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
What is the difference between a function and a method in c?