I am trying to write a program that goes system("dir"); the copies the results onto a text file. However I dont know how to get the results of system("dir"); to the text file. I am very new to c++ so any help would be appreciated.

Recommended Answers

All 2 Replies

The easiest solution is to use redirection straight from the command string:

std::system ( "dir > test.txt" );

thanks that works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.