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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhinav chouras
    New Member
    • Dec 2010
    • 1

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

    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.
  • donbock
    Recognized Expert Top Contributor
    • Mar 2008
    • 2427

    #2
    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:
    Code:
    system("dir > file.txt");

    Comment

    Working...