Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
is there a way to in c++ call other system functions within the program, and display the results to the screen as output?
for example:
system("dir c:\ /w");i know that doesn't work, but hopefully you see what i would like to do. also, one more step. would redirects, and pipes and switches work in the system call as well. could i redirect that dir output to a file like
system(dir c:\ /w > d:\dirlistc.txt);
i guess basically, can you run fully functional dos commands within a c++ program, and get the same result as if you had manually entered it from the cmd? thanks and take care.
hippiejoe

The only way that I know of is what you've started to look at, redirect the output to a file and then read and display the file contents.

This program works in VC++6.0:
#include <process.h>
void main()
{
system("dir c:\ /w > d:\myfiles2.txt");
}

bird - he didn't say that it didn't work, he said that he can't see the output.
I supposed if you are writing a console type program that has stdout, you'll see it, but if you are writing a windows program that doesn't have stdout, you won't see the output from the dir command.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |