Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to redirect WriteFile func writes to console

How to redirect WriteFile func writes to console

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestioncsharpwpfhelp
21 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Peter_in_2780

    This smells to me of buffering. I'm guessing your app doesn't call flush() or equivalent on its output file, so the output is buffered until the explicit or implicit close() call at termination. If you can make your app output lots of data, you will probably see it appear in chunks, which will be whatever buffer size is used. The reason it works on the console is that console drivers do not buffer. I have no idea if you can suppress buffering in your redirection, but if you could, my 2c says that would solve your problem. Good luck! Peter

    Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012

    L Offline
    L Offline
    leon de boer
    wrote on last edited by
    #21

    Yes standard console output is always buffered. You can actually easily remove it

    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);

    The problem is it will slow the console program down like a dog as each character invokes a full call. I sometimes do it when I have a embedded target with UART debugger like on the Raspberry Pi.

    In vino veritas

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups