I have a program that gathers data from a machine and outputs it to the command line from which it is called. I would like to write a program that calls the other program, reads its output, and writes that to a file. Here's an example of the output from the program:
Polling slave ...
[123]: 112
[124]: 101
[125]: 96
[126]: 101
[127]: 187
[128]: 194
[129]: 171
[130]: 177
[131]: -80
[132]: 0
[133]: 0
[134]: 69
[135]: 0
[136]: 1016
[137]: 0
[138]: 2555
[139]: 0
[140]: 2437
[141]: 108
So I know I can use system() to call the program, but that only returns an integer when I need all that garbage above. Could someone point me in the right direction?