Im having a problem with some of this code

Jan 8, 2016 at 7:11pm
I am getting the error comparison between distinct pointe types std::string with this code

if(energy <= gymc3){
cout << "If you work out any further you could possibly die from a heart attack\nAre you sure you want to keep working out? Y/N" << endl;
cin >> gymc4;
if(gymc4 == 'y' || gymc4 == 'Y'){
string deadono[] = {"Heart Attack", "Your Still Alive"};
string gymc5 = deadono[rand()%2];
if(deadono == "Heart Attack"){
cout << "You had a Heart Attack from working out too hard, You are dead" << endl;
}
}
}
Jan 8, 2016 at 7:21pm
So first don't give us the full code, so we have no idea what type of variables we are looking at.
Then you decide that writing "error comparison" will give us more information about the error than your compiler. Genius!

1. Post full relevant code that reproduces the problem.
2. Post actual errors.
3. Edit your post and use code tags - http://www.cplusplus.com/articles/jEywvCM9/
Jan 8, 2016 at 8:04pm
TarikNeaj Is correct

Guessing at the rest of your code, I would say you are possibly using a string instead of a char for gymc4- in which case you would change 'y' and 'Y' to "y" and "Y"
Jan 8, 2016 at 9:42pm
1
2
3
string deadono[] = {"Heart Attack", "Your Still Alive"};
string gymc5 = deadono[rand()%2];
if(deadono == "Heart Attack"){

deadono is an array, at line 3 you can't compare it to a string. I think you meant
if (gymc5 == "Heart Attack"){
Jan 11, 2016 at 1:47pm
Im sorry tarik im kindof new to posting code errors
Jan 11, 2016 at 1:52pm
Well, that's why there is a Read before posting - http://www.cplusplus.com/forum/beginner/1/
Topic archived. No new replies allowed.