I'm required to find a character entered by the user in a for loop. I'd usually do
- if (sentence[i] == 'e')
but since here, 'e' will be a one letter char variable, I don't know how to get that value to be compared. I can't just enter
- if (sentence[i] == thechar)
but I also can't create a variable to contain the character in between quotation marks like
- char2 = "\'" + thechar + "\'";
So how do I do it in this context? I'm not allowed to use other, more effective, more advanced methods. This is a basics course. Please help!
''is for character literals. Once you have achar, you don't need to add the single quotation marks or anything special.