C语言中的popen()函数

#include <stdlib.h>  
#include <stdio.h>  
  
#define BUF_SIZE 1024  
char buf[BUF_SIZE];  
  
int main(void)  
{  
    FILE * p_file = NULL;  
  
    p_file = popen("ifconfig eth0", "r");  
    if (!p_file) {  
        fprintf(stderr, "Erro to popen");  
    }  
  
    while (fgets(buf, BUF_SIZE, p_file) != NULL) {  
        fprintf(stdout, "%s", buf);  
    }  
    pclose(p_file);     
  
    return 0;  
}  

输出结果:
Referenced from:https://blog.csdn.net/yzy1103203312/article/details/78483566

本文链接地址:https://const.net.cn/622.html

标签: none

添加新评论