Structures
A struct groups variables of different types under one name. Access members with a dot, or with an arrow (->) when you have a pointer. typedef gives the type a shorter name.
Example
typedef struct {
char name[20];
int level;
} Student;
Student s = {"Ada", 3};
printf("%s level %d\n", s.name, s.level);
Student *p = &s;
p->level = 4;
printf("%d\n", s.level);Result
Ada level 3 4
Exercise
Access a member through a pointer.
plevel
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.