How to pass command line arguments to a c program

前端 未结 4 1623
无人共我
无人共我 2020-12-05 11:02

I\'ve known how to write a program that accepts command line arguments ever since I learned to program. What I don\'t understand is how these parameters get their v

4条回答
  •  旧巷少年郎
    2020-12-05 11:39

    In a Windows environment you just pass them on the command line like so:

    myProgram.exe arg1 arg2 arg3
    

    argv[1] contain arg1 etc

    The main function would be the following:

    int main (int argc, char *argv[])
    

提交回复
热议问题