Need Help with this Hangman like game
Please help me with confirming the user input letter if it's wrong or right based on the blanked up word.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
srand(time(0));
string guess1="COMPUTING";
string guess2="INFORMATION";
string guess3="TECHNOLOGY";
int guess1len=guess1.length();
int guess2len=guess2.length();
int guess3len=guess3.length();
int guesspick=rand()%3;
cout<<"Word To Guess:";
if (guesspick==0)
{
for(int h=1; h<=4; h++)
{
guess1.replace(rand()%guess1len, 1 , "_");
}
cout<<guess1;
}
else if (guesspick==1)
{
for(int j=1; j<=4; j++)
{
guess2.replace(rand()%guess2len, 1 , "_");
}
cout<<guess2;
}
else if (guesspick==2)
{
for(int k=1; k<=4; k++)
{
guess3.replace(rand()%guess3len, 1 , "_");
}
cout<<guess3;
}
}
|
For Example:
TECHNOLOGY
T_CH_OL__Y
Enter Letter:
K
Wrong
Enter Letter:
O
Right
Until the user gets all the right letters or get wrong guesses 4 times.
Anonymous. haha
Last edited on
Ey don't get caught man, he's everywhere, that name on your comment is a beacon
Topic archived. No new replies allowed.