-
While loop problem?
Code:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string input;
int money = 0;
int game = 1;
while(game = 1)
{
cin >> input;
if(input == "help")
{
cout << "Type St00fs f0r St00fs t0 happen\n";
}
if(input == "awsome")
{
cout <<"You Stumble along the dirt road and find a penny\n";
money = money + 1;
}
if(input == "money")
{
cout <<"You has " << money << " mooneys\n";
}
if(input == "gameover")
{
cout <<"You die guiz guiz\n";
game = 0;
}
}
return 0;
}
I type gameover and then it still doesnt exit input loop
-
Classic. You used = instead of == in your condition.
-
Omg lol
Hey thanks simple problem with simple answer
-
If you would have turned on some warnings (like -Wall in gcc) then your compiler would have told you something looked weird about your while loop.