How do I read the results of a system() call in C++?

后端 未结 9 931
醉梦人生
醉梦人生 2020-12-17 06:44

I\'m using the following code to try to read the results of a df command in Linux using popen.

#include  // file an         


        
9条回答
  •  情歌与酒
    2020-12-17 07:36

    To answer the question in the update:

    char buffer[1024];
    char * line = NULL;
    while ((line = fgets(buffer, sizeof buffer, fp)) != NULL) {
        // parse one line of df's output here.
    }
    

    Would this be enough?

提交回复
热议问题