Example
int
getNum(){
return
5;
}
void
main(
int
argc,
char
* argv[]) {
while
( a = getNum() ) {
cout <<
"A is still 5"
;
}
}
Solution
If the assignment is an error, change it to be a comparison. Otherwise, do the assignment outside the conditional statement.
int
getNum(){
return
5;
}
void
main(
int
argc,
char
* argv[]) {
int
a = 5;
while
( a == getNum() ) {
cout <<
"A is still 5"
;
}
}