Thread: Concurrent execution of cout statements while program is running? (ask)

  1. #1
    Registered User
    Join Date
    Sep 2018
    Posts
    217

    Concurrent execution of cout statements while program is running? (ask)

    So I had this idea to beautify my console window by using (char)219 ASCII value which is a white block. So essentially I used that to make a border. Then I thought about having a non-static background.

    So using: delay, clear-screen and cout statements; the border, which is checkered in look would keep blinking.

    Using SetConsolePosition from windows.h, I could easily place text inside this border and there's no problem with this non-static border.

    But here's the issue. The execution of cout statements stop when the program needs the user to enter a character.

    So is there anyway at all to have those cout statements be executing on their own while the user can give his input?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    ReadConsoleInput function - Windows Console | Microsoft Docs
    GetNumberOfConsoleInputEvents function - Windows Console | Microsoft Docs

    If you want very fine detailed control over the console, you'll be better off using a library like ncurses / pdcurses.

    There might be a way to do what you want with cin/cout, but it will be messy.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Sep 2018
    Posts
    217
    Ahh I just read about Multi-threading using the 'thread' header file. I hadn't known that there was support for this.. THIS IS AWESOME! AND IT WORKS!
    So that's one way of doing this.
    I'll post this just in case somebody else had a similar problem.

    Cheers!

    Thanks for the suggestion Salem, I didn't get the intent of the Microsoft Doc links (and the fact that I still don't know how to use the windows.h header file). But I will definitely look up ncurses when I'm free.
    Last edited by Nwb; 09-22-2018 at 09:48 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-12-2013, 06:22 PM
  2. Execution of statements in a loop condition
    By 127.0.0.1 in forum C Programming
    Replies: 4
    Last Post: 05-10-2011, 06:12 AM
  3. how do you repeat cout statements?
    By findme in forum C++ Programming
    Replies: 10
    Last Post: 11-21-2005, 11:34 AM
  4. Strange if-statements execution
    By ripper079 in forum C++ Programming
    Replies: 2
    Last Post: 06-20-2003, 11:59 AM

Tags for this Thread