I'm writing a simple code editor for the LC3 assembly language, and I've run into a small problem. LC3 assembler outputs basic information about the status of assembling which I'm trying to display in my program after reading it back from the log file.
Originally I attempted to use system() to call the LC3 assembler and redirect the stdout and stderr to a file, like so:
system("/pathto/lc3as 1> lc3.log 2>&1");
It outputs to the file but doesn't preserve the order of the output from the assembler.
I have come up with an ugly work around that preserves the order of the output but involves a lot more file IO than I'd like, and I'm not sure if it would work in every situation. On that note, I'm wondering if there is a better solution for routing the output to my program that preserves the order.