![]() |
![]()
| ![]() |
![]()
̾??
?饤?֥???Standard C Library (libc, -lc) ????
????
???? optionp
?ϡ?ʸ?????ؤΥݥ????ؤ??ݥ??Ǥ???
???? tokens
?ϡ?ʸ?????ؤΥݥ??????ġ?
?ȡ??????η????? ``name=value'' ?Ǥ??????硢 valuep ?ǻ??Ȥ????????ϡ? ?ȡ??????? ``value'' ????ʬ????Ƭ???ؤ??褦?????ꤵ???ޤ???
??????char *tokens[] = { #define ONE 0 "one", #define TWO 1 "two", NULL }; ... extern char *optarg, *suboptarg; char *option, *value; while ((ch = getopt(argc, argv, "ab:")) != -1) { switch(ch) { case 'a': /* ``a'' ???ץ??????????? */ break; case 'b': option = optarg; while (*option) { switch(getsubopt(&option, tokens, &value)) { case ONE: /* ``one'' ???֥??ץ??????????? */ break; case TWO: /* ``two'' ???֥??ץ??????????? */ if (!value) error("no value for two"); i = atoi(value); break; case -1: if (suboptarg) error("illegal sub option %s", suboptarg); else error("missing sub option"); break; } break; } ??Ϣ????????
|