1. the array flag is []:
# Include <stdio. h> int main (void) {int Nums [3]; Nums [0] = 11; Nums [1] = 22; Nums [2] = 33; printf ("% d, % d, % d", Nums [0], Nums [1], Nums [2]); getchar (); Return 0 ;}
2. array size and dimension:
# Include <stdio. h> int main (void) {int Nums [10]; printf ("the array size is % d \ n", sizeof (Nums); printf ("the array dimension is: % d \ n ", sizeof (Nums)/sizeof (Nums [0]); getchar (); Return 0 ;}
3. traverse the array:
# Include <stdio. h> int main (void) {int Nums [10]; int I; for (I = 0; I
For the string array, we can also think like this...
# Include <stdio. h> int main (void) {char CS [] = "abcdefg"; int I; for (I = 0; CS [I]; I ++) {/* When Cs [I] is false, the empty character */printf ("% C \ n", CS [I]) is reached;} getchar (); return 0 ;}
4. For a one-dimensional array, the dimension can be automatically recognized without being specified:
# Include <stdio. h> int main (void) {double Ds [] = {1.1, 2.2, 3.3, 4.4}; int COUNT = sizeof ds/sizeof DS [0]; int I; for (I = 0; I
4. Arrays with no dimension specified are often used as strings:
# Include <stdio. h> int main (void) {char str1 [] = "Builder";/* initialize */Char str2 [8] = {'B ', 'U', 'I', 'l', 'D', 'E', 'E', 'R', '\ 0'}; unsigned I; for (I = 0; I
5. Two-dimensional array:
# Include <stdio. h> int main (void) {int Nums [3] [4] ={{,}, {, 22 }}; printf ("% d, % d, % d \ n", Nums [0] [2], Nums [1] [2], Nums [2] [2]); getchar (); Return 0 ;}
5. The first dimension can only be omitted:
# Include <stdio. h> int main (void) {int Nums [] [4] ={{,}, {, 22 }}; printf ("% d, % d, % d \ n", Nums [0] [2], Nums [1] [2], Nums [2] [2]); getchar (); Return 0 ;}
6. Multi-dimensional array:
# Include <stdio. h> int main (void) {int Nums [2] [3] [4] ={{ 111,112,113,114 },{ 121,122,123,124 },{ 131,132,133,134 },{ 211,212,213,214 }, {221,222,223,224 },{ 231,232,233,234 }}; printf ("% d, % d, % d \ n", Nums [0] [0] [0], nums [1] [1] [1], Nums [1] [2] [2]); getchar (); Return 0 ;}
7. Multi-dimensional arrays can also be omitted only from the first dimension:
# Include <stdio. h> int main (void) {int Nums [] [3] [4] ={{ 111,112,113,114 },{ 121,122,123,124 },{ 131,132,133,134 },{ 211,212,213,214 }, {221,222,223,224 },{ 231,232,233,234 }}; printf ("% d, % d, % d \ n", Nums [0] [0] [0], nums [1] [1] [1], Nums [1] [2] [2]); getchar (); Return 0 ;}
8. String Array:
# Include <stdio. h> int main (void) {char CSS [] [10] = {"AAA", "BBB", "ccccccc"}; size_t I; for (I = 0; I
9. Local array variables that are not initialized include a bunch of junk values:
# Include <stdio. h> int NS1 [10];/* This will be initialized as null */INT main (void) {int NS2./* this will not be initialized */int I; for (I = 0; I
10. It is easy to initialize an array to be empty:
# Include <stdio. h> int main (void) {int NS1 [10] = {null }; /* or {0} */INT NS2. [2] [3] [4] = {0}; int I; for (I = 0; I