Naz
Naz

Reputation: 67

Passing arguments in C

Look at this method:

void* matmult (void*)

What does (void*) mean? I know that the function returns a pointer that points to any data type. But what is this argument being passed? How come there is no argument name being passed?

Upvotes: 3

Views: 256

Answers (2)

pohsyb
pohsyb

Reputation: 206

Also sometimes you will see something like:

void* foo(void);

In that case the function is explicitly declaring that it takes no parameters. Why would you do that instead of just leaving out parameters? Absence of parameters, for historical reasons, actually means one void* or int* parameter.

void* foo();

// ... later
foo(x);

That will work and compile, but its unclear that that the variable passed in was not intended.

Upvotes: 2

Heisenbug
Heisenbug

Reputation: 39164

The variable name in C prototype function isn't mandatory.

Upvotes: 14

Related Questions