checking if a char is a certain character?

Ive tried this but I cant get it to work! Ive sort of got it to work but I get an error for uninitialized local variable. The thing is, want the user to choose the character, so I dont want to initialize it. Heres some code:

1
2
3
4
5
6
char something;
cin >> something;
if (something == "l")
{
cout << "yay!";
}


I know char * something would solve the error, but then I need to initialize it. I cant understand what to do.

Thanks.
Last edited on
"l" is a string.
'l' is a char
Last edited on
Either you shall write

if ( something == 'l' ) // with single quotes

or

if (something == "l"[0] )

or even

if (something == *"l" )

O ya! Silly me! :P
Thanks guys!
Topic archived. No new replies allowed.