In C, an array of structures can be created just like any other array. Each element of the array is a structure of the same type.
For example, you can create an array of "student" structures like this:
struct student
{
char name[30];
int age;
float per;
}
Example :
struct student students[100];
//Array of Structure Objects #include<stdio.h> struct student { char *name; int age; float per; }; int main() { struct student o[2]; o[0].name="Ram Kumar"; o[0].age=25; o[0].per=65.25; o[1].name="Sam Kumar"; o[1].age=12; o[1].per=80; printf("\n------------------------------"); printf("\nName : %s",o[0].name); printf("\nAge : %d",o[0].age); printf("\nPercent : %f",o[0].per); printf("\n------------------------------"); printf("\nName : %s",o[1].name); printf("\nAge : %d",o[1].age); printf("\nPercent : %f",o[1].per); printf("\n------------------------------\n\n"); return 0; }To download raw file Click Here
------------------------------ Name : Ram Kumar Age : 25 Percent : 65.250000 ------------------------------ Name : Sam Kumar Age : 12 Percent : 80.000000 ------------------------------
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions