| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1119 人关注过本帖
标题:求大神指点!请问错在哪?
只看楼主 加入收藏
kissSX
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2017-3-15
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:4 
求大神指点!请问错在哪?
代码如下:
#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct Student)
struct Student
{
     char name[10];
    float sorce;
    struct Student *next;
};
struct Student *Creat()
{
    int n,i;
    struct Sutdent *p1=NULL;
        struct Sutdent *p2=NULL;
        struct Sutdent *head;
    head=(struct Student *)malloc(sizeof(struct Student));
    //head->next=NULL;
    p1=head;
    if(head=NULL)
    {
        printf("创建失败\n");
            return NULL;
    }
//    else
//    {
       printf("请问有几个学生?/n");
           scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        p2=(struct Student *)malloc(sizeof(struct Student));
        printf("请输入学生的名字和成绩/n");
        scanf("%s %f",&(p2->name),&(p2->sorce));
        p2=p2->next;
        p2=p1;
    }

}
出现以下错误:error C2037: left of 'name' specifies undefined struct/union 'Sutdent'
              error C2037: left of 'sorce' specifies undefined struct/union 'Sutdent'
搜索更多相关主题的帖子: include return 
2017-04-11 22:08
lmlm1001
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:4
帖 子:107
专家分:550
注 册:2015-3-1
收藏
得分:5 
Sutdent
Student
p2->name 已经是指针了
2017-04-11 22:20
kissSX
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2017-3-15
收藏
得分:0 
回复 2楼 lmlm1001
还是不太懂
2017-04-11 22:32
shuanggege
Rank: 2
等 级:论坛游民
帖 子:11
专家分:22
注 册:2017-4-8
收藏
得分:5 
#include<stdio.h>
#include<stdlib.h>
#define LEN sizeof(struct Student)
struct Student
{
     char name[10];
    float sorce;
    struct Student *next;
}*head,*p1,*p2;
struct Student *Creat()
{
    int n,i;
    /*struct Sutdent *p1=NULL;
        struct Sutdent *p2=NULL;
        struct Sutdent * head;*/
    head=(struct Student *)malloc(sizeof(struct Student));
    //head->next=NULL;
    p1=head;
    if(head=NULL)
    {
        printf("创建失败\n");
            return NULL;
    }
//    else
//    {
       printf("请问有几个学生?/n");
           scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        p2=(struct Student *)malloc(sizeof(struct Student));
        printf("请输入学生的名字和成绩/n");
        scanf("%s %f",&(p2->name),&(p2->sorce));
        p2=p2->next;
        p2=p1;
    }

}
2017-04-13 21:27
shuanggege
Rank: 2
等 级:论坛游民
帖 子:11
专家分:22
注 册:2017-4-8
收藏
得分:0 
把几个指针拿到外面结构体定义
2017-04-13 21:29
快速回复:求大神指点!请问错在哪?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019935 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved