Basically me and my friend are making a C++ hangman project in our programming class and we're having troubles trying to find a way (with our limited knowledge) on how to display certain letters if their guess is correct. E.G ____ __ (they input the letter i) displays __i__ _i or whatever, anyways heres the basis code for our project and we were just wondering if there was an easy way we could do this an understand it, we were thinking a for loop and a multi dimensional array but couldn't get it to work.


code:

/*****************************

//Hang Man Game

//Rory and Nathan

//Nov 8 2007

//Limitations:

//*****************************


#include <iostream>

using namespace std;


void display()

{

//Displays Hangman interface

cout<<"  []    []     [][]    [][]    []  [][][][]  [][]   [][]    [][]    [][]    []  " <<endl;

cout<<"  []    []    []  []   [] []   []  []        [] [] [] []   []  []   [] []   []  " <<endl;

cout<<"  [][][][]   [][][][]  []  []  []  []  [][]  []  []   []  [][][][]  []  []  []  " <<endl;

cout<<"  []    []   []    []  []   [] []  []    []  []       []  []    []  []   [] []  " <<endl;

cout<<"  []    []   []    []  []    [][]  [][][][]  []       []  []    []  []    [][]  " <<endl;

}


//Hang man Graphics

void hanger1()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger2()

{

cout<<"     _________       " <<endl;

cout<<"    ||       |       " <<endl;

cout<<"    ||       |        " <<endl;

cout<<"    ||     (oo)       " <<endl;

cout<<"    ||                " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger3()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger4()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||       |__       " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger5()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||     __|__       " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger6()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||     __|__       " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger7()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||     __|__       " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}

void hanger8()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||     __|__       " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||      /!         " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}


void hanger9()

{

cout<<"     _________         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||     (oo)        " <<endl;

cout<<"    ||     __|__       " <<endl;

cout<<"    ||       |         " <<endl;

cout<<"    ||      /!          " <<endl;

cout<<"    ||                 " <<endl;

cout<<"    ||______________   " <<endl;

cout<<"    [][][][][][][][]   " <<endl;

}




//Varaibale functions


               









int main () {


//Variables

int selection1=1;//users selection

char again;//Loop input

int score=0;//the users score

int choice=2;//users categories choice

//Char_Variables

//**********

char mletterm1;

char mword[9] = {'i','a','m','l' ,'e','g','e','n','d' };

int wanswer=0;

//**********

//random Variables

//Catagories 1

srand((unsigned)time(0)); 

int movies; 

for(int index= 0; index<20; index++){ 

movies = (rand()%3)+1;}

//2 

srand((unsigned)time(0)); 

int games; 

for(int index= 0; index<20; index++){ 

games = (rand()%3)+1;}

//3 

srand((unsigned)time(0)); 

int famousquotes; 

for(int index= 0; index<20; index++){ 

famousquotes = (rand()%3)+1 ;}

//4

srand((unsigned)time(0)); 

int hockey; 

for(int index= 0; index<20; index++){ 

hockey = (rand()%3)+1;}

//5

srand((unsigned)time(0)); 

int skilltest; 

for(int index= 0; index<20; index++){ 

skilltest = (rand()%3)+1 ;}


//displays graphic

display();

do{

cout<<"\n\n\n Welcome to Hangman the game" <<endl; 

cout<<"1)For a tutorial" <<endl;

cout<<"2)Start a new game" <<endl;

cout<<"3)View your current score" <<endl;

//user chooses if they want insructions or to start the game

cin>>selection1;

//Tutorial

if (selection1==1){

cout<<"Welcome to Hangman! the word guessing game! During a game of hangman, the player" <<endl;

cout<<"will take guesses at the letters in a word, the player will recieve 10 false " <<endl;

cout<<"guesses before he/her losses the game." <<endl;

cout<<" \n The players score will be tallied based on 1 point per correct awnser"<<endl;

cout<<"this allows the option for intense multiplayer games against your friends" <<endl;

cout<<"\n\n Enter 1 to go back to selection screen" <<endl;

cin>>again;

}

//Users Score

else if(selection1== 3){

cout<<"Your current score is: " <<score<<endl;

cout<<"\n Enter 1 to return to menu" <<endl;

cin>>again;

}

//Displays word categories to the user

else if(selection1== 2){

cout<<"Its time to play! Please select one of the 6 categories" <<endl;

cout<<"1)Movies"<<endl;

cout<<"2)Games"<<endl;

cout<<"3)Famous Quotes" <<endl;

cout<<"4)Hockey Players" <<endl;

cout<<"5)Skill test"<<endl;

cin>>choice;

   

//Movie word game

if(choice==1){

cout<<"You have selected Movies!" <<endl;

//*****************

do { 

cout << "_ __ ______" << endl;

cin >> mletterm1;

if ( mletterm1 == 'i' || mletterm1 == 'a' || mletterm1 == 'm' || mletterm1 == 'l' || mletterm1 == 'e' || mletterm1 == 'g' || mletterm1 == 'e' || mletterm1 == 'n' || mletterm1 == 'd'  ) { cout << "The letter " << mletterm1 << " is a letter in the word" << endl; }

          else if( mletterm1 != 'i' ||mletterm1 != 'a' || mletterm1 != 'm' || mletterm1 != 'l' || mletterm1 != 'e' || mletterm1 != 'g' || mletterm1 != 'e' || mletterm1 != 'n' || mletterm1 != 'd' ) { cout << "That letter is not in the word" << endl;

wanswer=wanswer+1;

if (wanswer == 1) { hanger2();}

else if (wanswer == 2) { hanger3();}

else if (wanswer == 3) { hanger4();}

else if (wanswer == 4) { hanger5();}

else if (wanswer == 5) { hanger6();}

else if (wanswer == 6) { hanger7();}

else if (wanswer == 7) { hanger8();}

else if (wanswer == 8) { cout << "GAME OVER" << endl; hanger9();}

}

} while (wanswer != 9);

//*****************

}

//Game word game

else if(choice== 2){

cout<<"You have selected Games" <<endl;

}

//Quotes word game

else if(choice== 3){

cout<<"You have selected Famous quotes" <<endl;

}

//Hockey Players word game

else if(choice== 4){

cout<<"You have selected hockey Players:" <<endl;

}

//Skill test word game

else if(choice== 5){

cout<<"you have selected Skill testing words" <<endl;

}

}


}while(again=='1');


return 0;

}

Use an array initialized to underscores. Then for each letter guessed correctly, replace the appropriate values with the letter guessed. Then you can output this array.