MY PURPOSE: I want to make a c++ program that could use DOS commands.
OPTION: I can make a batch file and put into it the DOS commands. But I don\'t know how
//example that makes and then calls a batch file
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
ofstream batch;
batch.open("mybatchfile.bat", ios::out);
batch <<"@echo OFF\n";
batch <<":START\n";
batch <<"dir C:\n";
batch <<"myc++file 2 >nul\n";
batch <<"goto :eof\n";
batch.close();
if (argc == 2)
{
system("mybatchfiles.bat");
cout <<"Starting Batch File...\n";
}
}