drkcore

2009/10/12 18:30:41

Unix/Linuxプログラミング理論と実践 9章 (環境)

環境はenvironが指す配列に格納されている。

環境変数一覧を出力してみる。

#include <stdio.h>
extern char **environ;

main()
{ 
  int i;

  for( i = 0 ; environ[i] ; i++ )
    printf("%s\n",environ[i]);
}

実行結果の一部。

EDITOR=/usr/bin/vim
LANG=ja_JP.utf-8
HISTCONTROL=ignoreboth
SHLVL=1

ProductName Unix/Linuxプログラミング理論と実践
Bruce Molay
アスキー・メディアワークス / ¥ 6,090 ()
在庫あり。

Comments