( C/C++ の場合) #include <stdlib.h> char *getenv(const char *name) name : 環境変数の名前 ( Java の場合: System クラスの static メソッド) String getProperty(String name)
#include <stdio.h>
#include <stdlib.h>
int main()
{
int sw;
char *str;
sw = putenv("BAS=c:\\basic");
str = getenv("BAS");
printf("sw %d 環境変数 BAS の値は %s\n", sw, str);
return 0;
}
(出力)
sw 0 環境変数 BAS の値は c:\basic
import java.io.*;
public class Test {
public static void main(String args[]) throws IOException
{
String sw, str;
sw = System.setProperty("BAS", "c:\\basic");
str = System.getProperty("BAS");
System.out.println("sw " + sw + " 環境変数 BAS の値は " + str);
}
}
(出力)
sw null 環境変数 BAS の値は c:\basic
| ホームページ | 目次 | 演習解答例目次 | 付録目次 | 索引 |