C language Structure in Structure

www.laut‮.irut‬com
C language Structure in Structure

In the following example, we have a "student" structure.
we have another structure "address" to store the address details in it.

//student structure having address structure inside
struct student {
  char name[255];
  char id[20];
    
  //address of the student
  struct {
    char line1[255];
    char line2[255];
    char city[255];
    char state[100];
    char country[255];
    char pincode[20];
  } address;
};

Access the 'name' member of the 'student' structure

std.name

Access the city member in address structure

std.address.city
Created Time:2017-08-28 07:14:24  Author:lautturi