using linux command inside C++ code

Hello everyone

I need some help regarding using linux command inside C++ code instead of writing those commands on the screen each time I run the program.Someone from this forum suggested me this example "http://www.cplusplus.com/reference/iostream/ios/rdbuf/" which I found it easier and it worked as well but not when I tried to use it with the output of this command

system("diff /home/test1.txt /home/test2.txt");

Does anyone have any idea why? it still prints the output on to the screen and not to a file.
what is the command you are trying to execute and put the code so that we can get some idea?
diff /home/test1.txt /home/test2.txt


Reason being above Linux command will print onto screen. You want print to file then you should do something like below

diff /home/test1.txt /home/test2.txt > difference.txt

difference.txt will then contain the results of the diff command.
Topic archived. No new replies allowed.