1. Why do you have both a global array named student and a local array as well.
Code:
struct class
{
...
} student[2];
int main()
{
struct class student[2]={{111, "rao", 22.50}, {222,"gto", 22.5}};
Pick one or the other.
2. Given this:
Code:
struct class
{
int number;
char name[20];
float marks;
struct jow
{
int num;
char word[10];
}teach;
};
Instead of this:
Code:
struct class student[2]={{111, "rao", 22.50}, {222,"gto", 22.5}};
struct jow teach={10, "ann"};
If you wish to initialize a nested structure you can do it like this:
Code:
struct class student[2]={{111, "rao", 22.50, {5,"bob"}}, {222,"gto", 22.5, {10,"ann"} }};