Looking at the code, both if statements are returned.
for (int i = 0; i < 11; i++){
if (input.compare(station[i]) == 0){
return 0;
}
else if (input.compare(station[i]) == 1){
"Cout <<" * Station without. Please re-enter." <<endl;
return 1;
}
}
If you look at this code, i=0, that is, if the comparison statement in the first for statement is 0 or 1, it is written in a structure that returns unconditionally.
The more correct logic would be to return immediately if there is a match to the array, and to return if there is no match to the array (i.e., if you go all the way through the loop).
for (int i = 0; i < 11; i++){
if (input.compare(station[i]) == 0){
return 0;
}
}
"Cout <<" * Station without. Please re-enter." <<endl;
return 1;
© 2024 OneMinuteCode. All rights reserved.