I'm attempting to do a simple output where the int variable "creaturelevel" is shown to the user, but it's giving back an error that says: "oroperator.cpp": E2087 Illegal use of pointer in function main() at line 18
It's a variable; I never declared a pointer in this project. I've looked but I don't understand what the problem is, can you help me figure it out?
#include <iostream>
usingnamespace std;
int main()
{
/* deciding whether or not to attack player if any value is
true */
int playerlevel;
int creaturelevel;
bool playerisattacking;
int attackordefend;
cout<<"Your level is: ";
cin>>playerlevel;
creaturelevel = playerlevel - 12;
cout<"Creeping along a dark hallway with your M4 Carbine \
ready to fire...the floors are soaked with blood from last \
nights ambush. A creature approaches, level " << creaturelevel << "\n";
cout<<" . Do you want to attack it \
or sneak past it?\n";
cout<<"Attack: 1\nDefend: 2\n";
//if attacks, game checks for player level versus creature
//level.
switch (attackordefend) // checks whether or not hes attacking
{
case 1:
bool playerisattacking = true; // player is attacking
if ( (playerisattacking == false) || (playerlevel < creaturelevel + 5) )
{
cout<<"The creature spots your effortless attack and you are ambushed...\nWith\
a broken leg and a cracked rib, you limp out of the building\n but bleed to death\
before you can reach your teammates.\n\n\n\t\t\t\t\t\tGame over.\n";
cin.get();
}
case 2:
cout<<"You successfully defend against the creature, and kill it with a \
headshot.\n";
}
cin.get();
}
another error I received for reference: "oroperator.cpp": E2126 Case bypasses initialization of a local variable in function main() at line 35
Thanks.
P.S.: the point of the program itself is to test out the OR logical operator when it comes to if statements.