Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the function of an asterisk before a function name?

I've been confused with what I see on most C programs that has unfamiliar function declaration for me.

void *func_name(void *param){     ... } 

What does * imply for the function? My understanding about (*) in a variable type is that it creates a pointer to another variable thus it can be able to track what address at which the latter variable is stored in the memory. But in this case of a function, I don't know what this * asterisk implies.

like image 636
Aldee Avatar asked Jan 18 '12 13:01

Aldee


People also ask

What is the function of asterisk?

The asterisk is a commonly used wildcard symbol that broadens a search by finding words that start with the same letters. Use it with distinctive word stems to retrieve variations of a term with less typing.

What does * Before variable mean 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 is an operator in Python that is commonly known as the multiplication symbol when used between two numbers ( 2 * 3 will produce 6 ) but when it is inserted at the beginning of a variable, such as an iterable, like a list or dictionary, it expands the contents of that variable.

Why do we use * Before variable in C?

While * means the address of a variable in C programming language, what does ** mean then? Actually, & means the address of a variable. * means the value at an address, which also known as dereferencing. In that sense, ** just is dereferencing twice.


1 Answers

The asterisk belongs to the return type, and not to the function name, i.e.:

void* func_name(void *param) { . . . . . } 

It means that the function returns a void pointer.

like image 128
NPE Avatar answered Sep 20 '22 23:09

NPE