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

What is call by reference in functions?

1418


Devise a program that inputs a 3 digit number n and finds out whether the number is prime or not. Find out its factors.

1116


What is the correct declaration of main?

1198


What is the meaning of typedef struct in c?

1054


A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler

1083


What is extern storage class in c?

986


Difference between Shallow copy and Deep copy?

2006


what are the different storage classes in c?

1171


main() { inta=10,b=20; a>=5?b=100:b=200; printf("%d ",b); }

1532


What is time complexity c?

981


formula to convert 2500mmh2o into m3/hr

976


What is a node in c?

967


What is %g in c?

1059


Explain what are run-time errors?

1070


What are the benefits of organizational structure?

1008