user13653916
user13653916

Reputation:

How can i put more than 3 arguments in a for loop?

I need something like this

for (int epsilon = 0; omega >= epsilon; epsilon += 1; char gamma = 'a'; gamma <= 'z'; gamma++)

But ofcourse it gives an error. Is something like this even possible?

Upvotes: 1

Views: 652

Answers (1)

user12031933
user12031933

Reputation:

You can write the loop like that:

char gamma = 'a';
for ( int epsilon = 0; omega >= epsilon && gamma <= 'z'; epsilon += 1, gamma++ )
{
}

Declaration of a loop indexers must be the same type, for example:

for ( int index1 = 0, index2 = 0; index1 < value1 && index2 < value2; index1++, index2 +=5 )
{
}

So we need to choose one type for the loop and declare others before.

But increments and condition can be mixed.

Upvotes: 2

Related Questions