C 错误:预期的声明说明符或“*”标记之前的“...”

noureldeen21

所以我正在学习数据结构,并且对 C 非常陌生。我正在尝试制作一个接受学生 ID 和课程编号的函数,输出将是学生姓名和课程名称。我目前被困在输入部分。这是我到目前为止的代码:

typedef struct Student Student;
typedef struct Course Course;
typedef struct Node Node;
typedef struct Node* NodePtr;

struct Student{
    int id;
    char name[30];
    double gpa;
    int ch;
};

struct Course{
    int id;
    char code[10];
    char name[30];
    int ch;
};

void displayStudents() {

     struct Student students[10]={
        {1, "ahmed" ,3.6,43},
        {2, "mohamed", 3.2, 40},
        {3,"hassan", 3.0, 41},
        {4, "hossam", 2.5, 35},
        {5, "hany", 2.3, 32},
        {6, "hala", 2.7, 37},
        {7, "hana", 2.8, 33},
        {8, "ramadan",3.8,46},
        {9, "sameh",3.7,43},
        {10, "nour",3.3,42}
     };

      for(int i=0; i<10; i++) {
        printf("%d,%s,%lf, %d", students[i].id, students[i].name, students[i].gpa, students[i].ch);
        printf("\n");
      }

}

void displayCourses() {

    struct Course courses[3] = {
    {30, "CS212", "DataStructure", 3},
    {40, "CS233", "Architecture", 3},
    {50, "GM300", "Multimedia", 3}

    };

    for (int i=0; i<3; i++) {

        printf("%d - %s - %s - %d", courses[i].id, courses[i].code, courses[i].name, courses[i].ch);
        printf("\n");
    }


}

void Registeration(struct Student student, *struct Course courses) {

          printf("Select a student: \n");
          gets(student.name);
          printf("Enter his ID: ");
          scanf("%d", &student.id);
          printf("Select a course: ");
          scanf("%d",&course.id);


}

我在注册功能中遇到错误。我尝试删除指针但它引起了其他问题,我也尝试了很多其他东西但无济于事。

这是错误:

||=== Build: Debug in Data Structure Project (compiler: GNU GCC Compiler) ===|
C:\Users\Shiko\Desktop\C Tutorials\Data structure project\main.c|155|error: expected declaration specifiers or '...' before '*' token|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
下午100

这不是有效的语法

void Registeration(struct Student student, *struct Course courses) 

我怀疑你的意思是

void Registeration(struct Student student, struct Course courses) 

要么

void Registeration(struct Student student, struct Course *courses) 

取决于您是要将结构作为 arg 还是指向结构的指针传递。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

错误:预期的声明说明符或C中“ tWordInfo”之前的“ ...”

预期的声明说明符或'*'标记之前的'...'

C ++错误:预期类型说明符

预期的声明说明符或'('标记前的'...'

c-指向const数据的const指针(gcc-重复的'const'声明说明符)

C ++模板:不能与以前的“类型名称”声明说明符组合

获取错误:字符串常量之前的预期声明说明符或“...”

我在“('令牌”之前收到错误“预期的声明说明符或'...'?

错误:XXX 之前的预期声明说明符或“...”(各种参数)

c ++两个类互相引用错误:“ ClassName”之前的预期类型说明符

在 C++ 中得到预期的类型说明符错误

在 C++ 中的错误之前无效使用不完整的类型和预期的类型说明符

声明外部堆栈时,预期的声明说明符错误

C ++嵌套名称空间错误-预期的类型说明符错误

C ++中的“此声明没有存储类或类型说明符”错误

错误:C ++要求所有声明都使用类型说明符?

错误:C++ 中的“此声明没有存储类或类型说明符”

如何修复错误“C++ 要求所有声明的类型说明符?”

C - “错误:预期标识符或 '(' 在 '[' 标记之前”

预期的类型说明符C ++模板类

C ++ 11,`noexcept`说明符,定义与声明

C ++:const引用,类型说明符之前和之后

C ++错误:Todd Veldhuizen的TMP Turing完整性证明中预期的嵌套名称说明符

声明Windows API结构(DCB)的对象-错误C4430:缺少类型说明符-假定为int

错误:声明说明符中有两个或多个数据类型

Flex 的 C 错误:缺少类型说明符?

错误:“数字”之前的预期类型说明符

错误:'Elem' 之前的预期类型说明符

错误:声明说明符中的两个或多个数据类型uint32_t int;