Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C中传递对函数的引用_C_Parameters_Reference - Fatal编程技术网

在C中传递对函数的引用

在C中传递对函数的引用,c,parameters,reference,C,Parameters,Reference,我试图构造一个以引用作为参数的函数 但是编译程序给了我一个错误警告,说“预期'”,我不知道问题出在哪里 我们不能在C中使用引用作为参数吗? 下面是代码段 typedef struct Qnode{ struct Qnode* first; struct Qnode* rear; int value; }Queue; int init_Queue(Queue &q) //expected')' as the compiler warned me. {

我试图构造一个以引用作为参数的函数

但是编译程序给了我一个错误警告,说“预期'”,我不知道问题出在哪里
我们不能在C中使用引用作为参数吗?
下面是代码段

typedef struct Qnode{
    struct Qnode* first;
    struct Qnode* rear;
    int value;
}Queue;

int init_Queue(Queue &q)  //expected')'  as the compiler warned me.
{
    return 1;
}

我是否应该使用指针而不是引用作为参数???

C没有引用。这是一个C++构造。< /P> 您需要更改函数以接受指针

int init_Queue(Queue *q)
{
    printf("value=%d\n", q->value);
    return 1;
}

C没有引用。这是一个C++构造。< /P> 您需要更改函数以接受指针

int init_Queue(Queue *q)
{
    printf("value=%d\n", q->value);
    return 1;
}