我的代码在这里给了我编译时错误-函数 InsertList 中的“取消引用指向不完整类型的指针”。我无法弄清楚为什么。我究竟做错了什么?
#include<stdio.h>
#include<stdlib.h>
struct ListNode;
struct ListNode{
int data;
struct ListNode* next;
};
void main(int argc,char* argv[]){
int p;
FILE *ptr;
FILE *out;
//ptr=fopen("C:\Users\dheeraj\Desktop\input.txt","r");
out=fopen("output.txt","w");
struct Listnode* head=0;
while(fscanf(ptr,"%d",&p) != EOF){
InsertList(head,p);
}
close(ptr);
}
void InsertList(struct Listnode** headref,int data)
{
struct Listnode* newNode= malloc(sizeof(struct ListNode));
if(newNode == 0)
printf("Memory error\n");
newNode->data=data;
newNode->next = (*headref);
(*headref )=newNode;
}