+ 1

Problem with using an if and an array

I'm a C++ beginner that's trying to make a little question game to help learn the periodic table (in French) and when I run it on my compiler it gives me the error "no match for operator == ". Any comments are useful. https://code.sololearn.com/cwTwrwFGcExz/#cpp

12th Nov 2017, 4:38 AM
Nicholas Legrand
Nicholas Legrand - avatar
11 Answers
+ 3
You cannot compare a string to an integer. Doing something like this is invalid : 1 == "H". I suggest you turn x to a string, and then input the abbreviation itself.
12th Nov 2017, 4:44 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
something like would be helpful https://code.sololearn.com/csz2rN3FHkRV/?ref=app
12th Nov 2017, 4:50 AM
shobhit
shobhit - avatar
+ 2
@shobhit But in the end, it depends on what Nicholas is going to input to the console. If its a string, he will have to change x, else he will have to do a comparison like your modified program does.
12th Nov 2017, 4:52 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
@kinshuk i don't know what nicholas wants from this program so it depends as you said.
12th Nov 2017, 4:54 AM
shobhit
shobhit - avatar
+ 1
its still not clear clarify what you want input & what you want in output.
12th Nov 2017, 5:08 AM
shobhit
shobhit - avatar
+ 1
in string isn't it & what you want in output
12th Nov 2017, 5:12 AM
shobhit
shobhit - avatar
+ 1
tell me clearly what r input what will be output so that i can help as of now as i understood your question you would need to input a string, check its index & output that index of element array.
12th Nov 2017, 5:30 AM
shobhit
shobhit - avatar
0
i wanted the program to ask what the abbreviation is ,than the user enters it and it checks wether the answer is good
12th Nov 2017, 5:01 AM
Nicholas Legrand
Nicholas Legrand - avatar
0
i want to input the abbreviation
12th Nov 2017, 5:11 AM
Nicholas Legrand
Nicholas Legrand - avatar
0
im sorry i dont understand your question
12th Nov 2017, 5:13 AM
Nicholas Legrand
Nicholas Legrand - avatar
0
Yea but the entire point was to make a game that asks what the abbreviation of the atom is and then tells wether its right or wrong
12th Nov 2017, 5:35 AM
Nicholas Legrand
Nicholas Legrand - avatar