Hello, I am very new to writing C++ and have started tryign to write a very basic calculator, capable of timesing, dividing, plussing or minusing two whole numbers.
I could be way off with this effort, but this is the code so far. And the only errors I get are when in the 'if' sections and the error is:'ISO C++ forbids comparison between pointer and integer'
Code:
#include <iostream>
using namespace std;
int main()
{
int number1;
char var;
int number2;
cout<<"Welcome to 'Phil's Calculator'\n";
cin.get();
cout<<"\nPlease choose a number \n";
cin>> number1;
cin.get();
cout<<"\nNow choose your variable. *,/,+ or - \n";
cin>> var;
cin.get();
cout<<"\nAnd finally, choose your second number \n";
cin>> number2;
cin.get();
if ( var == "*") {
cout<< number1*number2;
}
else if ( var == "/") {
cout<< number1/number2;
}
else if ( var == "+") {
cout<< number1+number2;
}
else if ( var == "-") {
cout<< number1-number2;
}
else cout<<"sorry, this program cannot do that";
}
Hope someone can tell me what i'm doing wrong, and how to fix the error.
Thanks
Phil