-
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.
-
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.
-
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
-
Sorry. I didnt reported I want a portable code. None of windows APIs plz.
Thanks!
-
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
-
Oh I see... posix
Thank you guys for the help!