Hi, I am a newbie programmer and is currently making a simple Dungeon Crawler, however I have encountered a problem. Here is my code:
Code:
#include <iostream>
#include <cstdlib>
const int LOW = 1;
const int HIGH = 10;
using namespace std;
struct Entity
{
int Health;
int Defence;
int Attack;
};
int main()
{
Entity Goblin;
Entity Character;
Goblin.Health = rand() % (HIGH - LOW + 1) + LOW;
Goblin.Defence = rand() % (HIGH - LOW + 1) + LOW;
Goblin.Attack = rand() % (HIGH - LOW + 1) + LOW;
Character.Health = 10;
Character.Defence = 10;
Character.Attack = 10;
cout << "YOU ENCOUNTER A GOBLIN!" << endl << endl;
cout << "Goblin's Health is " << Goblin.Health << endl;
cout << "Goblin's Defence is " << Goblin.Defence << endl;
cout << "Goblin's attack is " << Goblin.Attack << endl << endl;
cout << "Your Health is " << Character.Health << endl;
cout << "Your Defence is " << Character.Defence << endl;
cout << "Your Attack is " << Character.Attack << endl << endl;
char attack;
cin >> attack >> endl;
cout << "You attack the Goblin" << endl;
return 0;
}
The thing is, that this code giver me an error: no match for 'operator>>' in 'std:perator>> [with _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char&)(& attack))) >> std::endl'|
I have no idea what the problem is and would appreciate help