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

  • SEARCH
  • Home
  • 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 8930079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:48:13+00:00 2026-06-15T08:48:13+00:00

I would like to ask how can I make a console game when I

  • 0

I would like to ask how can I make a console game when I need the user to input some string within a period of time? (I’ve tried to use Sleep function but it will make the screen freeze for a period of time which I don’t want to)

Example : A Pop Quiz

  • 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. Editorial Team
    Editorial Team
    2026-06-15T08:48:14+00:00Added an answer on June 15, 2026 at 8:48 am

    I think this can be done without multithreading (A very simple version of a timer)

    You can try to write something like this and modify it to serve your needs:

    Please note that the code is not complete. You need to edit it so it match your needs. However, this should give you an idea.

    int main() 
    {   
       time_t begin, end;
       char input;
       bool flag = true;
       begin = time();
       while (flag) 
       {
          if(kbhit()) 
             ch = getch();
          end = time();
          if(difftime(end, begin) > NEEDED_TIME_IN_SECONDS) 
            flag = false;  //The user didn't enter it in within the wanted period of time
        }
    }
    

    Some documentations:

    • double difftime(time_t time2, time_t time1)
      Return difference between two times
      Calculates the difference in seconds between time1 and time2.
    • getch() Prompts the user to press a character and that character is not printed on screen.
    • kbhit() It returns a non-zero integer if a key is in the keyboard buffer. It will not wait for a key to be pressed.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask how can i make an html anchor (a element)
i would like to ask how can i make a php script which echoes
I am new to swing, I would like to ask how can I make
I would like to make the user input a center number of character, e.g.
I'm having a hard time with templates and would like to ask some help.
I would like to ask, how can I define class inside another one. In
Also I would like to ask if my app is not running then can
I'm trying to make a small username and password input box. I would like
I would like to ask if anyone know how to make use of the
I have a set of pages that I would like to ask the user

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.