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
Explain heap and queue.
What are the data types present in c?
pgm to find number of words starting with capital letters in a file(additional memory usage not allowed)(if a word starting with capital also next letter in word is capital cann't be counted twice)
How do you determine a file’s attributes?
Why cant I open a file by its explicit path?
Is c language still used?
What are the key features in c programming language?
What does node * mean?
When should we use pointers in a c program?
please explain every phase in the "SDLC" in the dotnet.
a value that does not change during program execution a) variabe b) argument c) parameter d) none
Explain the difference between strcpy() and memcpy() function?
What is 1d array in c?
Compare interpreters and compilers.
What should malloc(0) do?