Nested structure is basically a structure within a structure. In your example, struct time is a member of struct date.
The logic for accessing member of a structure will remain the same. i.e.the way you access member day of struct date.
but here you will require to create structure variable for struct time in order to access its members.
If you want to access members of nested structure then it will look like,
dp->time.sec // dp is a ptr to a struct date
d.time.sec // d is structure variable of struct date
You can check following code,
#include<stdio.h>
struct date
{
struct time
{
int sec;
int min;
int hrs;
}time;
int day;
int month;
int year;
};
int main(void)
{
struct date d = {1,2,3,4,5,6}, *dp;
dp = &d;
printf(" sec=%d\n min=%d\n hrs=%d\n day=%d\n month=%d\n year=%d\n",dp->time.sec, dp->time.min, dp->time.hrs, dp->day, dp->month, dp->year);
}
Output :
sec=1
min=2
hrs=3
day=4
month=5
year=6
struct timeinstruct date? If so, you didn't name it, and what you have written doesn't compile.