Code::Blocks的编译问题,大家帮忙看看,谢谢
程序代码:#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#define elemtype int
typedef struct qnode{
elemtype data;
struct qnode *next;
}qnode,*queueptr;
typedef struct{
queueptr front;
queueptr rear;
}linkqueue;
int initqueue(linkqueue &q)
{
q.front=q.rear=(queueptr)malloc(sizeof(qnode));
if(!q.front)
exit (0);
q.front->next=NULL;
return 1;
}
int enqueue(linkqueue &q,elemtype e)
{
queueptr p;
p=(queueptr)malloc(sizeof(qnode));
if(!p)
exit (0);
p->data=e;
p->next=NULL;
q.rear->next=p;
q.rear=p;
printf("调用函数 : %d\n",q.rear->data);
return 1;
}
int main(void)
{
linkqueue l;
int x;
initqueue(l);
printf("请输入元素 :");
scanf("%d",&x);
enqueue(l,x);
printf("主函数 : %d",l.rear->data);
}
大家好,我刚学了数据结构,自己写了一段实验一下,Code::Blocks 10.05带MinGW-4.4.1.
编译的时候出错了...说的是(int initqueue(linkqueue &q)和linkqueue enqueue(linkqueue &q,elemtype e))那两个引用符,可是如果去掉引用符的话,那就不能传递了,怎么办?
这段代码在CodeLite上编译成功MinGW-4.4.1,进队列也没问题...可就是CB下有问题,为什么会这样呢?大家帮忙看看,谢谢.
[ 本帖最后由 雾非雾 于 2011-11-17 12:41 编辑 ]






