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

后端 未结 9 927
醉梦人生
醉梦人生 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:24

    check your bufSize. ftell can return -1 on error, and this can lead to nonallocation by malloc with buffer having a NULL value.

    The reason for the ftell to fail is, because of the popen. You cant search pipes.

提交回复
热议问题