How to redirect the output of system() to a file?

后端 未结 4 1295
忘了有多久
忘了有多久 2021-01-02 21:34

In this C program

#include 
#include 
int main()
{
    int file = open(\"Result\", O_CREAT|O_WRONLY, S_IRWXU);

         


        
4条回答
  •  悲哀的现实
    2021-01-02 22:36

    You should use the popen() library function and read chunks of data from the returned FILE * and write them to whatever output file you like.

    Reference.

提交回复
热议问题