A first Hangman game in C++
I'm not sure if I'd use the phrase "too many", but I think you've included a header or two you'd probably be better off without.

The most obvious example would be &lt;cstring&gt;. There's rarely a good reason to use any of the &lt;cstring&gt; functions in C++ code (and I don't see any hint that this code is one of the rare exceptions either).

Right now, the main (only?) thing I see you using from &lt;cstring&gt; is strstr. std::string has a find member that can find a substring like strstr does.
Your code also seems somewhat inconsistent, at least to me. For example, in one place you create a string with N repetitions of a single character using code like: std::string(character, repetitions). In another place you do roughly the same thing using a loop to append on underscore at a time. Since they're doing the same thing, it would be better for them to do it the same way (preferably the constructor for std::string).
Right now you use a string to hold a single character (and enforce its being only one character). Since it's only a single char, I'd rather just use a char to hold it.
As a general rule of thumb, I'd prefer a well-chosen algorithm from the standard library over a raw loop.
Yes, you can (and in my opinion, should) break the code up into more functions (and based on your question, it seems like you already agree, but may not be sure how to do it).
I'd generally prefer to use the new random-number generation routines in &lt;random&gt; over the srand/rand from the C library. Likewise, I'd rather use the distribution classes in the standard library over the rand() % total_lines you have now. (but in fairness, they are more work to use, and it's unlikely to make a difference anybody's likely to notice or care about (but in many other cases, it's more important).
I'd avoid using namespace std; I know at first it seems painful to type in std:: everywhere, but it's still better than using namespace std;.
There are also neater ways to read words from a file into an array of strings, such as:

std::ifstream infile("wordlist.txt");

std::vector&lt;std::string&gt;{std::istream_iterator&lt;std::string&gt;(infile), {}};


One point though: this will produce different results if your input file has multiple words on one line. In this case your code treats a whole line as one word, but this treats each word separately.
I generally advise against using std::endl. It's probably harmless in this case, but a habit I'd try to avoid anyway.