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
Difference between exit() and _exit() function?
Why does notstrcat(string, "!");Work?
For what purpose null pointer used?
What is the difference between abs() and fabs() functions?
1234554321 1234 4321 123 321 12 21 1 1 12 21 123 321 1234 4321 1234554321
Explain what could possibly be the problem if a valid function name such as tolower() is being reported by the c compiler as undefined?
What is character constants?
What is a macro, and explain how do you use it?
simple program of graphics and their output display
Explain what happens if you free a pointer twice?
Can you add pointers together? Why would you?
Is it cc or c in a letter?
What is a string?
why programs in c are running with out #include
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.