c++ calculater (need help with pointer and trigger??)
i have written this c++ code a few days ago,
now my problem is i want to have the user input and check if its y or n but i get this error message
Code:
ANSI c++ forbits comparison between pointers and triggers
here's my c++ code
Code:
#include <iostream.h>
#include <stdlib.h>
int main()
{
int choice;
int x1;
int x2;
int mem1;
int mem2;
int answer;
char drie ;
cout <<" 1 = +\n";
cout <<" 2 = -\n";
cout <<" 3 = *\n";
cout <<" 4 = /\n";
cout <<" 5 = %\n";
cout <<" 6 = documentation/license\n";
cout <<" enter your choice: \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n ";
cin>>choice;
if (choice == 1){
cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nnenter number 1: ";
cin>>x1;
cout <<"\nenter number 2: ";
cin>>x2;
answer = x1 + x2;
cout <<"your answer :"<<answer<<"\n";
}
if (choice == 2){
cout <<"\nenter number 1: ";
cin>>x1;
cout <<"\nenter number 2: ";
cin>>x2;
answer = x1 - x2;
cout <<"your answer :"<<answer<<"\n";
}
if (choice == 3){
cout <<"\nenter number 1: ";
cin>>x1;
cout <<"\nenter number 2: ";
cin>>x2;
answer = x1 * x2;
cout <<"your answer :"<<answer<<"\n";
}
if (choice == 4){
cout <<"\nenter number 1: ";
cin>>x1;
cout <<"\nenter number 2: ";
cin>>x2;
answer = x1 / x2;
cout <<"your answer :"<<answer<<"\n";
}
if (choice == 5){
cout <<"\nenter number 1: ";
cin>>x1;
cout <<"\nenter number 2: ";
cin>>x2;
answer = x1 % x2;
cout <<"your answer :"<<answer<<"\n";
}
if (choice == 6){
cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
cout <<"welcome to tech calculator(TM) (c) stefan feenstra\n\n";
cout <<"you may not debug or do anything to get the source code\n";
cout <<"calculater is written in c++ 77 lines of code\n";
cout <<"this software is freeware, you may redristrubute BUT\n";
cout <<"you must leave a link to the official website\n";
cout <<"due to this software is Freeware the auther takes\n" ;
cout <<"no responsibillety, if you do not agree to these terms,\n" ;
cout <<"you may not use this software\n\n\n\n";
cout <<"known bugs, when typing a letter at a calculation you cant\n" ;
cout <<"type in a second number, or the program will terminate or something else\n";
cout <<"if you need to report a bug you can send it to [email protected]\n";
cout <<"under title of \'TECH CALCULATER BUG\'";
}
if (choice != 1 && choice != 2 && choice != 3 && choice != 4 && choice != 5 && choice != 6){
cout <<"\na error acured you entered a wrong number/letter you entered as choice\'"<<choice<<"\'";
}
//system("PAUSE");
cout <<"return ? 1 or 0 : ";
cin>>drie;
if (drie == "y"){
cout <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
return main();
}
if (drie != "n"){
return 0;
}
}
P.S. sorry i did not commend it