C 为什么我会得到;“之前的语法错误”;在调用函数时?

C 为什么我会得到;“之前的语法错误”;在调用函数时?,c,C,我正在尝试调用函数(从这个switch语句)。在我调用我得到的函数的每一行上,都是“Person之前的语法错误”Person*是指向链接列表中“Person”类型结构的指针。我调用的函数是由其他人编写的;我只是在写一个菜单函数。这个错误是否意味着我传递了错误的参数 do{ switch (input){ case 'a': add(Person*); //error

我正在尝试调用函数(从这个switch语句)。在我调用我得到的函数的每一行上,都是“Person之前的语法错误”
Person*
是指向链接列表中“Person”类型结构的指针。我调用的函数是由其他人编写的;我只是在写一个菜单函数。这个错误是否意味着我传递了错误的参数

    do{
            switch (input){
                case 'a':
                    add(Person*); //error
                    break;
                case 'd':
                    delete(Person*); //error
                    break;
                case 'v':
                    writelist(Person*); //error
                    break;
                case 's':
                    writefile(Person*, char*); //error
                    break;
                default:
                    printf ("Not a valid input\n");
                    break;
            }

        }while (input != 'q');

传递相应类型的实际变量,而不是变量类型。我假设你已经对你的个人结构做了
typedef

    //Some code
    Person* p = (Person*)malloc(sizeof(Person))//Some where in the  code
    //May be you want to set the values for the structure members
    char* fileName =  (char*) malloc(20);
    //Scan or set the file name
    //Some code
    do{
        switch (input){
            case 'a':
                add(p);
                break;
            case 'd':
                delete(p);
                break;
            case 'v':
                writelist(p);
                break;
            case 's':
                writefile(p,fileName);
                break;
            default:
                printf ("Not a valid input\n");
                break;
        }

    }while (input != 'q');

您正在传递变量的类型,但是变量本身在哪里?这是您的实际代码吗
Person*
在这种上下文中没有意义
switch
语句与此无关。行
add(Person*)即使在
开关
语句之外也无效。@bengoesboom
Person*
在该上下文中使用,无论它是什么;)这是我的实际代码,很明显我已经暴露了自己是一个笨蛋。我想我试图传递的参数就是问题所在。令人困惑的是它说:“错误:在“Person”之前的语法错误,所以我不确定。