I know how to use typedef in order to define a new type (label).
For instance, typedef unsigned char int8 means you can use "int8" to declare variables of type unsigned char.
However, I can't understand the meaning of the following statment:
typedef unsigned char array[10]
Does that mean array is of type unsigned char[10]?
In other part of code, this type was used as a function argument:
int fct_foo(array* arr)
Is there anyone who is familiar with this statement?
Does that mean array is of type
unsigned char[10]?
Replace "of" with "another name for the" and you have a 100% correct statement. A typedef introduces a new name for a type.
typedef unsigned char array[10];
declares array as another name for the type unsigned char[10], array of 10 unsigned char.
int fct_foo(array* arr)
says fct_foo is a function that takes a pointer to an array of 10 unsigned char as an argument and returns an int.
Without the typedef, that would be written as
int fct_foo(unsigned char (*arr)[10])
                        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