我似乎找不到这段代码中的错误链接:
#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/