Please help me identify the parts of this typdef
and what each part does and how it can be used:
typedef struct my_struct
{
int a;
int b;
int c;
} struct_int, *p_s;
struct_int struct_array[5];
What I think they are, pleae correct if wrong:
typedef struct
is creating a new type.my_struct
is the name of this type but not used in the rest of the code. struct_int
is one instance of the type that we can use in the code. *p_s
is the pointer specifically to the one instance we created. struct_array
is an array of the instance we created. (This part confuses me since we already created an instance...) Also, when creating the array of structs, why do we use struct_int
instead of my_struct
?
struct my_struct
is a name of a type, my_struct
is a tag name and not a type.
typedef
does not create types in C, but creates alias names for existing types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With