c - 缺少参数? C语言编程

标签 c arguments

我似乎找不到这段代码中的错误链接:

#include "queue.h"

int pause(){
    return 1;
}

void add_to_queue(person p){

    if(full() != 1){

        printf ("\nAnge förnamn:");
        scanf ("%c", p.first_name);
        printf ("\nAnge efternamn:");
        scanf ("%c", p.sure_name);
        printf ("\nAnge person nummer:");
        scanf ("%c", p.pers_nbr);
        enqueue(p);
    }
    else{
        printf ("\nKön är full!");
    }
}

void show_menu(){
    printf ("\n**** Meny ****\n");
    printf ("1. Lägg till personer i kön\n");
    printf ("2. Ta bort personer ur kön\n");
    printf ("3. Skriv ut kön\n");
    printf ("4. Avsluta\n\n");
}

int get_selection(){
        int selection;
        do{
                printf ("Ange ett alternativ 1-4: ");
                scanf ("%d", &selection);

                if (selection >= 1 && selection >= 4){
                    printf ("\nFel");
                }

        }while (selection < 1 && selection < 4);

        return selection;
}

void run_selection(int selection){
        switch (selection){
            case 1 :add_to_queue();   <------- THIS IS WHERE THE PROBLEM IS!
                break;

            case 2 ://remove_from_queue();
                break;

            case 3 ://print_queue();
                break;

            case 4 : exit(0);
                break;

        default:
            printf( "Ogiltigt val! Tryck enter och välj ett alternativ mellan 1-4" );
            break;
    }
}

它给了我错误:

menu.c:49:10: error: too few arguments to function ‘add_to_queue’

但我想不通这里应该有什么参数?尝试了 add_to_queue(p)add_to_queue(person p) 以及一切...... 帮助!!!!

最佳答案

您的 add_to_queue() 函数定义包括一个类型为 person 的参数。您必须将类型为 person 的参数传递给 return_selection 函数中的 add_to_queue()
或者改变

void add_to_queue(person p){...}  

void add_to_queue(void){...}

关于c - 缺少参数? C语言编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20129317/

相关文章:

python - 'required' 是 python 命令中位置参数的无效参数

c - 当我销毁我的链表时程序总是崩溃

c - strtok 似乎删除了字符串部分 - 我使用它正确吗?

C "#define"函数名生成

function - Kotlin 使用数据类发送函数参数

PHP将所有参数作为数组获取?

c# - WCF (WCF-Binding) in/with C/C++

c - 在 C 中查找结构的定义

Python 方法的参数验证,ArgError

java - 将 map 传递给另一个要在 java 中修改的方法