C++’s popen() returns a file descriptor that contains the output, after executing a process. Instead of a FILE*, I need a char*, ie. a string to be my output. What do I do? Please help me.
C++’s popen() returns a file descriptor that contains the output, after executing a process.
Share
I suppose I’d do something on this general order:
If you want to get more elaborate, you could allocate space dynamically, and attempt to increase it as necessary to hold the amount of output you get. That would be a better route unless you have at least some idea of how much output the child might produce.
Edit: Given that you’re using C++, a result with dynamic size is actually pretty easy: