Varaquilex
Varaquilex

Reputation: 3463

Empty file output from calling external program with output redirection in C++

From C++ source, I execute the following line:

system("../BWAPI/ITUBot/Clingo/clingo.exe bwapi-data/AI/ITUBotWall.txt > bwapi-data/AI/solver-out.txt");

This line causes an empty solver-out.txt to be created. If I execute the same command using command line from outside the C++ program, the output file is successfully created with relevant contents.

The ITUBotWall.txt is created just before this command. Would this be relevant to the issue?

What would the reason be behind this? What am I missing and how can I solve this?

Upvotes: 0

Views: 294

Answers (2)

ilkerulusoy
ilkerulusoy

Reputation: 118

You should make all paths absolute.

Upvotes: 1

Anmol Singh Jaggi
Anmol Singh Jaggi

Reputation: 8576

Try this -:
system("../BWAPI/ITUBot/Clingo/clingo.exe < bwapi-data/AI/ITUBotWall.txt > bwapi-data/AI/solver-out.txt");

Upvotes: 2

Related Questions