typedef int arr[10]
I understand that the above statement defines a new name for int[10] so that
arr intArray;
is equivalent to
int intArray[10];
However, I am confused by the convention for doing this. It seems to me that
typedef int arr[10]
is confusing and a clear way to me is
typedef int[10] arr
i.e. I define the "int[10]" to be a new type called arr
However, the compiler does not accept this.
May I ask why ? Is it just a convention for C language ?
int arr[10]? :)intArrayin your example, to declare an array.typedefon the front and it means the variable name becomes the name of the type alias.