Share your repls and programming experiences

← Back to all posts

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.

DynamicSquid (4893)

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

DynamicSquid (4893)

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


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

DynamicSquid (4893)

@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.


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