Skip to content
Advertisement

Redirect stdout to a external program in C/C++

I have a program called capture that reads the webcam data and output to the avconv program.

JavaScript

Now I have to output to avconv inside my C program.

So, instead of output to the stoud:

JavaScript

I need to do do something like that:

JavaScript

How can I do that?

Advertisement

Answer

You can use popen() for this purpose.

JavaScript

then use fwrite() to write.

PS: Actually, this method is not redirecting stdout of your c program but it is using pipe stream concept to provide input to avconv from your code.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement