#include <stdio.h>

void print_all(FILE *stream)
    int c;
    while ((c = getc(stream)) != EOF)
int main(void)
    FILE *stream;

    /* call netstat command. netstat is available for Windows and Linux */
    if ((stream = popen("netstat", "r")) == NULL)
        return 1;
    return 0;

This program runs a process ([netstat](<http://man7.org/linux/man-pages/man8/netstat.8.html>)) via [popen()](<http://pubs.opengroup.org/onlinepubs/9699919799/functions/popen.html>) and reads all the standard output from the process and echoes that to standard output.

Note: popen() does not exist in the standard C library, but it is rather a part of POSIX C)