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:
if (letter = S)<----when I do it gives me an error
letter ==svalue;
else
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..
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.
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.