单项选择题要实现通用队列,设计queue,定义类型为:typedef struct{void *buf;int front,rear;int max;int size;}queue;其中,buf为队列的首地址,front指向队头,rear指向对尾,max为队列容量,size为队列元素所占字节数。元素出队列的函数void out(queue *q ,void *val)的代码为()。
A.void *addr =(char *)q->buf +q->rear *q->size;memcpy(addr,val,q->size);q->rear++;
B.void *addr =(char *)q->buf +q->rear *q->size;memcpy(val,addr,q->size);q->rear++;
C.void *addr =(char *)q->buf +q->front *q->size;memcpy(addr,val,q->size);q->front++;
D.void *addr =(char *)q->buf +q->front *q->size;memcpy(val,addr,q->size);q->front++;