Is there a way to execute a program and receive the console output in c++ instead of displaying the console window? I am trying to do a command line call but provide a GUI instead of the console output.
+1
A:
You can do this on most systems using popen (or on some compilers _popen). If that isn't versatile enough for your purposes, you'll probably have to do something platform specific (e.g., fork on a POSIX-like system, or CreateProcess on Windows).
Jerry Coffin
2010-06-29 15:44:39
A:
You can write stdout to a file instead, and display the file in your GUI. One method for doing that is freopen.
int main ()
{
freopen ("myfile.txt","w",stdout);
printf ("This sentence is redirected to a file.");
fclose (stdout);
return 0;
}
This redirects stdout to myfile.txt.
Stephen
2010-06-29 15:45:09