[問題] assignment from incompatible pointer
開發平台(Platform):
dev c++
問題(Question):
小弟嘗試利用linked list的方法寫stack但是編譯後出現
"warning: assignment from incompatible pointer type"
以下是部分程式碼
//宣告結點
struct n{
int data;
struct node *next;
};
//宣告top
struct n *top = NULL;
//push
void push(int in)
{
struct n *tmp;
tmp = (struct n *)malloc(sizeof(struct n));
tmp->data=in;
tmp->next=top;
top=tmp;
}
警告出現在 tmp->next=top這行
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.33.236.246
→
10/15 22:45, , 1F
10/15 22:45, 1F
→
10/15 22:48, , 2F
10/15 22:48, 2F
→
10/15 22:55, , 3F
10/15 22:55, 3F
→
10/15 22:56, , 4F
10/15 22:56, 4F
→
10/15 22:57, , 5F
10/15 22:57, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章