Handling command line flags in C/C++

前端 未结 7 883
星月不相逢
星月不相逢 2020-12-14 21:03

I am looking for a very simple explanation/tutorial on what flags are. I understand that flags work indicate a command what to do. For example:

rm -Rf test
<         


        
7条回答
  •  被撕碎了的回忆
    2020-12-14 21:36

    In your own C program you can process command line options in any way you see fit. Command line parameters in C come in the parameters of the main(int argc, char *argv[]) method as strings.

    And if you'd like to process command line parameters in a way similar to most UNIX commands, the function you're probably looking for is getopt()

    Good luck!

提交回复
热议问题