FrontPage > C/C++ > popen

popen

説明

C言語から、他のアプリケーションを実行します。
UNIXの場合は、実行モードが必要。
pipeストリームのオープン処理。

インクルード

#include <stdio.h>

書式

FILE *popen(const char *command, const char *mode);

サンプル

#include	<stdio.h>

main(){

    FILE *fp = NULL;
    char file[128];

    /* オープン */
    fp = popen ("ls -1", "r");

    while (!feof(fp)) {
        memset (file, 0x00, sizeof(file));
        /* 読み込み */
        fscanf (fp, "%s", file);
        printf ("%s\n", file);
    }

    /* クローズ */
    pclose (fp);

}

関連項目


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2008-08-24 (日) 16:20:55