在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;
}