Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What does ** mean in C?

Status
Not open for further replies.

trivektor

Technical User
Oct 16, 2006
1
CA
Hi,

Can anyone please tell me what this means in C?

char **argv

Why are there ** there? What are they used for? Thanks.
 
It's like this...
Code:
char    c;    /* c is a character */
char  * pc;   /* pc is a pointer to a character */
char ** ppc;  /* ppc is a pointer to a pointer to a character */

/* and the following are equivalent */

char ** argv;
char * argv[];
char argv[][];
 
Warning - illegal declarator:
Code:
char argv[][];
C and C++ declarations pattern:
type_name list_of_declarators;
char **argv - (**argv) is a declarator. Suppose we have **argv in an expression. An asterisk sign denotes unary dereferencing operator in this context. So we have:
(*(*argv)) expression. Well, argv must be a pointer (only a pointer is a legal operand of unary * operator). Now *argv returns a pointer (for the second * operator). We have a pointer to a pointer. Look at the char type: argv must be pointer to pointer to char...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top