get text from screen

This is a discussion on get text from screen within the C Programming forums, part of the General Programming Boards category; How do I "read" some text on console? example: Code: system("program.exe"); then the program.exe i called from my code, puts ...

  1. #1
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52

    get text from screen

    How do I "read" some text on console?
    example:
    Code:
    system("program.exe");
    then the program.exe i called from my code, puts some output string on the screen and I'd like to get that output message.
    I could call the program from my code this way:
    Code:
    system("program.exe > output.txt");
    then I could open the file and read the contents. But I'd like to know if there is a more convenient way to do that.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Thats compile dependant (at least the more convient ways are)

    You might see if you have pipes available, in the form of popen() or _popen().

    Try this too.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,651
    Using a pipe may be more convenient:
    Code:
    system("program.exe | myprog.exe");
    This will send stdout of program.exe to stdin of myprog.exe

    Or there's the not as convenient Win32 API method.

    gg

  4. #4
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52
    Sorry. I didnt reported I want a portable code. None of windows APIs plz.
    Thanks!

  5. #5
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,651
    The system() function call is POSIX and a POSIX compliant shell will support pipelines ("command1 | command2") - if you're looking for convenience and portability.

    gg

  6. #6
    ipe
    ipe is offline
    Registered User
    Join Date
    Jan 2003
    Posts
    52
    Oh I see... posix
    Thank you guys for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  2. mygets
    By Dave_Sinkula in forum C Programming
    Replies: 6
    Last Post: 03-23-2003, 06:23 PM
  3. question about printing on screen and not overwriting text...
    By revelation437 in forum C Programming
    Replies: 2
    Last Post: 12-14-2002, 01:48 PM
  4. Text on Graphics screen
    By bob5845 in forum C++ Programming
    Replies: 4
    Last Post: 04-03-2002, 08:08 PM
  5. Validating the contents of a char buffer
    By mattz in forum C Programming
    Replies: 3
    Last Post: 12-09-2001, 05:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21