Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Tell me can the size of an array be declared at runtime?

1083


What is variables in c?

1096


Explain setjmp()?

1116


What is the best way to comment out a section of code that contains comments?

1388


What is a void pointer? When is a void pointer used?

1106


What is #include conio h?

1053


What is s in c?

1095


Is c programming hard?

1080


What are the types of variables in c?

1079


What is property type c?

1135


What is a example of a variable?

1063


What do you know about the use of bit field?

1099


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

1128


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

2386


What are header files in c?

1120