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

How was c created?

1003


Write a program to check palindrome number in c programming?

974


What is page thrashing?

1033


i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

1929


Which one to choose from 'initialization lists' or 'assignment', for the use in the constructor?

1031


What is the use of linkage in c language?

1018


Why is %d used in c?

969


What are the types of arrays in c?

1108


Which one would you prefer - a macro or a function?

1041


Explain which function in c can be used to append a string to another string?

1049


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1936


The difference between printf and fprintf is ?

1226


Why can’t constant values be used to define an array’s initial size?

1331


What was noalias and what ever happened to it?

995


will u please send me the placement papers to my mail???????????????????

1805