512 B
512 B
| tags | |
|---|---|
|
A struct is a custom, user-defined type, in constrast to the primitive types
(int, char, float etc). They are known as compound types.
Usage
Define the custom type:
struct Person {
int age;
float height;
}
Then to apply the type to a variable:
struct Person thomas
And define the sub-properties:
thomas.age = 37
thomas.height = 5.8
Alternatively do all together:
struct Person thomas = {
.age = 37,
.height = 5.8
}