Definition of a two-dimensional array:
Data type array name [constant expression 1] [constant expression 2] = {...}
int a[2][3] ={
{4,5,6},
{7,8,0}//or {7} does not write after 8 and 9, the system will help you add 0{7,0,0} by default
};
OR:
int b[3][2] ={3,87,43,66,82,11,34};
OR:
int b[][2] ={3,87,43,66,82,11,34}; Horizontal can not write
Array of strings
char array name [number of strings] [maximum allowable value per string] ={....}
Char str[3][15] ={"ipad", "ipod", "iphone"};
A string array is essentially a two-dimensional array that accesses a string using the array name [first-dimensional subscript].
The length of each string cannot exceed the length of the second dimension-1.
For example:
Char str2[3][20] ={"Luoshuailuotingluomama", "ipod", "ipad"};
The second dimension is 20, 20-1 = 19, but the first string is more than 19.
Char str2[3][20] ={"luoshuailuotingluomamadddddddssssssss", "ipod", "ipad"}; will not error, but will be warned.
for (int i =0; i < 3; i++) {
printf ("The End of Result:%s\n", Str2[i]);
}
Consider a question:
Creates an array of strings, pairs of strings (English?) Sort from small to large
Char str[5][15] ={"ipad", "ipod", "iphone", "main", "Luoshuai"};
Char temp[] ={0};
for (int i =0; i < strlen (str); i++) {
for (Int J =0; J<strlen (str)-i-1;j++) {
if (strcmp (Str[j] > str[j+1]) > 0) {
Strcopy (Temp,str[j]);
Strcopy (str[j],str[j+1]);
Strcopy (str[j+1],temp);
}
}
}
for (Int J =0; J<strlen (str); j + +) {
printf ("The End of Result:%s\n", str[j]);
}
C Language Basics 5