Cinere
Cinere

Reputation: 23

error: Iso c++ forbids comparison between pointer and integer [c++]

I'm getting the error in title when trying to compile.

#include <iostream>
using namespace std;

int chance()
{
return rand()%11;
}

int main()
{
if (chance > 5)
    cout << "You win." << endl;
else
    cout << "You lose." << endl;
return 0;
}

This is my full code, I'm attempting to have it output You win or You lose, 50-50

Upvotes: 0

Views: 3877

Answers (1)

billz
billz

Reputation: 45410

You are comparing function pointer to an integer(5), I guess you want to call chance() function, try

if (chance() > 5)
          ^^

Upvotes: 5

Related Questions