Little Game Help

can someone help, my code won’t run , even when my code is identical to ivans example

this is my code:

#include

using namespace std;

int main(){

int attempts = 0;
int target = 0;
int guess = 0;

cout << "Welcome to the game" <<endl<<endl;
cout << "Player 1 Enter a number: ";
cin >> target

while(true){
cout >> "Player 2, try and guess the number: " <<endl;
cin >> guess;

if (guess < target){
    cout << "Number is too low, guess higher"<<endl;
}
else if(guess > target){
    cout << "Number is too high, guess lower"<<endl;
}
else{
    cout << "You guessed correct!!";
    break;
}

}
}

the error states:

/Library/Developer/CommandLineTools/usr/include/c++/v1/istream:1506:1: note: candidate template ignored: could not match
‘basic_istream’ against ‘basic_ostream’
operator>>(basic_istream<_CharT, _Traits>& __is,
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/istream:1638:1: note: candidate template ignored: could not match
‘basic_istream’ against ‘basic_ostream’
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
^
2 errors generated.

been trying to figure it out for an hour but i dont understand

1 Like

i did write #include at the top I just pasted it wrong

I tried your code and it works on my system. Are you using CodeBlocks? Try to reinstall it!
FishshoeCodeHelp