Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要将 shell 脚本输出收集到我的 c 程序链表节点中,我也尝试过 popen()。但是那里发生类型转换错误。我的项目中需要这个。请帮忙......
你尝试了popen什么?这按预期工作:
popen
#include <stdio.h> int main(void) { char buf[BUFSIZ]; FILE *fp = popen("sh script", "r"); while (fgets(buf, sizeof buf, fp) != NULL) printf("Received: '%s'\n", buf); pclose(fp); return 0; }