Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ '==': no conversion from 'int' to 'std::string'

Tags:

c++

I am working on an assignment, so far I am asking the user whether they want to go first or not. I am wanting to check their input to make sure it matches the two values that I want.

I am getting errors about conversion while using Visual Studio such as:

'==': no conversion from 'int' to 'std::string'

no operator "==" matches these operands

Any support is greatly appreciated.

like image 903
fwackk Avatar asked Jun 28 '26 06:06

fwackk


1 Answers

Your problem is in the line:

if (turnChoice == 'yes' || turnChoice == 'no')

C++ and C denote single characters with the single quotation marks, not strings of characters. The compiler is thus attempting to convert your single quotation marks into an integer value. You must use double quotations for string literals. So change the above line to:

if (turnChoice == "yes" || turnChoice == "no")
like image 92
Tyler Lewis Avatar answered Jun 29 '26 19:06

Tyler Lewis