
Structures in C
? Structures in C
A structure in C (struct
) is a user-defined data type that allows grouping variables of different types under one name — like an object or record.
? Declaring a Structure
struct struct struct printf("%s is %d years old\n", person1.name, person1.age);
Use the arrow (->
) operator when accessing via a pointer:
struct #include struct () { struct struct struct struct struct struct typedef struct { char name[50]; int age;} Person;Person p1 = {"Bob", 30};
?? Notes
Structures are value types — assigned by value, not by reference.
Use pointers to avoid copying large structures.