hey everyone
i am making a test program, and i was wondering, if i was to call system("dir"); (on windows), how would i capture the output, and put it in a string, or something to display in my c program.
thanks
hey everyone
i am making a test program, and i was wondering, if i was to call system("dir"); (on windows), how would i capture the output, and put it in a string, or something to display in my c program.
thanks
Well I wouldn't advise using system() but:
system ("dir >temp.txt") would reidrect the output from dir to a file called temp.txt
From there you could open the file and parse your little heart aawy
thats a good idea.. what would u advise instead of using system?
search the board for the reason why you shouldn't use system()
A better function to use might be popen(), which would send the output from the dir command directly to your program.
If you understand what you're doing, you're not learning anything.
okay, thanks itsme
ok ill look and see what i can find.Originally Posted by Thantos
hmm, popen is a unix function.. is there a windows equivalent?
You can look here for some basic technique for running another program, then figure out how to capture the output.
http://faq.cprogramming.com/cgi-bin/...&id=1043284392
Help populate a c/c++ help irc channel
server: irc://irc.efnet.net
channel: #c