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

Difference between exit() and _exit() function?

1146


Why does notstrcat(string, "!");Work?

1155


For what purpose null pointer used?

1086


What is the difference between abs() and fabs() functions?

1137


1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321

3731


Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?

1025


What is character constants?

1193


What is a macro, and explain how do you use it?

1087


simple program of graphics and their output display

2007


Explain what happens if you free a pointer twice?

1093


Can you add pointers together? Why would you?

1134


Is it cc or c in a letter?

1030


What is a string?

1127


why programs in c are running with out #include? some warnings are display in terminal but we execute the program we get answer why? eg: main() { printf("hello world "); }

1776


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

2246