Archived

This topic is now archived and is closed to further replies.

phil05

If/Else Condition with Characters

Recommended Posts

What I have has no errors, but does a infinite loop. I want it to recognize the "y" the character inputs in a do/while loop in c++.
char abilityAnswer[2];
  do { 
	system("cls");
	cout << "Ability Modifiers:" << endl;
	cout << "------------------\n" << endl;
	cout << "\tStrength: " << Player.STR << "          Intelligence: " << Player.INT << endl;
		cout << "\tDexterity: " << Player.DEX << "     Wisdom: " << Player.WIS << endl;
		cout << "\tConstitution: " << Player.CON << "   Charisma: " << Player.CHA << endl;
	
		cout << "Type ''y'' or ''n'' to continue: ";
		cin.getline(abilityAnswer, 2, ''\n'');
	} while (abilityAnswer != "y");
 

Share this post


Link to post
Share on other sites
I''m extremely new to std::string. Does it need the #include <string> header? And can you fix my code above so I can see it visually? Thanks.

Share this post


Link to post
Share on other sites