How do I verify two letters

Hey guys so basically I'm reading text from a file well like a menu type.
Everything is good now this is my problem:
I have to read a set of letters : S and D.
How do I assigned them a value??
For instance this is what I want to do:

char letter;
double svalue = 21.75;
double dvalue = 25.80;

if (letter = S)<----when I do it gives me an error
letter ==svalue;

letter ==dvalue;

I tried to do that but I keep getting an error it wont let me.
Anyone have any ideas as to how I can approach this? Thank you
BTW! I cant use switch or arrays..
Last edited on
You've got "=" and "==" backward. A single equal sign assigns a value to the variable to the left of it. A double equal sign checks to see if the two items are the same.
Thnx for replying I know what you mean I tried both and I still get an error
The only solution it tells me is that if I want toi use an "if" statement I must make a bool. I really dont know how to apply a bool with this problem.
I just realized that you're trying to compare a LETTER to a DOUBLE, why are you doing this?
if (letter = S) is giving you an error because you don't have single quotes around S. And as previously mentioned you need to use == for equality check, not a single =.

You need to put:

if (letter == 'S')

You will still have problems getting a char to hold a double's value however.
Well I have to make a menu receipt so S means standard menu
D means deluxe menu.

The standard menu costs 21.75
The deluxe menu costs 25.80

However they are simply put as S or D in the menu that I'm reading data from.
Topic archived. No new replies allowed.