Page 1 of 1

Posted: 2006-12-12T15:46:07-07:00
by el_supremo
I think that system() just passes all its arguments to identify without interpreting ">out.txt" as redirection. You have to do the redirection yourself.
I don't know how you would do this in C++ but in C I did this with the freopen function:

Code: Select all

freopen("out.txt","w",stdout);
and then call "identify".

Pete

Posted: 2006-12-13T15:04:03-07:00
by el_supremo
Try adding "fclose(stdout);" after your system call.

Pete

Posted: 2006-12-20T15:28:21-07:00
by el_supremo
I was closing the file pointer returned by freopen

That's the correct thing to do. My brain obviously wasn't in gear when I wrote fclose(stdout)!. Sorry.

Pete