An array is literally a combination of a set of numbers
The use of arrays I think it's more convenient to create the same type of data
For example, to create 100 numbers without an array, you must int a = 1;int b = 2 ...
But the use of arrays does not require so much int a[100]= {1,2,3,4,5 ...};
It's a lot easier.
Start by understanding the array from the bottom of the memory storage: The array is in memory in a contiguous address form, each memory occupies a size that you define the type of the array, for example, int arr[10] then the distance between arr[1] and Arr[0 is 4 bytes
Char arr[10] The distance between arr[0] and arr[1] is 1 bytes
If it is a two-dimensional array, his address is so stored arr[0][0]arr[0][1]arr[1][0]arr[1][1]; and the distance between each element is the size of the type you define
There are some situations that require special attention when defining a character array, such as defining a character array char c[10]={' h ', ' e ', ' l ', ' l ', ' o '}, or char c[10]= "Hello", if char arr[] = {' h ', ' e ', ' l ', ' l ', ' O '};sizeof (arr), the result is 6, because the character type array ends with/0, and he says that takes up an element, and the output is using%c
In the definition string array is, the same ending is/0 and occupies an element. Output with%s. Char ch[] = {"Hello", "World"}; This is three elements, the first arr[0] is Hello, the second element arr[1] is world, the third is the end of/0;
int arr[4] = {0}; Arr is actually arr[0];
C Base Array