SNODE *listinsert(SNODE *head,int i) //将学生插入到班级Li_head的第i个位置。
{
int m=0;
struct snode *newp;
struct snode *p,*q;
if(i<=0){
printf("插入值不正确,请重新插入!\n");
return head;
}
if(newp==NULL)
{
printf("内存动态空间用完,无法插入!\n");
return head;
}
newp=malloc(sizeof(struct snode));
这里的malloc()函数的返回值类型是void *,但是newp的类型是struct snode *,需要对malloc()函数的返回值进行强制类型转换:
newp = (struct snode *)malloc(sizoef(struct snode));