Sponsored Content
Full Discussion: getoptlong
Top Forums Programming getoptlong Post 302215061 by jim mcnamara on Tuesday 15th of July 2008 12:27:58 PM
Old 07-15-2008
try this for unambiguous option letters and getopt_long:
Code:
static struct option long_options[] = {
                  {"add", 1, 0, 0},
                  {"append", 0, 0, 0},
                  {"d", 1, 0, 0},
                  {"v", 0, 0, 0},
                  {"create", 1, 0, 'c'},
                  {"file", 1, 0, 0},
                  {0, 0, 0, 0}
              };

getopt_long_only() will handle finding "-a" versus "-append" (ambiguous options ) in the example below
NOTE: ONLY when the command line has -a for an option.
Code:
static struct option long_options[] = {
                  {"a", 1, 0, 0},
                  {"append", 0, 0, 0},
                  {"delete", 1, 0, 0},
                  {"verbose", 0, 0, 0},
                  {"create", 1, 0, 'c'},
                  {"file", 1, 0, 0},
                  {0, 0, 0, 0}
              };

 
All times are GMT -4. The time now is 09:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy