I know that argv[0] represents the executable file name, but I don’t understand how it is implemented — how it gets the filename and options at the source code level. At first I thought it was dependent on built-in functions in linux, but then found out that windows also supports it, leading me to believe that it may be done by the compiler?
I know that argv[0] represents the executable file name, but I don’t understand how
Share
It’s actually part of the C99 standard, hence the same implementation across compilers and operating systems. From 5.1.2.2.1 Program startup (page 12):
Edit: Following up on Waleed Khan’s comment, you can retrieve these values via:
/proc/self/cmdline_NSGetArgc/_NSGetArgvor[NSProcessInfo arguments]GetCommandLine()withCommandLineToArgvW()