Okay, so I'm (trying) to make a word guessing game, while also trying to learn about coding. My problem here is, that the program skips true if-statements and executes false ones. Here's a section:
#include <iostream>
#include <stdlib.h>
/*Some more #include...*/
using namespace std;
int main()
{
int Lives = 5, Sel_Word, i;
string Sel_Diff;
/*Some more variables*/
while(Lives >= 1)
{
cout << "Difficulty...";
cin >> Sel_Diff;
if (Sel_Diff == "Very Easy")
{
/*Executes game for that level*/
}
/*Gets skipped, when I enter "Very Easy" for
some reason*/
if (Sel_Diff == "Exit")
{
break;
}
/*Works fine*/
if (Sel_Diff == "Easy" || Sel_Diff == "Medium")
/*Et cetera...*/
{
cout << "\n\nDifficulty does not yet exist!";
}
else
{
cout << "\n\nDifficulty does not exist";
}
/*These two execute, when I enter
"Very Easy" for some reason*/
}
}
Someone please help, thanks! Notes: I looked to see if someone has the same problem, but I didn't find anyone, although I found a question about a false statement executing, which doesn't help me. Also, I don't know if this happens only in c++, haven't used c or c#.
Aucun commentaire:
Enregistrer un commentaire