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. Writing to the console only (without re-direction)

Writing to the console only (without re-direction)

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 2 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.
  • M Offline
    M Offline
    Member 3852024
    wrote on last edited by
    #1

    Process A launches process B with re-directed out, and err. Process B must write to the console only - no re-direction (as the output will obviously be routed back to Process A). I have tried a number of ways; including _cputs() etc. But I need a method where the output is rendered faithfully - where extended ASCII chars are written correctly. None of the 'console only' output functions seem to support this. Any suggestions? Third party libraries I might look at? Thanks in advance.

    H 1 Reply Last reply
    0
    • M Member 3852024

      Process A launches process B with re-directed out, and err. Process B must write to the console only - no re-direction (as the output will obviously be routed back to Process A). I have tried a number of ways; including _cputs() etc. But I need a method where the output is rendered faithfully - where extended ASCII chars are written correctly. None of the 'console only' output functions seem to support this. Any suggestions? Third party libraries I might look at? Thanks in advance.

      H Offline
      H Offline
      Hans Dietrich
      wrote on last edited by
      #2

      Have you tried wprintf?

      Best wishes, Hans


      [Hans Dietrich Software]

      M 1 Reply Last reply
      0
      • H Hans Dietrich

        Have you tried wprintf?

        Best wishes, Hans


        [Hans Dietrich Software]

        M Offline
        M Offline
        Member 3852024
        wrote on last edited by
        #3

        Hi Hans. Thank you for the suggestion but all of the variations of printf, cout etc .. all write to an (re-directable) output stream. I need to write the console only.

        H 1 Reply Last reply
        0
        • M Member 3852024

          Hi Hans. Thank you for the suggestion but all of the variations of printf, cout etc .. all write to an (re-directable) output stream. I need to write the console only.

          H Offline
          H Offline
          Hans Dietrich
          wrote on last edited by
          #4

          You might try CreateFile() with device name "CON" and dwDesiredAccess = GENERIC_WRITE.

          Best wishes, Hans


          [Hans Dietrich Software]

          M 2 Replies Last reply
          0
          • H Hans Dietrich

            You might try CreateFile() with device name "CON" and dwDesiredAccess = GENERIC_WRITE.

            Best wishes, Hans


            [Hans Dietrich Software]

            M Offline
            M Offline
            Member 3852024
            wrote on last edited by
            #5

            Thanks Hans .. I am going to try that! Cheers.

            1 Reply Last reply
            0
            • H Hans Dietrich

              You might try CreateFile() with device name "CON" and dwDesiredAccess = GENERIC_WRITE.

              Best wishes, Hans


              [Hans Dietrich Software]

              M Offline
              M Offline
              Member 3852024
              wrote on last edited by
              #6

              Hans. Thanks a lot for the CreateFile() suggestion. It works perfectly .. I am delighted. You should create a short post about CONS only output. There is lots out there about re-direction etc .. but nothing that I could find about faithful rendering of console only output. Again .. cheers. Best regards. James.

              H 1 Reply Last reply
              0
              • M Member 3852024

                Hans. Thanks a lot for the CreateFile() suggestion. It works perfectly .. I am delighted. You should create a short post about CONS only output. There is lots out there about re-direction etc .. but nothing that I could find about faithful rendering of console only output. Again .. cheers. Best regards. James.

                H Offline
                H Offline
                Hans Dietrich
                wrote on last edited by
                #7

                Thanks for letting me know. For my own curiosity, can you say why you want to disallow redirection?

                Best wishes, Hans


                [Hans Dietrich Software]

                M 1 Reply Last reply
                0
                • H Hans Dietrich

                  Thanks for letting me know. For my own curiosity, can you say why you want to disallow redirection?

                  Best wishes, Hans


                  [Hans Dietrich Software]

                  M Offline
                  M Offline
                  Member 3852024
                  wrote on last edited by
                  #8

                  Hi Hans. I have been writing an application for a few years now .. www.tenfiftytwo.co.uk/pipelines It's basically a multi-stream pipelines (textual manipulation) app that will allow you to chain together pipelines to transform text/data. I am developing a TRACE option that allows interactive user input to inspect i/o records and in order to do this each called process must share the same console. So, console prompts must be just that - no redirection back to the calling process. They need to be console only. Only the called process output should be captured by re-directed streams. Best regards. James. PS. Cannot believe that I did not think of CreateFile() .. thanks again.

                  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