tags:

views:

36

answers:

1

I have a console application written in c++. It simply reads an integer from standard input(keyboard) and writes another integer to standard output(screen). Now I want to give some tests to that program and check its answers using another program. In another words, I want to write electron judge for that program. I want that program(which I want to test) to read from file and write to file without changing source code. How can I do that. I tried assigning input&output to files before executing c++ program, but it did not worked.

assign(input,'temp.in');
reset(input);
assign(output,'temp.out');
rewrite(output);
exec('domino.exe');
close(input);
close(output);
A: 

A simple solution is to redirect standard input and output when running your program from your shell, like this:

./someProgram < inputFile.txt > outputFile.txt

The < precedes the input file, and the > precedes the output file.

Mike Daniels
problem is, I am using windows
Azad Salahli
It works in a `cmd` shell, too: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
Mike Daniels
Thank you very much. It helped me very much.
Azad Salahli