+ 1

array in C

is it fine to not use all the index in an array like char name[30]; scanf("%s", name); \*lets say that the user enters characters that are less than 20, is it fine to declare an array with an unused indexes?*\

10th Dec 2022, 3:32 AM
CodeEater
CodeEater - avatar
1 Respuesta
+ 1
Of course, you can, by specifying the size of the array when declaring a variable, you thereby reserve the amount of memory and no more, so the less you reserve, the less your program will consume RAM.
10th Dec 2022, 12:38 PM
Solo
Solo - avatar