开发者

error after compilation in C

开发者 https://www.devze.com 2023-02-15 18:39 出处:网络
if ((pos < n) && (key == ptr->keys[pos].value)) { struct return_values* function(&ptr->keys[pos]);
if ((pos < n) && (key == ptr->keys[pos].value))
  {
    struct return_values* function(&ptr->keys[pos]);
  }

while compilation i get the error

 error: syntax error before '&' token in this line 
 struct return_values* function(&ptr->key开发者_如何学编程s[pos]);

i am passing the address of ptr->keys[pos] to the function

struct return_values* function(struct classifier fun_ptr)

where struct return_values is the return type what is the error here h


You need to assign the result of functon to a variable:

struct return_values* values = function(&ptr->keys[pos]);


If you are calling function from there, you don't need to write "struct return_values*" part.


Change

struct return_values* function(struct classifier fun_ptr)

to

struct return_values* function(struct classifier *fun_ptr)

0

精彩评论

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