Handling command line flags in C/C++

前端 未结 7 865
星月不相逢
星月不相逢 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:39

    The easiest thing is to write your main() like so:

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

    Then inside that main you decide what happens to the command line arguments or "flags". You find them in argv and their number is argc.

    0 讨论(0)
提交回复
热议问题