The following code would print arr[1]
~ arr[5]
.
int arr[5], i=0;
while(i<5){
arr[i]=++i;
printf("%d, ", arr[i]);
}
My question is for an array with a fixed length: can we just add a new element behind that without any limitation?
The following code would print arr[1]
~ arr[5]
.
int arr[5], i=0;
while(i<5){
arr[i]=++i;
printf("%d, ", arr[i]);
}
My question is for an array with a fixed length: can we just add a new element behind that without any limitation?
we can just add new element behind that without any limitation?
No you cannot do that. Arrays are fixed size you mention in your question and something which is fixed means it cannot be changed. You can make a linked list if you want a data structure which can grow.
Also this code invokes undefined behavior:
arr[i]=++i;
Please go through - Why are these constructs undefined behavior?