below is a small snippet of code I am having my problem with.
ISO C++ forbids comparison between pointer and integer and that is the message I get when I try to compile.
it probably does not help that I dont even know what a pointer exactly is
if (choice==1&&choice>ranNum2)
the little part above is where C++ is spitting out an error, and obviously the 4 variants of that.... originally I had them saying if (choice=="Higher"&&choice>ranNum2) I got the same error
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////Variables//////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
int ranNum=0,ranNum2=0,ranMax=200,guess,scoreP1=0,scoreAI=0,round=0;
//coloring
int scoreP1C=241;
int scoreAIC=242;
void score();
////////////////////////////////////////////////////////////////////////////////
/////////////////////////////Functions//////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
int main()
{
string choice []={"Higher","Lower"};
do
{
srand((unsigned)time(NULL));//init random funct
ranNum=rand()%ranMax;
ranNum++;
cout<<"The number is "<<ranNum<<".\nWill the next number be Higher or Lower than\n"<<ranNum<<"?\n";
srand((unsigned)time(NULL));
ranNum2=rand()%ranMax;
ranNum++;
for (int i=0;i<2;i++)
{
cout<<i+1<<"-"<<choice[i]<<endl;
}
if (choice==1&&choice>ranNum2)
{
cout<<"\nGood job, "<<ranNum<<" is > "<<ranNum2<<" you get a point.\n";
scoreP1++;
round++;
cout<<"\nPlayer 1 has "<<scoreP1<<" points.\n";
cout<<"The AI player has "<<scoreAI<<" points.\n";
cin.get();
Sleep(1000);
}
if (choice==2&&choice<ranNum2)
{
cout<<"\nGood job, "<<ranNum<<" is < "<<ranNum2<<".\n";
scoreP1++;
round++;
cout<<"\nPlayer 1 has "<<scoreP1<<" points.\n";
cout<<"The AI player has "<<scoreAI<<" points.\n";
cin.get();
Sleep(1000);
}
if (choice==1&&ranNum!>ranNum2)
{
cout<<"\nSorry, your guess was wrong "<<ranNum<<" is lower than "<<ranNum2<<".\n";
scoreAI++;
round++;
cout<<"\nPlayer 1 has "<<scoreP1<<" points.\n";
cout<<"The AI player has "<<scoreAI<<" points.\n";
cin.get();
Sleep(1000);
}
if (choice==2&&ranNum!<ranNum2)
{
cout<<"\nSorry, your guess was wrong "<<ranNum<<" is higher than "<<ranNum2<<".\n";
scoreAI++;
round++;
cout<<"\nPlayer 1 has "<<scoreP1<<" points.\n";
cout<<"The AI player has "<<scoreAI<<" points.\n";
cin.get();
Sleep(1000);
}
while (round<10)
score();
}
I apologize for the length of the code, but c++.com didnt let me use the [spoiler][/spoiler]bbc tag :(
putting it like that it wont work, however Like I said I also tried naming a string from that array "Higher" and that returned comparison between distinct pointer types `std::string*' and `const char*' lacks a cast... and that is something I do not understand at all.
when the program does compile the user will use the number 1 or 2 to activate Higher or Lower