system(NULL) is returning 1! Great. What could possibly be wrong with
the installation?
Sorry I’ve made a horrible error, returning 1 is correct.
Ah, okay. That’s a load off my mind.
Seems the output redirect “>” in my system() command is what’s causing
the trouble. I need the output redirected to a file, or redirected to
the program’s stdin. I guess this is more of a generic C/C++ question…
system(NULL) is returning 1! Great. What could possibly be wrong with
the installation?
Sorry I’ve made a horrible error, returning 1 is correct.
RS > Ah, okay. That’s a load off my mind.
RS > Seems the output redirect “>” in my system() command is what’s causing
RS > the trouble. I need the output redirected to a file, or redirected to
RS > the program’s stdin. I guess this is more of a generic C/C++ question…
but this is probably a bit dodgy since the thing you are treating as an
ifstream is a pipe and so doesn’t really have file semantics.
In any case if you are using Dinkum (or worry about standards conformance)
it looks like you are SOL since there is no ifstream(fd) constructor. I
guess you could write your own iostream-derived class to handle it (which
is actually easier than it sounds).
Or if you don’t need cin elsewhere in your program the following kludge
should work to “tie” cin to your pipe:
close(fileno(stdin));
FILE *fp = popen(…); // Will use first unused fd ie 0=stdin=cin
// cin is now connected to your pipe, you can just do
cin.get_line();