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 ?
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.
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 (*).
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.
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.
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)
;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With