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 / govind279

#include<stdio.h>
int main()
{
int n;
int x,*p,*p1;/* here u can change the type */
p=&x;
p1=(p+1);

printf("size of x is : %d\n",n=(char *)(p1)-(char *)p);
}
Note:without type cast, it always gives 1.
i.e 1 int(4 chars), 1 float(4 chars),1 double(8
chars)etc...coz p+1 points to the next new location of same
type.

Is This Answer Correct ?    40 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

2072


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

1320


Is javascript based on c?

993


What is a keyword?

1119


What do you mean by keywords in c?

1079


Write a program to reverse a linked list in c.

1060


What is the code in while loop that returns the output of given code?

1889


Do you know the difference between exit() and _exit() function in c?

1012


Why is c so powerful?

1061


how to capitalise first letter of each word in a given string?

1863


Why is C language being considered a middle level language?

1040


Explain modulus operator. What are the restrictions of a modulus operator?

967


Where does the name "C" come from, anyway?

1074


main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }

1087


How can you restore a redirected standard stream?

1051