String comparison error
Hey everyone, Ive been trying to make a calculator, a portion of its code is shown below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
#include <string>
using std::string;
using std::cout;
using std::cin;
using std::endl;
int main () {
float fNum1;
float fNum2;
string sResponse;
float fProduct;
float fSum;
float fQuotient;
int iLine;
for(bool bConfirm = true ; bConfirm == true;) {
entry:
cout << " Welcome To Evans Calculator.\n If You Would Like To Quit Enter Quit" << endl << endl;
cout << " What Would You like To Do? " << endl << endl;
cout << " 1 - Multiplication" << endl << endl;
cout << " 2 - Addition" << endl << endl;
cout << " 3 - Division" << endl << endl << " ";
cin >> sResponse;
cin.ignore();
if (sResponse == 'q' || sResponse == 'Q') { //Exits If User Entered Q
bConfirm = false;
|
I get a build time error though on this part
1 2
|
if (sResponse == 'q' || sResponse == 'Q') { //Exits If User Entered Q
bConfirm = false
|
Saying " Error: no operator '==' matches these operands." How would i compare sResponse to q without getting that error
Last edited on
if (sResponse == "q" || sResponse == "Q")
Hmm thanks a ton! that worked, i thought double quotes where used for strings with more than 1 letter
Topic archived. No new replies allowed.