Lecture 13 Size of Structure in, array vs structure, array within structure , passing structure to function, Nested Structure , Union , nesting of unions Size of structure - Size of structure can be found out using sizeof() operator with structure variable name or tag name with keyword. sizeof(struct student); or sizeof(s1); sizeof(s2); Size of structure is different in different machines. So size of whole structure may not be equal to sum of size of its members. Array of structures When database of any element is used in huge amount, we prefer Array of structures. Example: suppose we want to maintain data base of 200 students, Array of structures is used. #include<stdio.h> #include<string.h> struct student { char name[30]; char branch[25]; int roll; } void main() { struct student s[200]; int i; s[i].roll=i+1; printf("\nEnter information of students:"); for(i=0;i<200;i++) { printf("\nEnter the roll no:%d\n",s[...
Comments
Post a Comment