Computing.Net > Forums > Programming > Display a system call in C++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Display a system call in C++

Reply to Message Icon

Name: hippiejoeland (by HippieJoeLand)
Date: July 15, 2004 at 20:35:38 Pacific
OS: windows
CPU/Ram: 933.256
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: July 15, 2004 at 21:04:28 Pacific
Reply:

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.



0

Response Number 2
Name: Birdman
Date: July 16, 2004 at 12:41:18 Pacific
Reply:

Why doesn't system("dir") work? Works for me...


0

Response Number 3
Name: egkenny
Date: July 16, 2004 at 14:04:23 Pacific
Reply:

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


0

Response Number 4
Name: Don Arnett
Date: July 16, 2004 at 18:17:59 Pacific
Reply:

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.


0

Response Number 5
Name: Birdman
Date: July 17, 2004 at 08:50:32 Pacific
Reply:

Oh ok I get it. Yeah then I guess you'd have to go to a file and then out. Thanks Don.


0

Related Posts

See More



Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Display a system call in C++

System call in C www.computing.net/answers/programming/system-call-in-c/661.html

Writing a safecopy file in C - HELP!!! www.computing.net/answers/programming/writing-a-safecopy-file-in-c-help/1114.html

System-pause - in c#? www.computing.net/answers/programming/systempause-in-c/10626.html