Answer the question
In order to leave comments, you need to log in
Is it possible in C to initialize an array counter with non-consecutive values?
And if so, how?
That is, for example, with specific values from another array.
Need something like this:
int f[F] = {1,12,3,5};
for (int i=f[0]; i<f[F] ; ++i)
{...}
Answer the question
In order to leave comments, you need to log in
Do you want the loop to have its counter run through the values in the array?
Nothing will work, you have to write like this:
int f[F] = {1,12,3,5};
for (int i=0; i<F ; ++i){
int v=f[i];
...
}
You can initialize the "array count" however you want and change this parameter however you like. The main thing is that the conditions for exiting the loop are fulfilled.
What is an "array counter"? If you mean the number inside [] when accessing elements, you can write anything there, the main thing is not to go beyond the boundaries.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question