有哪位大佬能帮帮看看这几个错误是怎么回事,感激不尽

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define _CRT_SECURE_NO_WARNINGS
struct student{
    char name[20];
    char num[20];//学号,姓名,性别,楼栋号,宿舍号,出发地(从哪出发
                 //返校),身体状况,并写入文件。
    int _class;
    char sex[4];
    char telephone[20];
    //double a;
    char loudong[20];
    int sushe;

};

struct stu_node{
    struct student data;
    struct stu_node *next;
};

//链表操作函数区域
struct stu_node* buildlist()    //创建链表
{
    struct stu_node* head = (struct stu_node*)malloc(sizeof(struct stu_node));//为表头动态内存分配
    head->next = NULL;            //初始化表头为NULL
    return head;                //返回值为头指针
}

struct stu_node* buildnode(struct student data)//创建学生结点
{
    struct stu_node* newnode = (struct stu_node*)malloc(sizeof(struct stu_node));//新建节点动态内存分配
    newnode->data = data;        //新建学生信息初始化
    newnode->next = NULL;        //新建学生节点的next初始化为NULL
    return newnode;                //返回值为新建的学生节点
}

void insertnode(struct stu_node* head, struct student data)//插入节点,头插法(新建的节点放在最前面)
{
    struct stu_node* newnode = buildnode(data);    //利用创建节点函数创建一个节点
    newnode->next = head->next;                    //头插法将新节点插入链表
    head->next = newnode;
}

/*void deletenode(struct stu_node* head, char* num)//删除给定学号的学生节点
{
    struct stu_node*  deletenodeFront= head;
    struct stu_node*  deletenode = head->next;
    while(strcmp(deletenode->data.num,num)){    //寻找学号为指定学号的节点
        deletenodeFront = deletenode;
        deletenode = deletenode->next;
    }
    deletenodeFront->next = deletenode->next;    //删除实现的操作
    free(deletenode);
}*/
void deletenode(struct stu_node* head,char*name)
{
struct stu_node*  deletenodeFront= head;
    struct stu_node*  deletenode = head->next;
    while(strcmp(deletenode->data.name,name)){    //寻找学号为指定学号的节点
        deletenodeFront = deletenode;
        deletenode = deletenode->next;
    }
    deletenodeFront->next = deletenode->next;    //删除实现的操作
    free(deletenode);
}


//文件操作函数区域
void readstudent(struct stu_node* head, char *filename)//读取文件操作
{
    FILE *read=NULL;
    struct student temp;
    read=fopen(filename,"r");                             //以”只读“的方式打开文件
    if(read == NULL)
        read = fopen(filename,"w+");                    //第一次打开文件以“建立新文本文件进行读\写”的方式打开
    while(fscanf(read,"%s\t%s\t%d\t%s\t%s\t%s\t%d\n",temp.name,temp.num,&temp._class,temp.sex,temp.telephone,temp.loudong,&temp.sushe)!=EOF){
        insertnode(head,temp);//&temp.a
    }
    fclose(read);
    return;//关闭文件
}

void writestudent(struct stu_node* head, char *filename)//写入文件操作
{
    FILE *write=NULL;
    struct stu_node *pHead;
    pHead = head->next;
    write=fopen(filename,"w");                            //以“建文本文件只进行写”的方式打开
    while(pHead){
        fprintf(write,"%s\t%s\t%d\t%s\t%s\t%s\t%d\n",pHead->data.name,pHead->data.num,pHead->data._class,pHead->data.sex,pHead->data.telephone,pHead->data.loudong,pHead->data.sushe);
        pHead = pHead->next;
    }
    fclose(write);    
    return;//关闭文件
}

void printList(struct stu_node *head)
{
    struct stu_node *pMove = head->next;
    printf("姓名    学号    班级    性别     电话      楼栋   宿舍   \n");
    while(pMove){
        printf("%s\t%s\t%d\t%s\t%s\t%s\t%d\n",
        pMove->data.name,pMove->data.num,pMove->data._class,pMove->data.sex,pMove->data.telephone,pMove->data.loudong,pMove->data.sushe);
        pMove = pMove->next; 
    }
    printf("\n");
}

struct node* searchstudent(struct stu_node *head, char *studentname)
{
    struct stu_node *pMove = head->next;
    //&& 短路现象
    while (pMove != NULL&&strcmp(pMove->data.name, studentname))
    {
        pMove = pMove->next;
    }
    return pMove;        //NULL 没找到
}


void menu()
{
    printf("---------------------------------------------\n");
    printf("\t\t0.退出系统\n");
    printf("\t\t1.录入信息\n");
    printf("\t\t2.浏览信息\n");
    printf("\t\t3.修改信息\n");
    printf("\t\t4.查找信息\n");
    printf("\t\t5.删除信息\n");
    printf("\t\t6.总览信息\n");
    printf("---------------------------------------------\n");
}

struct stu_node *head; 

void keydown()
{
    int userKey = 0;
    struct student userData;
    int sum;
    //double ave_grade;
    //int elx_sum;
    scanf("%d",&userKey);
    switch(userKey)
    {
        case 0:
            printf("-----------【退出系统】------------\n");
            printf("正常退出\n");
            system("pause");
            exit(0);
            break;
        case 1:
            printf("-----------【录入信息】------------\n");
            printf("请输入以下学生信息\n");
            printf("姓名  学号   班级  性别   电话   楼栋   宿舍\n");
            scanf("%s %s %d %s %s %s %d",userData.name,userData.num,&userData._class,userData.sex,userData.telephone,userData.loudong,&userData.sushe);
            insertnode(head,userData);
            break;    
        case 2:
            printf("-----------【浏览信息】------------\n");
            printList(head);
            break;
        case 3:
            printf("-----------【修改信息】------------\n");

        printf("\n\t\t【修改学生信息】\n");  //链表的修改
        printf("\t\t按照姓名修改,请输入要修改学生的姓名\n");
        scanf("%s", userData.name);
        if (searchstudent(head, userData.name) == NULL)
        {
            printf("未找到相关信息,无法修改!\n");
        }
        else
        {
            printf("请输入信息妃子信息(姓名,学号,班级,性别,电话,楼栋,宿舍)\n");
            scanf("%s%s%d%s%s%s%d", searchstudent(head, userData.name)->temp.name,
                searchstudent(head, userData.name)->temp.num,
                searchstudent(head, userData.name)->temp._class,
                searchstudent(head, userData.name)->temp.sex,
                searchstudent(head, userData.name)->temp.telephone,
                searchstudent(head, userData.name)->temp.loudong,
                searchstudent(head, userData.name)->temp.sushe);
                
          writestudent(head,"student");
          printf("修改成功!\n");
        }
        break;
    default:


            break;
        case 4:
            printf("-----------【查找信息】------------\n");
            break;
        case 5:
            printf("-----------【删除信息】------------\n");
            printf("请输入删除学生的姓名\n");
            scanf("%s",userData.name);
            deletenode(head,userData.name);
            break;
        case 6:
            printf("-----------【总览信息】------------\n");
            printf("学生总数\n");
            /*Class_Statisics(head,&sum,&ave_grade,&elx_sum);*/
            printf("%d",sum);
            /*printf("%d\t  %.1lf\t    %d\n",sum,ave_grade,elx_sum);*/ 
            break; 
    }
}
int main()
{    
    head = buildlist();
    readstudent(head,"student");
    while(1){
        menu();
        keydown();
        writestudent(head,"student");
        system("pause");
        system("cls"); 
    }
    return 0;
}
错误提示

--------------------Configuration: xuexin - Win32 Debug--------------------
Compiling...
xuexin.c
C:\Users\ren200119\Desktop\xuexin\xuexin.c(121) : warning C4133: 'return' : incompatible types - from 'struct stu_node *' to 'struct node *'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(180) : error C2037: left of 'temp' specifies undefined struct/union 'node'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(181) : error C2037: left of 'temp' specifies undefined struct/union 'node'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(182) : error C2037: left of 'temp' specifies undefined struct/union 'node'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(183) : error C2037: left of 'temp' specifies undefined struct/union 'node'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(184) : error C2037: left of 'temp' specifies undefined struct/union 'node'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(185) : error C2037: left of 'temp' specifies undefined struct/union 'node'
C:\Users\ren200119\Desktop\xuexin\xuexin.c(186) : error C2037: left of 'temp' specifies undefined struct/union 'node'
执行 cl.exe 时出错.

xuexin.obj - 1 error(s), 0 warning(s)
 

帮你修改后,可以运行了。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define _CRT_SECURE_NO_WARNINGS
struct student{
    char name[20];
    char num[20];//学号,姓名,性别,楼栋号,宿舍号,出发地(从哪出发
                 //返校),身体状况,并写入文件。
    int _class;
    char sex[4];
    char telephone[20];
    //double a;
    char loudong[20];
    int sushe;

};

struct stu_node{
    struct student data;
    struct stu_node *next;
};

//链表操作函数区域
struct stu_node* buildlist()    //创建链表
{
    struct stu_node* head = (struct stu_node*)malloc(sizeof(struct stu_node));//为表头动态内存分配
    head->next = NULL;            //初始化表头为NULL
    return head;                //返回值为头指针
}

struct stu_node* buildnode(struct student data)//创建学生结点
{
    struct stu_node* newnode = (struct stu_node*)malloc(sizeof(struct stu_node));//新建节点动态内存分配
    newnode->data = data;        //新建学生信息初始化
    newnode->next = NULL;        //新建学生节点的next初始化为NULL
    return newnode;                //返回值为新建的学生节点
}

void insertnode(struct stu_node* head, struct student data)//插入节点,头插法(新建的节点放在最前面)
{
    struct stu_node* newnode = buildnode(data);    //利用创建节点函数创建一个节点
    newnode->next = head->next;                    //头插法将新节点插入链表
    head->next = newnode;
}

/*void deletenode(struct stu_node* head, char* num)//删除给定学号的学生节点
{
    struct stu_node*  deletenodeFront= head;
    struct stu_node*  deletenode = head->next;
    while(strcmp(deletenode->data.num,num)){    //寻找学号为指定学号的节点
        deletenodeFront = deletenode;
        deletenode = deletenode->next;
    }
    deletenodeFront->next = deletenode->next;    //删除实现的操作
    free(deletenode);
}*/
void deletenode(struct stu_node* head,char*name)
{
struct stu_node*  deletenodeFront= head;
    struct stu_node*  deletenode = head->next;
    while(strcmp(deletenode->data.name,name)){    //寻找学号为指定学号的节点
        deletenodeFront = deletenode;
        deletenode = deletenode->next;
    }
    deletenodeFront->next = deletenode->next;    //删除实现的操作
    free(deletenode);
}


//文件操作函数区域
void readstudent(struct stu_node* head, char *filename)//读取文件操作
{
    FILE *read=NULL;
    struct student temp;
    read=fopen(filename,"r");                             //以”只读“的方式打开文件
    if(read == NULL)
        read = fopen(filename,"w+");                    //第一次打开文件以“建立新文本文件进行读\写”的方式打开
    while(fscanf(read,"%s\t%s\t%d\t%s\t%s\t%s\t%d\n",temp.name,temp.num,&temp._class,temp.sex,temp.telephone,temp.loudong,&temp.sushe)!=EOF){
        insertnode(head,temp);//&temp.a
    }
    fclose(read);
    return;//关闭文件
}

void writestudent(struct stu_node* head, char *filename)//写入文件操作
{
    FILE *write=NULL;
    struct stu_node *pHead;
    pHead = head->next;
    write=fopen(filename,"w");                            //以“建文本文件只进行写”的方式打开
    while(pHead){
        fprintf(write,"%s\t%s\t%d\t%s\t%s\t%s\t%d\n",pHead->data.name,pHead->data.num,pHead->data._class,pHead->data.sex,pHead->data.telephone,pHead->data.loudong,pHead->data.sushe);
        pHead = pHead->next;
    }
    fclose(write);    
    return;//关闭文件
}

void printList(struct stu_node *head)
{
    struct stu_node *pMove = head->next;
    printf("姓名    学号    班级    性别     电话      楼栋   宿舍   \n");
    while(pMove){
        printf("%s\t%s\t%d\t%s\t%s\t%s\t%d\n",
        pMove->data.name,pMove->data.num,pMove->data._class,pMove->data.sex,pMove->data.telephone,pMove->data.loudong,pMove->data.sushe);
        pMove = pMove->next; 
    }
    printf("\n");
}

struct stu_node* searchstudent(struct stu_node *head, char *studentname)
{
    struct stu_node *pMove = head->next;
    //&& 短路现象
    while (pMove != NULL&&strcmp(pMove->data.name, studentname))
    {
        pMove = pMove->next;
    }
    return pMove;        //NULL 没找到
}


void menu()
{
    printf("---------------------------------------------\n");
    printf("\t\t0.退出系统\n");
    printf("\t\t1.录入信息\n");
    printf("\t\t2.浏览信息\n");
    printf("\t\t3.修改信息\n");
    printf("\t\t4.查找信息\n");
    printf("\t\t5.删除信息\n");
    printf("\t\t6.总览信息\n");
    printf("---------------------------------------------\n");
}

struct stu_node *head; 

void keydown()
{
    int userKey = 0;
    struct student userData;
//    int sum;
    //double ave_grade;
    //int elx_sum;
    scanf("%d",&userKey);
    switch(userKey)
    {
        case 0:
            printf("-----------【退出系统】------------\n");
            printf("正常退出\n");
            system("pause");
            exit(0);
            break;
        case 1:
            printf("-----------【录入信息】------------\n");
            printf("请输入以下学生信息\n");
            printf("姓名  学号   班级  性别   电话   楼栋   宿舍\n");
            scanf("%s %s %d %s %s %s %d",userData.name,userData.num,&userData._class,userData.sex,userData.telephone,userData.loudong,&userData.sushe);
            insertnode(head,userData);
            break;    
        case 2:
            printf("-----------【浏览信息】------------\n");
            printList(head);
            break;
        case 3:
            printf("-----------【修改信息】------------\n");

        printf("\n\t\t【修改学生信息】\n");  //链表的修改
        printf("\t\t按照姓名修改,请输入要修改学生的姓名\n");
        scanf("%s", userData.name);
        if (searchstudent(head, userData.name) == NULL)
        {
            printf("未找到相关信息,无法修改!\n");
        }
        else
        {
            printf("请输入信息妃子信息(姓名,学号,班级,性别,电话,楼栋,宿舍)\n");
            scanf("%s%s%d%s%s%s%d", searchstudent(head, userData.name)->data.name,
                searchstudent(head, userData.name)->data.num,
                searchstudent(head, userData.name)->data._class,
                searchstudent(head, userData.name)->data.sex,
                searchstudent(head, userData.name)->data.telephone,
                searchstudent(head, userData.name)->data.loudong,
                searchstudent(head, userData.name)->data.sushe);
                
          writestudent(head,"student");
          printf("修改成功!\n");
        }
        break;
    default:


            break;
        case 4:
            printf("-----------【查找信息】------------\n");
            break;
        case 5:
            printf("-----------【删除信息】------------\n");
            printf("请输入删除学生的姓名\n");
            scanf("%s",userData.name);
            deletenode(head,userData.name);
            break;
        case 6:
            printf("-----------【总览信息】------------\n");
            printf("学生总数\n");
            /*Class_Statisics(head,&sum,&ave_grade,&elx_sum);*/
            //printf("%d",sum);
            /*printf("%d\t  %.1lf\t    %d\n",sum,ave_grade,elx_sum);*/ 
            break; 
    }
}
int main()
{    
    head = buildlist();
    readstudent(head,"student");
    while(1){
        menu();
        keydown();
        writestudent(head,"student");
        system("pause");
        system("cls"); 
    }
    return 0;
}

 

C:\Users\ren200119\Desktop\xuexin\xuexin.c(121) : warning C4133: 'return' : incompatible types - from 'struct stu_node *' to 'struct node *'

返回的结构体不兼容,不是同一个结构体对应的变量吧。

帮你修改后,可以运行了。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define _CRT_SECURE_NO_WARNINGS
struct student{
    char name[20];
    char num[20];//学号,姓名,性别,楼栋号,宿舍号,出发地(从哪出发
                 //返校),身体状况,并写入文件。
    int _class;
    char sex[4];
    char telephone[20];
    //double a;
    char loudong[20];
    int sushe;

};

struct stu_node{
    struct student data;
    struct stu_node *next;
};

//链表操作函数区域
struct stu_node* buildlist()    //创建链表
{
    struct stu_node* head = (struct stu_node*)malloc(sizeof(struct stu_node));//为表头动态内存分配
    head->next = NULL;            //初始化表头为NULL
    return head;                //返回值为头指针
}

struct stu_node* buildnode(struct student data)//创建学生结点
{
    struct stu_node* newnode = (struct stu_node*)malloc(sizeof(struct stu_node));//新建节点动态内存分配
    newnode->data = data;        //新建学生信息初始化
    newnode->next = NULL;        //新建学生节点的next初始化为NULL
    return newnode;                //返回值为新建的学生节点
}

void insertnode(struct stu_node* head, struct student data)//插入节点,头插法(新建的节点放在最前面)
{
    struct stu_node* newnode = buildnode(data);    //利用创建节点函数创建一个节点
    newnode->next = head->next;                    //头插法将新节点插入链表
    head->next = newnode;
}

/*void deletenode(struct stu_node* head, char* num)//删除给定学号的学生节点
{
    struct stu_node*  deletenodeFront= head;
    struct stu_node*  deletenode = head->next;
    while(strcmp(deletenode->data.num,num)){    //寻找学号为指定学号的节点
        deletenodeFront = deletenode;
        deletenode = deletenode->next;
    }
    deletenodeFront->next = deletenode->next;    //删除实现的操作
    free(deletenode);
}*/
void deletenode(struct stu_node* head,char*name)
{
struct stu_node*  deletenodeFront= head;
    struct stu_node*  deletenode = head->next;
    while(strcmp(deletenode->data.name,name)){    //寻找学号为指定学号的节点
        deletenodeFront = deletenode;
        deletenode = deletenode->next;
    }
    deletenodeFront->next = deletenode->next;    //删除实现的操作
    free(deletenode);
}


//文件操作函数区域
void readstudent(struct stu_node* head, char *filename)//读取文件操作
{
    FILE *read=NULL;
    struct student temp;
    read=fopen(filename,"r");                             //以”只读“的方式打开文件
    if(read == NULL)
        read = fopen(filename,"w+");                    //第一次打开文件以“建立新文本文件进行读\写”的方式打开
    while(fscanf(read,"%s\t%s\t%d\t%s\t%s\t%s\t%d\n",temp.name,temp.num,&temp._class,temp.sex,temp.telephone,temp.loudong,&temp.sushe)!=EOF){
        insertnode(head,temp);//&temp.a
    }
    fclose(read);
    return;//关闭文件
}

void writestudent(struct stu_node* head, char *filename)//写入文件操作
{
    FILE *write=NULL;
    struct stu_node *pHead;
    pHead = head->next;
    write=fopen(filename,"w");                            //以“建文本文件只进行写”的方式打开
    while(pHead){
        fprintf(write,"%s\t%s\t%d\t%s\t%s\t%s\t%d\n",pHead->data.name,pHead->data.num,pHead->data._class,pHead->data.sex,pHead->data.telephone,pHead->data.loudong,pHead->data.sushe);
        pHead = pHead->next;
    }
    fclose(write);    
    return;//关闭文件
}

void printList(struct stu_node *head)
{
    struct stu_node *pMove = head->next;
    printf("姓名    学号    班级    性别     电话      楼栋   宿舍   \n");
    while(pMove){
        printf("%s\t%s\t%d\t%s\t%s\t%s\t%d\n",
        pMove->data.name,pMove->data.num,pMove->data._class,pMove->data.sex,pMove->data.telephone,pMove->data.loudong,pMove->data.sushe);
        pMove = pMove->next; 
    }
    printf("\n");
}

struct stu_node* searchstudent(struct stu_node *head, char *studentname)
{
    struct stu_node *pMove = head->next;
    //&& 短路现象
    while (pMove != NULL&&strcmp(pMove->data.name, studentname))
    {
        pMove = pMove->next;
    }
    return pMove;        //NULL 没找到
}


void menu()
{
    printf("---------------------------------------------\n");
    printf("\t\t0.退出系统\n");
    printf("\t\t1.录入信息\n");
    printf("\t\t2.浏览信息\n");
    printf("\t\t3.修改信息\n");
    printf("\t\t4.查找信息\n");
    printf("\t\t5.删除信息\n");
    printf("\t\t6.总览信息\n");
    printf("---------------------------------------------\n");
}

struct stu_node *head; 

void keydown()
{
    int userKey = 0;
    struct student userData;
//    int sum;
    //double ave_grade;
    //int elx_sum;
    scanf("%d",&userKey);
    switch(userKey)
    {
        case 0:
            printf("-----------【退出系统】------------\n");
            printf("正常退出\n");
            system("pause");
            exit(0);
            break;
        case 1:
            printf("-----------【录入信息】------------\n");
            printf("请输入以下学生信息\n");
            printf("姓名  学号   班级  性别   电话   楼栋   宿舍\n");
            scanf("%s %s %d %s %s %s %d",userData.name,userData.num,&userData._class,userData.sex,userData.telephone,userData.loudong,&userData.sushe);
            insertnode(head,userData);
            break;    
        case 2:
            printf("-----------【浏览信息】------------\n");
            printList(head);
            break;
        case 3:
            printf("-----------【修改信息】------------\n");

        printf("\n\t\t【修改学生信息】\n");  //链表的修改
        printf("\t\t按照姓名修改,请输入要修改学生的姓名\n");
        scanf("%s", userData.name);
        if (searchstudent(head, userData.name) == NULL)
        {
            printf("未找到相关信息,无法修改!\n");
        }
        else
        {
            printf("请输入信息妃子信息(姓名,学号,班级,性别,电话,楼栋,宿舍)\n");
            scanf("%s%s%d%s%s%s%d", searchstudent(head, userData.name)->data.name,
                searchstudent(head, userData.name)->data.num,
                searchstudent(head, userData.name)->data._class,
                searchstudent(head, userData.name)->data.sex,
                searchstudent(head, userData.name)->data.telephone,
                searchstudent(head, userData.name)->data.loudong,
                searchstudent(head, userData.name)->data.sushe);
                
          writestudent(head,"student");
          printf("修改成功!\n");
        }
        break;
    default:


            break;
        case 4:
            printf("-----------【查找信息】------------\n");
            break;
        case 5:
            printf("-----------【删除信息】------------\n");
            printf("请输入删除学生的姓名\n");
            scanf("%s",userData.name);
            deletenode(head,userData.name);
            break;
        case 6:
            printf("-----------【总览信息】------------\n");
            printf("学生总数\n");
            /*Class_Statisics(head,&sum,&ave_grade,&elx_sum);*/
            //printf("%d",sum);
            /*printf("%d\t  %.1lf\t    %d\n",sum,ave_grade,elx_sum);*/ 
            break; 
    }
}
int main()
{    
    head = buildlist();
    readstudent(head,"student");
    while(1){
        menu();
        keydown();
        writestudent(head,"student");
        system("pause");
        system("cls"); 
    }
    return 0;
}

 

您好,我是有问必答小助手,你的问题已经有小伙伴为您解答了问题,您看下是否解决了您的问题,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

非常感谢您使用有问必答服务,为了后续更快速的帮您解决问题,现诚邀您参与有问必答体验反馈。您的建议将会运用到我们的产品优化中,希望能得到您的支持与协助!

速戳参与调研>>>https://t.csdnimg.cn/Kf0y