开发者

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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜