typedef with Array
typedef can also be used with an array to increase their count.
Example:
typedef int arr[20]
Here, arr is an alias for an array of 20 integer elements.
// it's same as Arr[20], two-Arr[20][23]; arr Arr, two-Arr[23];
Example 3: Using typedef to define an alias for Array.
C
// C program to implement typedef with array #include <stdio.h> typedef int Arr[4]; // Driver code int main() { Arr temp = { 10, 20, 30, 40 }; printf ( "typedef using an array\n" ); for ( int i = 0; i < 4; i++) { printf ( "%d " , temp[i]); } return 0; } |
typedef using an array 10 20 30 40
C typedef
The typedef is a keyword that is used to provide existing data types with a new name. The C typedef keyword is used to redefine the name of already existing data types.
When names of datatypes become difficult to use in programs, typedef is used with user-defined datatypes, which behave similarly to defining an alias for commands.