+ 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
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.
+ 2
something like would be helpful
https://code.sololearn.com/csz2rN3FHkRV/?ref=app
+ 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.
+ 2
@kinshuk i don't know what nicholas wants from this program so it depends as you said.
+ 1
its still not clear clarify what you want input & what you want in output.
+ 1
in string isn't it & what you want in output
+ 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.
0
i wanted the program to ask what the abbreviation is ,than the user enters it and it checks wether the answer is good
0
i want to input the abbreviation
0
im sorry i dont understand your question
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