Skip to main content
To Get All Information of Sarkari Jobs | Results | Admit Card | And courses ,Internships then CLICK HERE

More On Structure Of C Language

 
1- Array Of Structure
  • The way we have "array of int's","array of float","array of char" similarly we have "array of structure".
  • Array of structure is nothing but finite number of homogeneous structure variable,belonging to a structure.
  • Contiguous memory is allocated for array of structure.
  • We use array of structure when there is a need of large number of structure variable of same type.
Example:
#include<stdio.h>
#include<conio.h>
main()
{ struct emp
      { char name[15];
          int age;
           float ht;
       };
     struct emp e[5];
         int i=0;
for(i=0;i<5;i++)
{printf("Enter name,age&height"):
scanf("%s %d %f ",&e[i].name,&e[i].age,&e[i].ht);
for(i=0;i<5;i++)
printf("\n Name=%s,Age=%d,Height=%f",e[i].name,e[i].age,e[i].ht);
getch();
}
Output:
Enter name,age&height Sudarshan
21
5.2
Name= Sudarshan,Age=21,Height=5.2

 2- Copying Structure Variable

The way we can assign the value of one integer variable into another integer type variable,value of one float variable into another float type variable,similarly we can assign the value of one structure variable into another structure variable of same type.

Comments


Download The Book "Let Us C" By Yashavant P.Kanetkar,Click The Below Button

-->Email Subscription

Enter Your Email Address:-

Delivered by FeedBurner

Copyright © 2020 TechProgramiz|All Right Reserved|Made By-: Sudarshan Pandey