Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two asterisks before variable name

Tags:

c

While digging in some C source code I found that fragment of code

char  **words

I know that single asterisk before variable name "points" to pointer, but what is the purpose of those two asterisks ?

like image 318
jingo Avatar asked Sep 29 '11 10:09

jingo


People also ask

What does * mean in Python before a variable?

Practical Data Science using Python Single asterisk as used in function declaration allows variable number of arguments passed from calling environment. Inside the function it behaves as a tuple.

What does * mean before a variable in C?

In computer programming, a dereference operator, also known as an indirection operator, operates on a pointer variable. It returns the location value, or l-value in memory pointed to by the variable's value. In the C programming language, the deference operator is denoted with an asterisk (*).

What does asterisk before variable mean?

The asterisk symbol in C programming language is used as a pre-fix before a variable name to specify that the variable can store address reference of a memory location, i.e. asterix (variable name) makes the variable a pointer. An example: int a =10.

Why do we use * Before variable in C?

int variable1; int variable2; char variable3; int *addressOfVariables; * – A pointer variable is a special variable in the sense that it is used to store an address of another variable. To differentiate it from other variables that do not store an address, we use * as a symbol in the declaration.


1 Answers

It is a pointer to a pointer.

It is used primarily when you use an array of character strings.

For example: you have char sample[5][5]; - this can store 5 strings of length 4;

If you need to pass it to a function, func(sample);

And the function definition of such a function would be func(char **temp);

like image 63
Jan S Avatar answered Oct 20 '22 03:10

Jan S