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
Give basis knowledge of web designing ...
What is sizeof int?
What is c token?
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)
Is a pointer a kind of array?
If errno contains a nonzero number, is there an error?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
How variables are declared in c?
How will you delete a node in DLL?
What are # preprocessor operator in c?
What is the newline escape sequence?
What are the different types of C instructions?
What is external variable in c?