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’s a signal? Explain what do I use signals for?
In C language what is a 'dangling pointer'?
In c programming language, how many parameters can be passed to a function ?
Why main function is special give two reasons?
When would you use a pointer to a function?
Explain setjmp()?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f
Write a program to use switch statement.
What does sizeof function do?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
How can you call a function, given its name as a string?
How are portions of a program disabled in demo versions?
swap 2 numbers without using third variable?
Not all reserved words are written in lowercase. TRUE or FALSE?
What are the main characteristics of c language describe the structure of ac program?