Computer Science, asked by DishaRajpal8611, 10 months ago

Write a c program to find size of structure without using sizeof operator

Answers

Answered by HarishAS
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