Re: what is the meaning of "char **option"?
- From: "Nick Keighley" <nick_keighley_nospam@xxxxxxxxxxx>
- Date: 16 Oct 2006 05:14:00 -0700
Omats.Z wrote:
what is meaning os "char **option meet"?
I get a function like this:
__________________________________
int getchoice(char *greet, char *choices[])
{
int chosen = 0;
int selected;
char **option; // what is this line mean?
ptr-to-ptr-to-char
a pointer is typically implemented as an address so option will contain
the
address of a location that holds the address of a location of a char.
option is of type char**
*option is of type char* (ptr-to-char)
**option is of type char
do {
printf("Choice: %s\n", greet);
option = choices;
option now points at choices
while (*option) {
*option points to the first entry of the choices array, the loop
continues so
long as the entry is not NULL
printf("%s\n", *option);
option++;
this advances to the next entry in the array
}
selected = getchar();
option = choices;
while (*option) {
if (selected == *option[0]) {
chosen = 1;
break;
}
}
if (!chosen) {
printf("Incorrect choice, select again\n");
}
} while (!chosen);
return selected;
}
__________________________________
I know "char *option" is a pointer. But what is the ** mean? If i
delete one *, this function can't be compiled!
PS: i compile it by GCC 4 on ArchLinux
a good text book should explain all this
--
Nick Keighley
.
- References:
- what is the meaning of "char **option"?
- From: Omats.Z
- what is the meaning of "char **option"?
- Prev by Date: Re: Efficiency of the for loop
- Next by Date: Re: Efficiency of the for loop
- Previous by thread: what is the meaning of "char **option"?
- Next by thread: Re: what is the meaning of "char **option"?
- Index(es):
Relevant Pages
|