I would like to how does C++ actually turn the command line arguments into a char array? What "secret" code does this? Where can I view the code that does this (even if it is in assembly, I know some assembly)? I am using Linux, if that helps.
Thank You
asked Jul 30 '26 23:07
In most (all?) Unix-based operating systems, they are already an array. It's how operating system executes a process there — when a process starts, there is already an array of arguments ready for it.
The code that turns command line into an array lives in a shell (like bash) or any other program that starts another program. bash has it's sources available, other programs — it's different.
In Windows, they are one string (which you can get unmodified using GetCommandLine() API call), which is parsed by C runtime library to turn it into an array, because the language specification requires them to come as an array.
For programs compiled with Visual C++, the code that does this is included into Visual Studio distributions. You may have to turn on a checkbox that says something like “Include C runtime library source” in installer in order to have it installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With