Structures
struct groups related fields. Use . for members and -> through a pointer.
Example
#include <stdio.h>
struct P { char name[10]; int age; };
int main(void) {
struct P p = {"Ada", 30};
struct P *q = &p;
printf("%s %d %d\n", p.name, p.age, q->age);
return 0;
}Result
Ada 30 30
Exercise
Member through pointer.
qage
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.