Reputation: 433
I tried to construct a function that has the reference as a parameter.
But the compile gave me a error warning, saying that expected')', I don't know what is the problem.
Can't we use reference as parameter in C?
The following is the code segment.
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;
}
Should I use a pointer instead of a reference as a parameter??
Upvotes: 0
Views: 38
Reputation: 223972
C doesn't have references. That's a C++ construct.
You'll need to change the function to accept a pointer.
int init_Queue(Queue *q)
{
printf("value=%d\n", q->value);
return 1;
}
Upvotes: 3