BlackCat30 2022-02-16 21:51 采纳率: 80%
浏览 161
已结题

C Visual-Studio 不允许指针指向不完整的类类型

已加_CRT_SECURE_NO_WARNINGS

假期预习想自己试着写一下链表 单链双链都没问题 到循环链这里就如下(实力不济求包含)

#include<stdio.h>
#include<stdlib.h>
typedef struct{
    struct Struction* next;
    struct Struction* prep;
    int value;
}Struction;
typedef struct point{
    Struction* head;
    Struction* circle;
}Point;
void Print(Point* List,int n);
int Length(Point* List);
 void Insert(Point* List);
int main()
//循环链表 (无头结点)
{
    int n;
    scanf("%d",&n);
    Point List;
    List.head=NULL;
    List.circle=NULL;
    int i=0;
    for(i;i<n;i++){
        Struction* p=(Struction*)malloc(sizeof(Struction));
        if(List.head==NULL){
            List.head=p;
            List.circle=p;
            p->next=NULL;
            p->prep=NULL;
        }else{
            List.circle->next=p;
            p->prep=List.circle;
            List.circle=p;
            p->next=List.head;
        }
        scanf("%d",&(p->value));
    }
    Print(&List,n);
 }
 int Length(Point* List)
 {
     Struction* plist=List->head;
     int len=0;
     for(len,plist;plist!=List->circle;plist=plist->next){
         len++;
     }
    return len;
  } 
 void Insert(Point* List)
 {
     int num;
    scanf("%d",&num);
    int len=Length(List);
    if(num>=0&&num<=len){
        Struction* plist;
        Struction* p=(Struction*)malloc(sizeof(Struction));
        if(num==0){
            plist=List->head;
            plist->prep=p;
            p->next=plist;
            p->prep=NULL;
            List->head=p;
            List->circle->next=p;
        }else if(num==len){
            plist=List->circle;
            plist->next=p;
            p->prep=plist;
            p->next=List->head;
            p=List->circle;
        }else{
            plist=List->head;
            int i=1;
            if(num<=len/2){
                for(i,plist;i<=num-1;i++,plist=plist->next);
                p->next=plist->next;
                plist->next=p;
                _**p->next->prep=p;**_
                p->prep=plist;
            }else{
                for(i,plist;i<=len-num;plist=plist->prep);
                p->prep=plist->prep;
                plist->prep=p;
                _**p->prep->next=p;**_
                p->next=plist;
            }
        }
    }else{
        printf("Wrong input.\n");
    }
 }
 void Print(Point* List,int n)
 {
     Struction* plist=List->head;
     int i=0;
     for(plist,i;i<n;plist=plist->next,i++){
         printf("%d ",plist->value);
     }
     printf("\n");
 }

报错在Insert函数中的斜体粗体部分(78、84行),报错内容如标题
不清楚原因

  • 写回答

3条回答 默认 最新

  • ·星辰大海 2022-02-16 23:13
    关注

    改好了改好了,你试一下。

    typedef struct node{
        struct node* next;
        struct node* prep;
        int value;
    }Struction;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 2月25日
  • 已采纳回答 2月17日
  • 修改了问题 2月16日
  • 创建了问题 2月16日

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘