Skip to content
← Back to Community
hangman
Profile icon
ANDREWVOSS

This is a simple hangman game in C. Have someone else enter the phrase, and then try and guess the letters.

or you could just cheat and enter the phrase yourself, I won't stop you

This was surprisingly tough to make in C (still pretty easy tho). C++'s std::cin and new statements would have made the user input way simpler to code.

Voters
Profile icon
leachestlurker
Profile icon
ANDREWVOSS
Comments
hotnewtop
Profile icon
DynamicSquid

How would C++'s new keyword make things easier?

Profile icon
VMTU

@DynamicSquid c++ 😎

Profile icon
DynamicSquid

@VMTU ? But you're not doing any dynamic memory allocation?

Profile icon
ANDREWVOSS

@DynamicSquid the game_str function creates a dynamically sized array, which would be much easier with char* str = new char[len];

Profile icon
DynamicSquid

@ANDREWVOSS I don't see why you could have just used a character array? Also C++ has std::string, which means you don't have to use new at all.

Profile icon
ANDREWVOSS

@DynamicSquid

  1. Returning a character array was leading to bugs with longer phrases
  2. Kinda forgot about std::string, you're right.