Lỗi: [Warning] passing argument 1 of 'linked' makes integer from pointer without a cast

Em đang học linked list bằng c thì gặp lỗi như thế này

đây là code của em ạ

#include<stdio.h>
#include <stdlib.h>

struct node
{
int data;
struct node* next;
};

typedef struct node node;

node* create(int n){
node *p = (node*)malloc(sizeof (node));
p->data = n;
p->next = NULL;
return p;
}

node *linked(int n, node *p){
node *t = create(n);
if (p->next == NULL){
	    p->next = t;
	    printf("%d\n", p->data);
	} 
	else{
		while (p->next!=NULL)
			p = p->next;
		p->next = t;
	}	
return t;
}


void in(int n, node *p){
node *t = p;
while (t != NULL){
  		printf("%d ", t->data);
    t = t->next;
}
}

int main(){
int n, temp;
scanf("%d", &n);
node *p;
for (int i=0; i<n; ++i){
    scanf("%d", &temp);
    p = linked(p, temp);
    
}
in(n,p);
}

Em không biết nên sửa thế nào và tại sao nó lại báo lỗi, mọi người chỉ giúp em với ạ, em cảm ơn!

Do gọi nhầm tham số ấy :smiley:

Nói chung luôn để chủ thể là tham số đầu tiên.

3 Likes

Khai báo (int, node*), lúc gọi thì lại là (node*, int).
Hàm nào thì thông báo lỗi đã nhắc đến, rất dễ sửa.

2 Likes

Dạ cảm ơn mọi người em sửa được rồi ạ ;;v;; em cứ thấy thông báo lạ lạ không để ý nó sai ở đấy

83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?