popen实际上就是执行CMD命令,然后将CMD命令内容写入到buffer里面。pclose对应popen,要关掉。
/* Run DIR so that it writes its output to a pipe. Open this * pipe with read text attribute so that we can read it * like a text file. */
if ((pPipe = _popen("dir *.c /on /p", "rt")) == NULL) exit(1);