0

Compare string and char

can i compare string and char for example , string=raj; char=a; how to compare this string raj to char a ? (Not to compare character wise) i mean i don't need null at below code watch out plzzz. https://code.sololearn.com/cNWDPFfkxEg6/?ref=app

21st May 2018, 11:44 AM
Arman khosla
Arman khosla - avatar
4 odpowiedzi
+ 2
Use a loop to iterate through each character element of the string and compare it with the character provided. You are comparing each character from a string with another character, so you need single quotes instead of double quotes.
21st May 2018, 11:50 AM
Rahul George
Rahul George - avatar
+ 1
but i was thinking- is it possible that ''compare with ' ???
21st May 2018, 12:02 PM
Arman khosla
Arman khosla - avatar
+ 1
because if i use loop i think then also null will print i think....
21st May 2018, 12:04 PM
Arman khosla
Arman khosla - avatar