# C 语言中的数组

``````--------------------------------------------
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | …… | N-1 |
--------------------------------------------

``````

## 1. 数组的声明

``````int intArray[10];
``````

``````int intArray[]={1,2,3,4,5};
``````

``````int a=10, intArray[a];
``````

## 2. 数组的初始化

``````int intArray[]={1,2,3,4,5};
``````

``````int intArray[10]={1,2,3,4,5};
``````

``````int intArray[20]={1,2,3,4,5,[8]=8,9,10,11,[19]=19};
``````

## 4. 示例

``````#include <stdio.h>

int main()
{
int a = 10;
int b[10];
int c[] = {1, 2, 3, 4, 5};
int d[10] = {1, 2, 3, 4, 5};
int e[20] = {1, 2, 3, 4, 5, [8] = 8, 9, 10, 11, [19] = 19};
int f[a];

for (int i = 0; i < 10; i++)
{
printf("b[%d] = %d\n", i, b[i]);
}

for (int i = 0; i < 5; i++)
{
printf("c[%d] = %d\n", i, c[i]);
}

for (int i = 0; i < 10; i++)
{
printf("d[%d] = %d\n", i, d[i]);
}

for (int i = 0; i < 20; i++)
{
printf("e[%d] = %d\n", i, e[i]);
}

for (int i = 0; i < 10; i++)
{
printf("f[%d] = %d\n", i, f[i]);
}

return 0;
}
``````

``````b[0] = -692187488
b[1] = 32767
b[2] = -692187472
b[3] = 32767
b[4] = -1365075304
b[5] = 32673
b[6] = 0
b[7] = 0
b[8] = 0
b[9] = 0
c[0] = 1
c[1] = 2
c[2] = 3
c[3] = 4
c[4] = 5
d[0] = 1
d[1] = 2
d[2] = 3
d[3] = 4
d[4] = 5
d[5] = 0
d[6] = 0
d[7] = 0
d[8] = 0
d[9] = 0
e[0] = 1
e[1] = 2
e[2] = 3
e[3] = 4
e[4] = 5
e[5] = 0
e[6] = 0
e[7] = 0
e[8] = 8
e[9] = 9
e[10] = 10
e[11] = 11
e[12] = 0
e[13] = 0
e[14] = 0
e[15] = 0
e[16] = 0
e[17] = 0
e[18] = 0
e[19] = 19
f[0] = 0
f[1] = 0
f[2] = 1700966438
f[3] = 0
f[4] = -1365075304
f[5] = 32673
f[6] = -692187320
f[7] = 32767
f[8] = -692187264
f[9] = 32767
``````