Thread: How to get the console output

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    9

    How to get the console output

    Hello, I'm wondering how to get the console output in c++ application in some string or file... For example, when the code -> system("pause"); executes, on the console the text "Press any key to continue" appears. How to get that text, or everything what is currently displayed on the console into a string or file, ???
    Thanks In Advance

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Simply use pipes (I think this is how they're called).

    In a shell (DOS) :
    myprogram.exe > output.txt

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Desolation View Post
    Simply use pipes (I think this is how they're called).

    In a shell (DOS) :
    myprogram.exe > output.txt
    Actually, that particular thing is called IO redirection.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Output string to both console and file at the same time
    By GOBLIN-85 in forum C++ Programming
    Replies: 6
    Last Post: 11-04-2008, 06:52 AM
  2. redirect console output to a String?
    By TwistedMetal in forum C Programming
    Replies: 10
    Last Post: 02-26-2008, 02:54 PM
  3. Help with Console output
    By JeremyCAFE in forum C++ Programming
    Replies: 4
    Last Post: 12-20-2005, 10:36 AM
  4. Replies: 4
    Last Post: 11-30-2005, 04:44 PM
  5. Redirecting console output
    By _hannes in forum Windows Programming
    Replies: 3
    Last Post: 11-04-2004, 04:51 AM