A loop using an array

The problem I'm having is, i want an if/else statement to run until certain conditions within a while loop are met. Basically before this starts the user enters 4 names and then the while loop kicks in and asks the user to constantly do an if/else statement until all the names have been entered then the code moves on, the only thing is I have to assign or think I have to assign a certain point of the array to get the while loop to work, meaning say

while ( get_team_name(0) >= teamname)

I want it to basically search through all the array and not break when a certain part of the array is met? you follow?? for some strange reason im finding it really hard to explain so I apologise

Thanks
Last edited on
No, I'm not following.
I believe you are referring to your sports team program thing you have been working on. And you want to iterate through an array and check the team names? Just a simple for-loop will suffice. I think I remember you having 4 teams, so:

1
2
3
for( size_t i = 0; i < 4; ++ i ) {
     // check whatever you want with team[i]
}
Last edited on
I did try a for loop, however it appears that if i enter an incorrect name it wont let me finish entering all the names as it only lets me enter a name 4 times so it basically runs out of loops?

I even tried combining a for loop with a while loop, it's sending me crazy this part.

Also the loop holds an if/else statement within it, thats why I thought a while loop would be easier to work with
Last edited on
Basically I'm trying to get the loop to say "While it's not equal to anything inside this array then loop"

but for some strange reason can't!!
Topic archived. No new replies allowed.