C語(yǔ)言數(shù)組可以通過(guò)以下幾種方式進(jìn)行初始化:
int arr[] = {1, 2, 3, 4, 5};
int arr[5];
arr[0] = 1;
arr[1] = 2;
arr[2] = 3;
arr[3] = 4;
arr[4] = 5;
int arr[5] = {1, 2};
char str[] = "Hello";
需要注意的是,數(shù)組的初始化只能在定義時(shí)進(jìn)行,之后無(wú)法再進(jìn)行初始化操作。