森侃 2022-10-02 21:59 采纳率: 60%
浏览 35
已结题

不懂警告怎么消除 ,初学者


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

typedef struct LinkNode
{
    int data;
    struct linknode *prev,*next;
}Node,*List;
List Createlist(int n)
{
    List head=(List)malloc(sizeof(Node));
    Node* p;
    Node* q;
    int a;
    p=head;
    for(int i=0; i<n; i++)
    {
        q=(List)malloc(sizeof(Node));
        scanf("%d",&a);
        p->next=q;
        q->prev=p;
        q->data=a;
        p=q;
    }
    p->next=NULL;
    head=head->next;
    head->prev=NULL;
    return head;
}

void Delete_x(List L,int n,int x)
{
    Node* p=L;
    Node* r=L;
    Node* q=L;
    for(int i=0;i<n;i++)
    {
        if(L->data==x)
        {
            r=p->next;
            r->prev=NULL;
            L=r;
        }
        else if(p->data==x&&p->next!=NULL)
        {
            q=p->prev;
            r=p->next;
            q->next=r;
            r->prev=q;
        }
        if(p->data==x&&p->next==NULL)
        {
            q=p->prev;
            q->next=NULL;
        }
        p=p->next;
    }
    while(L)
    {
        printf("%d ",L->data);
        L=L->next;
    }
}
int main(void)
{
    int n;
    scanf("%d",&n);
    List L=Createlist(n);
    int x;
    scanf("%d",&x);
    Delete_x(L,n,x);
    return 0;
}

main.c: In function 'Createlist': main.c:20:16: warning: assignment from incompatible pointer type [enabled by default] p->next=q; ^ main.c:21:16: warning: assignment from incompatible pointer type [enabled by default] q->prev=p; ^ main.c:28:6: warning: assignment from incompatible pointer type [enabled by default] p=p->next; ^ main.c: In function 'Delete_x': main.c:43:14: warning: assignment from incompatible pointer type [enabled by default] r=p->next; ^ main.c:49:14: warning: assignment from incompatible pointer type [enabled by default] q=p->prev; ^ main.c:50:14: warning: assignment from incompatible pointer type [enabled by default] r=p->next; ^ main.c:51:20: warning: assignment from incompatible pointer type [enabled by default] q->next=r; ^ main.c:52:20: warning: assignment from incompatible pointer type [enabled by default] r->prev=q; ^ main.c:56:14: warning: assignment from incompatible pointer type [enabled by default] q=p->prev; ^ main.c:59:10: warning: assignment from incompatible pointer type [enabled by default] p=p->next; ^ main.c:64:10: warning: assignment from incompatible pointer type [enabled by default] L=L->next; ^

在code:blocks中没有任何错误,在teacher要求的平台上就有这么一大长串的错误,怎么改呀?

  • 写回答

2条回答 默认 最新

  • X-道至简 2022-10-02 22:40
    关注

    Node* p;
    Node* q; 定义是Node*,在使用的时候用了 List,其它的地方类似改改,统一用法看看
    编译器有不同的规则

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月11日
  • 已采纳回答 10月3日
  • 创建了问题 10月2日

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line