Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Liquid Web Managed Dedicated Server: RAID 1 SSD with 16GB of RAM minimum! 24/7 On-Site Heroic Support! Industry-Leading SLA!

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Liquid Web Cloud VPS Hosting

8,357 questions

11,608 answers

573 users

How to read all the standard output from the process in C

1 Answer

0 votes
#include <stdio.h>

void print(FILE *fp)
{
    int c;
    while ((c = getc(fp)) != EOF)
        putchar(c);
}
int main(void)
{
    FILE *fp;

    if ((fp = popen("netstat", "r")) == NULL)
        return 1;
  
    print(fp);
    
    pclose(fp);
    
    return 0;
}
    
/*
run:
 

Active Connections

  Proto  Local Address          Foreign Address        State
  TCP    127.0.0.1:....         Avi-PC:.....           ESTABLISHED
  TCP    123.456.9.789:.....    fw-okpk123:https       ESTABLISHED
  TCP    123.456.9.789:.....    mmpb:imap              ESTABLISHED
  ...
  
*/

 




answered Aug 19, 2017 by avibootz
...