-
Nested Structures
How do you create a nested structure? is it anything along the lines of:
struct info{
char name[21];
char address[31];
struct dob;
}INFO;
struct dob{
int day[3];
int month[3];
int year[5];
}DOB;
Then to write to the D.o.b struct something along the lines of:
scanf("%d", INFO.DOB.day);
Thanks for the help.
-
Yes, about like that
Code:
struct dob{
int day;
int month;
int year;
};
struct info{
char name[21];
char address[31];
struct dob;
}INFO;
scanf("%d", &INFO.dob.day);
-
Makes sense...
Thanks!
:D :D :D
-
Quote:
Originally posted by Salem
Yes, about like that
Code:
struct info{
char name[21];
char address[31];
struct dob;
}INFO;
scanf("%d", &INFO.dob.day);
Do you see anything odd about this line Salem? :D
I thought variables had to have a name in addition to a type? Hehe.
Now you COULD do it this way:
Code:
struct info {
char name[21];
char address[31];
struct {
int day;
int month;
int year;
} dob;
};
Quzah.
-
dob has to be defined first than info