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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#include <iostream>
#include <stdio.h>
#include<conio.h>
#include <ctype.h>
#include <time.h>
using namespace std;
char wordbank[30][30]={"book","cook","Hook","took","wookie","snookie","dog","cat","house","tyranasouras rex","dolphin","jungle","phone","drum","bomb","airport","plane","guess","mess","chess","less","locc-ness","jess","bulge","smulge","indulge","Bin","Ladder","Sausage","chair"};
int word_length;
int lives = 6;
char display_word[20];
char secret_word[20];
char guess_word[20];
char word_found;
int i;
int x =0;
char hidden_word[20];
int count = 0;
char guess;
int test;
int test_letter(char guess);
int main(void)
{
cout<<" _ _ _ _ _ ____ __ __ _ _ _ \n";
cout<<" | | | | / \\ | \\ | |/ ___| \\/ | / \\ | \\ | | \n";
cout<<" | |_| | / _ \\ | \\| | | _| |\\/| | / _ \\ | \\| | \n";
cout<<" | _ |/ ___ \\| |\\ | |_| | | | |/ ___ \\| |\\ | \n";
cout<<" |_| |_/_/ \\_\\_| \\_|\\____|_| |_/_/ \\_\\_| \\_| \n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<"\n";
cout<<" Welcome To Hangman!\n\n Press space bar to continue...\n";
cout<<"+---+\n |\n |\n |\n |\n |\n=========\nPlease make your first guess, choose a letter.\n";
int secret_word, secret_word_Len,i;
srand ( time(NULL) );
secret_word = rand() % 30 ; //Chooses a random word from the word bank
strcpy(&hidden_word[0],&wordbank[secret_word][0]);
secret_word_Len=strlen(hidden_word);
cout<<"Your chosen word has "<<secret_word_Len<<" Letters\n";
cout<<"You Have "<< lives<<" Lives Remaining\n";
cout<<"\n";
cout<<"Enter a Guess\n";
cout << "\n\n" << secret_word_Len;
for(i=0;i<secret_word_Len;i++)
{
cout<<"*";
}
{
cout<<"\n"<<&hidden_word[0]<<"\n";
cin.get();
return 0;
}
while ( ! (cin >> guess))
{
test=test_letter(guess);
if(test==1)
{
cout<<"Correct Guess\n";
}
if (guess == hidden_word[i])
{
display_word[i]= (guess);
}
}
cin.get();
cin.get();
}
| |