Write a c program to find size of structure without using sizeof operator
Answers
Answered by
1
Answer:
#include<stdio.h>
struct student{
int roll;
char name[100];
float marks;
};
int main(){
struct student *pt = 0;
pt++;
printf("Size of the structure student: %d",pt);
return 0;
}
Explanation:
i) First we create a pointer.
ii) Now the pointer will assign some ID or memory address .
iii) It will start assigning from 0.
iv) The pt++ will increment to the starting address of next structure variable which is equal to the size of the structure.
Similar questions
Biology,
5 months ago
Computer Science,
5 months ago
Math,
11 months ago
Math,
1 year ago
Social Sciences,
1 year ago