07-27-2023, 10:17 AM
`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 ?
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 ?