C++ help

Associate
Joined
24 Aug 2006
Posts
50
Location
Derby
Hi,

Bit of a newbie C++ programmer, and I was wondering if someone could help me.

I have an if statement as follows:

void ABalanceSmooth::getParameterDisplay(long index, char *text)
{
if (fBal==0)
{
strcpy (text, " Hard Left ");
}
else if (fBal==1.0)
{
strcpy (text, " Centre ");
}
else if (fBal==2.0)
{
strcpy (text, " Hard Right ");
}
else
float2string(fBal,text);
}

Where fBal==1.0 in order to display Centre, I would like it to display Centre between values from 0.98 to 1.02. I'm trying normal operators <, >, <= and >= and they don't seem to be working.

Any ideas?

Cheers.
 
Cheers! Tried something similar to that earlier and it didn't work - looks like I was missing two brackets. Thanks again.
 
Unless you've got a duff compiler, (x >= a && x <= b) is exactly equivalent to ((x >= a) && (x <= b)) in C & C++
 
Back
Top Bottom