I'm trying to make a simple text based game. Every time I start it, it skips my if statement and moves on through the code.
#include "stdafx.h"
#include "targetver.h"
#include <iostream>
#include <iomanip>
#include <conio.h>
#include <cstdlib>
using namespace std;
int main()
{
cout << "Press Enter To Start." << endl;
while (1)
{
if (_kbhit()) break;
}
char playerName[20];
char cheatsMaybe[20];
char cheatCode[25];
cout << "What's Your Name?" << endl;
cin >> playerName;
cheatRedo:
cout << "Hello " << playerName << ", Do You Have Any Cheat Codes For Me?('yes' or 'no')";
cin >> cheatsMaybe;
if (cheatsMaybe == "yes") {
cout << "Please Enter It Now." << endl;
cin >> cheatCode;
if (cheatCode == "cheatcodehere") {
cout << "Infinite Coins Cheat Has Been Activated, Thank You.";
goto cheatRedo;
}
else if (cheatCode == "cheatcodehere") {
cout << "Infinite Health Cheat Activated, Thank You.";
goto cheatRedo;
}
else {
cout << "Not A Cheat, Try Again";
goto cheatRedo;
}
}
else if (cheatsMaybe == "no") {
cout << "No Cheats Then.";
goto actualStart;
}
actualStart:
I'm using Visual Studio 2015. All answers are appreciated and please keep in mind that I am relatively new to C++.
Aucun commentaire:
Enregistrer un commentaire