getoptlong


 
Thread Tools Search this Thread
Top Forums Programming getoptlong
# 1  
Old 07-15-2008
Question getoptlong

Hi...,
I am using the getoptlong() function to handle the options.
For some options I am having the long option and for some other I don't want the long option.
So, what I have to specify in the place of long option field when declaring the longopt array.
# 2  
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}
              };

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question