struct ptr
{
int a;
char b;
int *p;
}abc;
what is d sizeof structure without using "sizeof" operator??
Answer Posted / vadivel t
Hi All,
The size of any data type is depends on the compiler
(including struct, union and enum). But the question does
not mean, "what is the size of the given structure".
It actually means,
Find the size of the structure without using sizeof()
operator.
The Answer, irrespective of compiler would be,
Output of the following code.
-First printf gives the size of the structure, wthout using
size of operator.
-U can cross check the ans using sizeof() operator in the
second printf().
#include<stdio.h>
struct name
{
int a;
char b;
int *p;
}abc;
main()
{
struct name *ptr, *ptr1;
ptr = &abc;
ptr1 = ptr + 1;
printf("WITHOUT USING sizeof() OPERATOR: %d \n",((char *)
ptr1 - (char *)ptr));
printf("USING sizeof() OPERATOR: %d \n", sizeof(abc));
getch();
}
| Is This Answer Correct ? | 13 Yes | 0 No |
Post New Answer View All Answers
What is the difference between variable declaration and variable definition in c?
Whats s or c mean?
What is the difference between %d and %i?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
What is the right type to use for boolean values in c?
What is the data segment that is followed by c?
What is the use of ?: Operator?
What is a buffer in c?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
What are c preprocessors?
What is masking?
What are the 4 data types?
diff between exptected result and requirement?
Is malloc memset faster than calloc?
write a sorting prgm to sort 50 nos and sum them and also remove all the occurrences of 15 and print it?