filmov
tv
C Programming - 47 - Initialize an array
![preview_player](https://i.ytimg.com/vi/ACbPkTFr7hA/sddefault.jpg)
Показать описание
You can initialize an array at the time of its declaration. Following are valid array declarations in a C program.
int X[5] = { 5 , 7, 9, 4 , 2};
char vowels[5] = { 'a' , 'e' , 'i', 'o', 'u' };
int Y[ ] = { 7, 9, 2 };
Look at the last declaration, here the array dimension is not provide. This is also a valid array declaration. If you initialize an array at the time of its declaration , then the array dimension is optional. Put a comma operator between each members in array initialization. Always put a single quotes or double quotes while initializing a character array.
int X[5] = { 5 , 7, 9, 4 , 2};
char vowels[5] = { 'a' , 'e' , 'i', 'o', 'u' };
int Y[ ] = { 7, 9, 2 };
Look at the last declaration, here the array dimension is not provide. This is also a valid array declaration. If you initialize an array at the time of its declaration , then the array dimension is optional. Put a comma operator between each members in array initialization. Always put a single quotes or double quotes while initializing a character array.