26.11.2013, 15:57. Просмотров 391. Ответов 1
Уважаемые форумчане, растолкуйте, пожалуйста, назначение третьего аргумента "char *const options" в функции GetOptList . Для чего он данном случае, ведь обычно третий аргумент - char *env[].
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| typedef struct option_t
{
char option;
char *argument;
int argIndex;
struct option_t *next;
} option_t;
option_t *GetOptList(const int argc, char *const argv[], char *const options)
{
int nextArg;
option_t *head, *tail;
int optIndex;
/* start with first argument and nothing found */
nextArg = 1;
head = NULL;
tail = NULL;
/* loop through all of the command line arguments */
while (nextArg < argc) // 1< argc
{
if ((strlen(argv[nextArg]) > 1) && ('-' == argv[nextArg][0]))
{
/* possible option */
optIndex = 0;
/* attempt to find a matching option */
while ((options[optIndex] != '\0') && (options[optIndex] != argv[nextArg][1]))
{
do
{
optIndex++;
}
while ((options[optIndex] != '\0') && (':' == options[optIndex]));
} |
|