I am trying to compare a string from my text file to a user input i was wondering how I would do this I have tried the == operator but that seems to be getting me no where. I am currently trying to use the .compare() but it doesn't seem to be working can someone help me out it would be much appreciated.
#include <iostream>
#include <fstream>
using namespace std;
class The_League
{
string champ_type;
string fav_stage;
string disable;
int hitpoints;
string crwd_ctrl;
int health;
int damage;
int health_perlvl;
string name;
string type;
string stage;
string disables;
string crowd_ctrl;
string weakness;
public:
The_League();
The_League(string type, string stage, string disables, int health, string cc);
void sort_Champions();
void In_Out_Stage1();
void screen_Output();
void dps_champions();
};
The_League::The_League()
{
}
The_League::The_League(string type, string stage, string disables, int health, string cc)
{
champ_type = type;
fav_stage = stage;
disable = disables;
hitpoints = health;
crwd_ctrl = cc;
}
void The_League::sort_Champions()
{
ifstream roster("LolRoster.txt");
while(roster>>name>>health>>damage>>health_perlvl>>type>>stage>>disables>>crowd_ctrl)
{
if(type == champ_type)
{
cout<<type;
}
}
}
void The_League::In_Out_Stage1()
{
}
void The_League::screen_Output()
{
}
int main()
{
string champ_type;
string fav_stage;
string disable;
int hitpoints;
string crwd_ctrl;
The_League obj(champ_type, fav_stage, disable, hitpoints, crwd_ctrl);
cout<<"What type of champ do you like? \n1. dps\n2. bruiser\n3. mage\n4. support\n5. tank\n6. ranged"<<endl;
cin>>champ_type;
cout<<"2. What stage of the game is your favorite? \n1. ealry\n2. mid\n3. late"<<endl;
cin>>fav_stage;
cout<<"3. what is your favorite disable? \n1. stun\n2. snare\n3. taunt\n4. fear\n5. knock-up"<<endl;
cin>>disable;
cout<<"4. Do you prefer champs with MOAR Health (1. yes, 0.no)?"<<endl;
cin>>hitpoints;
cout<<"5. Do you prefer champions with crowd control (1. yes, 0.no)"<<endl;
cin>>crwd_ctrl;
obj.sort_Champions();
return 0;
}