command line processing library - getopt

后端 未结 4 830
余生分开走
余生分开走 2021-01-05 15:42

Can someone help me with the getopt function?

When I do the following in main:

char *argv1[] = {\"testexec\",\"-?\"};
char *argv2[] = {\"testexec\",\         


        
4条回答
  •  被撕碎了的回忆
    2021-01-05 16:18

    As stated in the man page:

    "A program that scans multiple argument vectors, or rescans the same vector more than once, and wants to make use of GNU extensions such as '+' and '-' at the start of optstring, or changes the value of POSIXLY_CORRECT between scans, must reinitialize getopt() by resetting optind to 0, rather than the traditional value of 1. (Resetting to 0 forces the invocation of an internal initialization routine that rechecks POSIXLY_CORRECT and checks for GNU extensions in optstring.)"

提交回复
热议问题