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
write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays
What is a wrapper function in c?
What functions are used for dynamic memory allocation in c language?
Explain what is page thrashing?
What is structure padding and packing in c?
Do you know null pointer?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.
What is formal argument?
Disadvantages of C language.
How are pointers declared in c?
how many errors in c explain deply
What is c language in simple words?
Can a void pointer point to a function?
How can I generate floating-point random numbers?