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
A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM
Why can’t constant values be used to define an array’s initial size?
Is javascript based on c?
What is a keyword?
What do you mean by keywords in c?
Write a program to reverse a linked list in c.
What is the code in while loop that returns the output of given code?
Do you know the difference between exit() and _exit() function in c?
Why is c so powerful?
how to capitalise first letter of each word in a given string?
Why is C language being considered a middle level language?
Explain modulus operator. What are the restrictions of a modulus operator?
Where does the name "C" come from, anyway?
main() { int i = 10; printf(" %d %d %d ", ++i, i++, ++i); }
How can you restore a redirected standard stream?