Passing Arguments in C

Take a look at this method:

void* matmult (void*)

What does it mean (void*)? I know that a function returns a pointer pointing to any data type. But what is passed to this argument? Why is the argument name not passed?

+3
source share
2 answers

The variable name in the C prototype function is optional.

+14
source

Also sometimes you will see something like:

void* foo(void);

In this case, the function explicitly declares that it does not accept parameters. Why would you do this and not just leave the options? The lack of parameters for historical reasons actually means a single parameter void * or int *.

void* foo();

// ... later
foo(x);

This will work and compile, but it is not clear that the variable passed into it was not intended.

+2
source

All Articles