Question:
Write a c program to find the size of structure without using sizeof operator?
Solution:
C program:
#include<stdio.h>
struct XYZ{
int x;
float y;
char z;
};
int main(){
int sz = (int) (((struct XYZ *)0) + 1);
printf("Size of Struct= %d",sz);
return 0;
}
Write a c program to find the size of structure without using sizeof operator?
Solution:
C program:
#include<stdio.h>
struct XYZ{
int x;
float y;
char z;
};
int main(){
int sz = (int) (((struct XYZ *)0) + 1);
printf("Size of Struct= %d",sz);
return 0;
}
Output:
Size of Struct= 12
0 comments:
Post a Comment