left of '->next' must point to struct/union为什么?
我明明定义了结构体Student的啊
还有为什么一直说->next左边的不是结构体呢?CurrentData也是我定义过的Student结构体指针啊
跪求解释error和warning的原因
代码如下
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
struct stud
{
char Name[20];
float Score;
struct stud*next;
};
typedef struct stud Student;
Student* Create();
Student* Insert(Student*head);
void Display_Main_Menu();
int menu_select();
int Continue();
int main(int argc,char*argv[])
{
Display_Main_Menu();
for(;;)
{
switch(menu_select())
{
case 1:
printf("Execution of \"Creat List\"\n");
Create();
break;
default:
printf("error!please input 1\n");
};
}
return 0;
}
int menu_select()
{
int SelectedNumber;
printf("please input the number(from 0 to 7) and \'Enter\':");
scanf("%d",&SelectedNumber);
return SelectedNumber;
};
void Display_Main_Menu()
{
printf("1. Creat List\n");
printf("2. Display All Record\n");
printf("3. Insert a Record\n");
printf("4. Delete a Record\n");
printf("5. Query\n");
printf("6. Add Records from a Text File\n");
printf("7. Write to a Text File\n");
printf("0. Quit\n");
printf("Give your choice(0-7): ");
};
int Continue()
{
char choice;
printf("continue to input? press \'y\' or \'n\': ");
scanf("%c",&choice);
if(choice=='y')
return 1;
}
Student* Insert(Student*head)
{
Student* NewData=(struct Stud*)malloc(sizeof(struct stud));
printf("please input a name and \'Enter\': ");
scanf("%s",NewData->Name);
printf("please input the score and \'Enter\': ");
scanf("%d",&(NewData->Score));
NewData->next=NULL;
if(head==NULL)
{
head=NewData;
return head;
}
Student *CurrentData=head;
while(CurrentData->next!=NULL)
{
CurrentData=CurrentData->next;
};
CurrentData->next=NewData;
}
Student* Create()
{
static struct Student *head=NULL;
do
{
Insert(head);
printf("Insert a piece of data successfully\n");
}
while(Continue()==1);
return head;
}
warning C4133: 'initializing' : incompatible types - from 'struct Stud *' to 'struct stud *'
error C2275: 'Student' : illegal use of this type as an expression
see declaration of 'Student'
error C2065: 'CurrentData' : undeclared identifier
error C2223: left of '->next' must point to struct/union
error C2223: left of '->next' must point to struct/union
error C2223: left of '->next' must point to struct/union
warning C4133: 'function' : incompatible types - from 'struct Student *' to 'struct stud *'
warning C4133: 'return' : incompatible types - from 'struct Student *' to 'struct stud *'
执行 cl.exe 时出错.
相关推荐
C语言命语法错误大全
18. error C2223: left of '->x' must point to struct/union该错误是由于'->x'的左侧应是结构类型变量或联合类型变量引起的。
【信息科学与工程学】计算机科学与自动化——第三百零五篇 计算机系统中的各类运算操作01
编号类型领域运算操作运算类型算法算法的详细设计及数学分析参数列表及参数的数值设计应用场景 (100+条)集合运算1集合运算关系代数并集 (Union)集合运算归并排序去重合并两个集合,去除重复元素。时间复杂度 O(n+m),n,m为两集合大小。输入:集合A, B。输出:A∪B。数据集成、多表结果合并、去重后的全量数据提取。2集合运算关系代数交集 (Intersection)集合运算哈希交集找出同时属于两个集合的元素。平均时间复杂度 O(min(n,m)),最坏 O(n*m)。输入:集合A, B。输出:A∩
24点游戏 (c/c++)
struct nod {struct nod *left,*right;unsigned char operatie; union { double valoare;CString *valoares
C++程序员面试笔试题.pdf,这是一份不错的文件
(num); int left = 0; int right = strNum.length() - 1; while (left < right) { if (strNum[left] !
c语言学习关键字的书写
例如,定义一个新的类型`TreeNode`来表示树节点:```ctypedef struct TreeNode { int value; struct TreeNode* left; struct TreeNode


