By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,982 Members | 1,738 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,982 IT Pros & Developers. It's quick & easy.

Where does the output of the function system("dir") in C go?

P: 1
hi. i tried to execute a simple system() in c with dir as its argument. can any1 please tell me where do i find the output of this command( i.e. dir) . system () just returns a 0 or a -1. but how to get the output of the dir command from this function...??

thanx in advance.
Dec 13 '10 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 2,398
The output goes to the same place it would have gone had you simply typed "dir" at the command prompt. I'm not sure of the details -- whether it goes to stdout [which might have been redirected when you ran your program] or if it goes unconditionally to the console.

If you want your program to see the results of the "dir" command then you should explicitly redirect its output to a file which your program can then parse:
Expand|Select|Wrap|Line Numbers
  1. system("dir > file.txt");
Dec 13 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.