-2

I want to run an .exe file from my c++ program. but I also want to pipe an input file and take output of that file into another file.

I know that this can be done from command line as:

c:> my_program.exe <"input.txt"> "output.txt"

with this command, my_program takes all standard input from input.txt and gives standard output to output.txt

Now I want this should happen from my C++ program. my my_program.exe is in D: drive. also input.txt is in D: drive.

Please tell me how can I accomplish my goal.

Balayesu Chilakalapudi
  • 1,386
  • 3
  • 19
  • 43
Bhavesh Munot
  • 675
  • 1
  • 6
  • 13

3 Answers3

0

You need to handle input and output pipes inside your c++ program, and read/write data to files accordingly. See MSDN for example.

Ryzhehvost
  • 395
  • 1
  • 9
0

The question was basically how to redirect stdin and stdout from the inside of C++, which as been answered here.

Community
  • 1
  • 1
DrakaSAN
  • 7,673
  • 7
  • 52
  • 94
-1

Just change your directory to D:

cd D:\

D:>my_program.exe <"input.txt">"output.txt"

sheu
  • 284
  • 5
  • 13
  • this is not what I want. I want a c++ program to do this. I dont want to do it manually. My C++ program should do it automatically – Bhavesh Munot Mar 20 '14 at 11:43