C言語 main 関数の第三引数
概要
C言語の main 関数の第三引数を使えば環境変数を取得できる。参考 : C言語main関数の隠された第三引数に迫る!! | moge32の日常
コード main.c
#include <stdio.h> int main(int argc, char* argv[], char* evn[]) { int i = 0; for (i = 0; evn[i] != NULL; ++i) { printf("%s\n", evn[i]); } return (0); }
コマンドライン
ALLUSERSPROFILE=C:\ProgramData AMDAPPSDKROOT=C:\Program Files (x86)\AMD APP\ APPDATA=C:\Users\jskny\AppData\Roaming CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=SEKI-VAIO ComSpec=C:\Windows\system32\cmd.exe configsetroot=C:\Windows\ConfigSetRoot EMC_AUTOPLAY=C:\Program Files (x86)\Common Files\Roxio Shared\ FP_NO_HOST_CHECK=NO GPU_MAX_ALLOC_PERCENT=100 GPU_USE_SYNC_OBJECTS=1 GTK_BASEPATH=C:\Program Files (x86)\GtkSharp\2.12\ HerokuPath=C:\Program Files (x86)\Heroku HOMEDRIVE=C: HOMEPATH=\Users\jskny JAVA_HOME=C:\Program Files (x86)\Java\jdk1.6.0_30 LOCALAPPDATA=C:\Users\jskny\AppData\Local LOGONSERVER=\\SEKI-VAIO MSRKINECTSDK=C:\Program Files (x86)\Microsoft Research KinectSDK\ NUMBER_OF_PROCESSORS=4 OS=Windows_NT Path=C:\ProgramData\Oracle\Java\javapath;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\WIDCOMM\Bluetooth Software\;C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Justsystems\JSLIB32\;C:\Program Files (x86)\Sony\VAIO Startup Setting Tool;C:\Program Files (x86)\Common Files\Roxio Shared\10.0\DLLShared\;C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\NASM;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft Research KinectSDK\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files\Wireshark;C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\git\cmd;C:\Program Files (x86)\nodejs\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Haskell\bin;C:\Program Files\Haskell Platform\2014.2.0.0\lib\extralibs\bin;C:\Program Files\Haskell Platform\2014.2.0.0\bin;C:\Program Files\Haskell Platform\2014.2.0.0\mingw\bin;C:\bin;C:\Perl\bin;C:\bin\Python27;C:\bin\Python27\Scripts;C:\Program Files\SlikSvn\bin;C:\Program Files\TortoiseSVN\bin;C:\Users\jskny\AppData\Roaming\npm PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 42 Stepping 7, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=2a07 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PROMPT=$P$G PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ PUBLIC=C:\Users\Public RoxioCentral=C:\Program Files (x86)\Common Files\Roxio Shared\10.0\Roxio Central36\ SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\Windows TEMP=r:\TEMP TMP=r:\TEMP USERDOMAIN=******** USERNAME=jskny USERPROFILE=C:\Users\jskny VS100COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\ windir=C:\Windows XNAGSShared=C:\Program Files (x86)\Common Files\Microsoft Shared\XNA\