OverFlow 커뮤니티를 보다가 정말 괜찮은 소스가 있길래 옮겨둔다

FILE * fp = popen("ifconfig", "r");
            if (fp) {
                    char *p=NULL, *e; size_t n;
                    while ((getline(&p, &n, fp) > 0) && p) {
                       if (p = strstr(p, "inet addr:")) {
                            p+=10;
                            if (e = strchr(p, ' ')) {
                                 *e='\0';
                                 printf("%s\n", p);
                                 break;
                            }
                       }
                    }
            }
            pclose(fp);