jschmuff
asked on
Help with guess letter location.
I have my hangman game all done and plays great, but I have a small problem. Where the blanks spaces I have '_' and it works great but my whole game is all \t so it is somewhat centered and the blank spaces where I guess are all on the left with no indent how can I get these centered to? or at least tabbed over?
I have tried using \t in there or something doesn't seem to work!
Here is my portion of code in HGame.cpp code:
I have tried using \t in there or something doesn't seem to work!
Here is my portion of code in HGame.cpp code:
void HGame::playGame()
{
char Continue = 'Y';
cout << "\t\tWelcome to Hangman!" << endl;
while(Continue == 'Y')
{
myGame.runGame();
cout << "\n\tDo you want to play again? (Y or N): ";
cin >> Continue;
Continue = toupper(Continue);
}
cout << "\n\tThanks for playing." << endl;
}
void HGame::runGame()
{
myGame.loadList();
int word;
int condition = 1;
int blanks = 0;
char Guess[MAX_WORD_SZ];
char Copy[MAX_WORD_SZ];
char Letter;
int Correct = 0;
srand((unsigned)time(NULL));
word = rand() % count;
strcpy_s(Copy,List[word]);
Sz = strlen(List[word]);
for(; blanks < Sz; blanks++)
{
Guess[blanks] = '_';
}
Guess[blanks] = '\0';
while(condition != 6)
{
myGame.hangMan(condition);
cout << Guess << endl;
cout << "\tGuess letter: ";
cin >> Letter;
cout << endl;
Letter = tolower(Letter);
for(blanks = 0; blanks < Sz; blanks++)
{
if(Copy[blanks] == Letter)
{
Guess[blanks] = Letter;
Correct = 1;
cout << "\n\tGood Guess...";
if(strcmp(List[word],Guess) == 0)
{
cout << "\n\tThe word was: " << List[word] << endl;
cout << "\n\tYou have won and did not hang... good job!\n";
return;
}
}
}
if(Correct == 0)
{
cout << "\n\tBad guess, try again...\n";
condition++;
}
Correct = 0;
}
myGame.hangMan(condition);
cout << "\tThe word was: " << List[word] << endl;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you tried changing line 46 to output tabs before Guess? Something like: -
cout << "\t" << Guess << endl
cout << "\t" << Guess << endl
>> cout << "\t" << Guess << endl
Yep, that's what I suggested too ... Have you tried that, jschmuff ?
Yep, that's what I suggested too ... Have you tried that, jschmuff ?
ASKER
Thanks sorry I was confused about what you were talking about.
ASKER
_______
guess:
the _______ I would like tabbed over
the code for that is on line 36-39