More Loops

Assume you want to use a loop to process an array of characters starting from the beginning of the array. You want the loop to stop when you read the null terminator character from the array. Fill in the loop test condition that will make this work correctly.
index = 0;
ch = array[index];
while ( _____________________________)
{
// process the character
index++;
ch = array[index];
}
a variation:
1
2
3
4
5
for ( int index = 0; array[index] != '\0'; ++index )
{
  char ch = array[index];
  // process the character
}
Topic archived. No new replies allowed.