Hi
are you looking for something like this ?
Code:
const char *s_option="hi:n:p:v";
const struct option l_option[]={
{ "help", 0, NULL, 'h'},
{ "ip", 1, NULL, 'i'},
{ "nm", 1, NULL, 'n'},
{ "port", 1, NULL, 'p'},
{ "version", 0, NULL, 'v'},
};
// Now, looking for the supplied arguments and options
do {
n_opt=getopt_long(argc,argv,s_option,l_option,NULL);
switch(n_opt){
case 'h':
case '?':
usage(argv[0],0);
break;
case 'i':
printf("i\n%s\n",optarg);
break;
case 'n':
printf("n\n%s\n",optarg);
break;
case 'p':
printf("p\n%s\n",optarg);
break;
case 'v':
printf(" %s version %s\n",argv[0],VERSION_INFO); exit(0);
case -1:
break;
default:
abort();
} /* switch */
} while (n_opt!=-1);
a small modified part from one of my codes...