Initializing Array of Structures


An array of structures can be assigned initial values just as any other array can. Each array element is a structure that must be assigned a corresponding set of initial values. Let us consider the example:
struct employee
{
            in emp_code;
            char emp_name [20];
            int dept code;
            double salary;
};
……………………..
…………………….
employee emp [3] = { 101, “ABC”, 5, 100.70,
                                     102, “DEF”, 6, 200.80,
                                     103, “EFG”, 7, 300.90

                                    }  ;

Previous                                                                                    Next


Powered by Blogger.