How do you define arrays in the C language?

The method of defining arrays in C language is as follows:

// 定义一个整型数组,数组名为arr,长度为5
int arr[5];

// 定义一个字符数组,数组名为str,长度为10
char str[10];

// 定义一个浮点型数组,数组名为floatArr,长度为3
float floatArr[3];

When defining an array, you need to specify both the data type and length of the array. The length of the array must be a constant expression, and cannot be a variable. The indexing of the array starts at 0, with the first element being indexed as 0, the second element as 1, and so on.

bannerAds