This is my code:
while( Func(x) != ERR_D)
{
if(result == ERR_A)
throw...;
if(result == ERR_B)
throw...;
mydata.x = x;
}
The problem is that I want to use result = Func(x) in the while condition as the result will be checked inside the while loop. The while loop should call Func(x) untill it returns ERR_D.
I can't use
do{
result = Func(x);
if(result == ERR_A)
throw ...;
if(result == ERR_B)
throw ...;
mydata.x = x;
}while(result != ERR_D);
in my project as it first calls Func(x) which is what I don't want.
But I have tried while(result = Func(x) != ERR_D), it doesn't work. Any ideas to solve this?
xnever changes. Maybe that has something to do with it? Hard to say, since "doesn't work" could mean almost anything and we have no idea what's supposed to be happening.var result = Func(x); while (result != ERR_D) { doStuff(); result = Func(x); }?