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
Tell me can the size of an array be declared at runtime?
What is variables in c?
Explain setjmp()?
What is the best way to comment out a section of code that contains comments?
What is a void pointer? When is a void pointer used?
What is #include conio h?
What is s in c?
Is c programming hard?
What are the types of variables in c?
What is property type c?
What is a example of a variable?
What do you know about the use of bit field?
a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler
i have to apply for rbi before that i need to know the the syllabus for the entrance questions. whethet it may be aps or techinical
What are header files in c?