where command line arguments are stored?

前端 未结 4 1890
逝去的感伤
逝去的感伤 2021-01-13 16:29

I have a doubt @ the storage of command line arguments.

myprog.exe -cfgfile myconfig.cfg

commandline args are passed when process gets created so are they

4条回答
  •  不思量自难忘°
    2021-01-13 16:38

    It depends on the OS and possibly the language. A good C-centric answer is that the OS creates the process space (including loading the code, creating the heap and stack, etc). Then it puts the command line argument vector in a location, and then copies the address of the argument vector to 'argv' on the stack, and the count of words to 'argc'.

    Only after these tasks are done does the OS allow the process to execute.

提交回复
热议问题