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 / 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 ) ) );
}

this will work for any data type

Is This Answer Correct ?    15 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the meaning of 2d in c?

1121


What are the types of bitwise operator?

1105


What is getch c?

1292


What is the maximum no. of arguments that can be given in a command line in C.?

1142


What are external variables in c?

1097


Do array subscripts always start with zero?

1287


What is the advantage of a random access file?

1194


Why is struct padding needed?

1081


how to print the character with maximum occurence and print that number of occurence too in a string given ?

2461


What are local variables c?

1007


Ow can I insert or delete a line (or record) in the middle of a file?

998


Which is more efficient, a switch statement or an if else chain?

1017


how to find anagram without using string functions using only loops in c programming

3187


How can I use a preprocessorif expression to ?

1056


What are keywords in c with examples?

1079