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.
シェル スクリプトの出力を 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; }