Home>Article>Backend Development> How to define string array in C language
You can define a string array in the following two ways:
Method 1: By defining a two-dimensional array of type char
Each string in the array can be obtained through the row index of the two-dimensional array. The size of the column limits the maximum number of characters that each string can contain. Therefore, when using this definition method, the column The size of must not be less than the maximum length of all strings in the array.
The definition code is as follows:
When fetching each string in the array, just index the row directly.
Method 2: By defining an array of pointers to char type to achieve
Each element in the array is a pointer, through which the array can be obtained of each string.
The definition code is as follows:
Recommended tutorial:C language tutorial
The above is the detailed content of How to define string array in C language. For more information, please follow other related articles on the PHP Chinese website!