Initializing Array of Structure in C Programming
- Array elements are stored in consecutive memory Location.
- Like Array , Array of Structure can be initialized at compile time.
Way1 : Initializing After Declaring Structure :
struct Book{ char bname[20]; int pages; char author[20]; float price; }b1[3] = { {"Let us C",700,"YPK",300.00}, {"Wings of Fire",500,"APJ Abdul Kalam",350.00}, {"Complete Reference C",1200,"Herbt Schildt",450.00} };Way 2 : Initializing in Main
struct Book{ char bname[20]; int pages; char author[20]; float price; };
void main(){struct Book b1[3] = { {"Let us C",700,"YPK",300.00}, {"Wings of Fire",500,"APJ Abdul Kalam",350.00}, {"Complete Reference C",1200,"Herbt Schildt",450.00} };//- - - - //-Remaining Code//- - - - }

