Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 155297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:07:50+00:00 2026-05-11T10:07:50+00:00

So I was feeling bored and decided I wanted to make a hangman game.

  • 0

So I was feeling bored and decided I wanted to make a hangman game. I did an assignment like this back in high school when I first took C++. But this was before I even too geometry, so unfortunately I didn’t do well in any way shape or form in it, and after the semester I trashed everything in a fit of rage.

I’m looking to make a txt document and just throw in a whole bunch of words (ie: test love hungery flummuxed discombobulated pie awkward you get the idea )

So here’s my question: How do I get C++ to read a random word from the document?

I have a feeling #include<ctime> will be needed, as well as srand(time(0)); to get some kind of pseudorandom choice…but I haven’t the foggiest on how to have a random word taken from a file…any suggestions?

Thanks ahead of time!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:07:51+00:00Added an answer on May 11, 2026 at 10:07 am

    Here’s a rough sketch, assuming that the words are separated by whitespaces (space, tab, newline, etc):

    vector<string> words; ifstream in('words.txt'); while(in) {   string word;   in >> word;   words.push_back(word); }  string r=words[rand()%words.size()]; 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Try using a later version of the pickle protocol with… May 11, 2026 at 11:20 am
  • added an answer The version 9.00.4035 uniquely identifies SP3, although it doesn't explicitly… May 11, 2026 at 11:20 am
  • added an answer There are two options: Use Apache as a front end… May 11, 2026 at 11:20 am

Related Questions

So I was listening to the latest Stackoverflow podcast ( episode 19 ), and
So I was writing some code today that basically looks like this: string returnString
So I was wondering if there are any major differences between the various implementations
So I was making a class the other day and used Eclipse's method to
So I was thinking about creating a dynamic sql question, meaning that i want
So I was playing around a little more with attributes in .NET, and realized
So I was thinking one way that you can bring method chaining into PHP
So I was playing around the other day just to see exactly how mass
So I've looked at this use of the freebase API and I was really
So I need to track changes that happen on a Mysql table. I was

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.