This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hey so the main problem I'm having is that every time somebody gets the letter wrong in hangman I want to start drawing the person right, but for some reason when u see my code it doesn't read it properly and places the message in the wrong places.
So this code right here prints out the message
void Hangman::printMessage(string message, bool printT = true, bool printB = true) {
if(printT) {
cout << "*---------------------------------*\n";
cout << "|";
}
else {
cout << "|";
}
bool front = true;
for(char i = message.length(); i < 33; i ){
if(front) {
message = " " message;
}
else {
message = message " ";
}
front = !front;
}
cout << message.c_str();
if(printB) {
cout << "|\n";
cout << "*---------------------------------*\n";
}
else {
cout << "|\n";
}
}
and this code is supposed to start drawing the hangman
void Hangman::draw(int guess) {
guess = 0;
if(guess >= 1) {
printMessage("/", false, false);
}
else {
printMessage("", false, false);
}
}
and this is in my main
int main() {
Hangman h;
h.printMessage("Hang Man", true, true);
h.draw(1);
getchar();
return 0;
}
so for the printMessage function it does exactly what I need it to do the output is:
*---------------------------------*
| Hang Man |
*---------------------------------*
but in the draw function the output is:
*---------------------------------*
| Hang Man |
*---------------------------------*
| |
while I am trying to get it as
*---------------------------------*
| Hang Man |
*---------------------------------*
/
Subreddit
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/cpp_questio...