분류 | 게시판 |
베스트 |
|
유머 |
|
이야기 |
|
이슈 |
|
생활 |
|
취미 |
|
학술 |
|
방송연예 |
|
방송프로그램 |
|
디지털 |
|
스포츠 |
|
야구팀 |
|
게임1 |
|
게임2 |
|
기타 |
|
운영 |
|
임시게시판 |
|
#define MALLOC(p,s) \
if(!((p)=malloc(s))) {\
mem_error=1;\
return;\
}
#define MALLOC2(p,s,r) \
if(!((p)=malloc(s))) {\
mem_error=1;\
return (r);\
}
이렇게 MALLOC 매크로를 지정하고나서
void enqueue(Node item) //Node는 구조체입니다.
{
queuePointer temp = 0;
MALLOC(temp, sizeof(temp*)); ----------------------->> 요기
temp->data=item;
temp->link=NULL;
if(front!=NULL)
{
rear->link=temp;
rear=temp;
}
else
{
front=temp;
rear=temp;
}
}
Node dequeue()
{
Node temp_node;
if(front!=NULL)
{
queuePointer temp;
temp_node=front->data;
MALLOC2(temp, sizeof(temp*), temp_node); ------------>>요기
temp=front;
front=front->link;
free(temp);
return temp_node;
}
else
printf("The Queue is Empty\n");
}
죄송합니다. 댓글 작성은 회원만 가능합니다.