Structures
Nested Structure
Use a nested structure to store a student’s date of birth.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Use a nested structure to store a student’s date of birth.
#include <stdio.h>
struct Date {
int day, month, year;
};
struct Student {
char name[50];
struct Date dob;
};
int main() {
struct Student s = {"Alice", {15, 8, 2003}};
printf("%s was born on %d/%d/%d\n",
s.name, s.dob.day, s.dob.month, s.dob.year);
return 0;
}
Alice was born on 15/8/2003