Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C-某些方法没有从菜单方法调用_C - Fatal编程技术网

C-某些方法没有从菜单方法调用

C-某些方法没有从菜单方法调用,c,C,我正在为uni编写一个blackjack程序,有些方法根本没有被调用。 此菜单方法是包含main方法的assign1.c文件的一部分。其他方法在其他.c文件中,但我多次检查了代码的#include部分,它们都是100%正确的。 菜单打印得很好,i被正确设置为输入,但是当调用适当的if语句时,菜单中的方法不正确。这是密码 编辑:特别是playGame()方法我知道其他方法没有被正确调用,但playGame方法给了我最大的痛苦 int mainmenu(){ int i = 0; int j = 0

我正在为uni编写一个blackjack程序,有些方法根本没有被调用。 此菜单方法是包含main方法的assign1.c文件的一部分。其他方法在其他.c文件中,但我多次检查了代码的#include部分,它们都是100%正确的。 菜单打印得很好,i被正确设置为输入,但是当调用适当的if语句时,菜单中的方法不正确。这是密码

编辑:特别是playGame()方法我知道其他方法没有被正确调用,但playGame方法给了我最大的痛苦

int mainmenu(){
int i = 0;
int j = 0;
while (j<1) {
    printf("\n");
    printf("Black Jack - Main Menu\n");
    printf("1) Play Game\n");
    printf("2) Display Scores\n");
    printf("3) Reset Scores\n");
    printf("4) Quit\n");
    printf("\n" "Make your selection: ");

scanf("%d", &i);
if (i==1) {
    Player* playGame(Player *computer, Player *human, Card *deck);
    int testmethod();
}
else if (i==2) {
    printScoreBoard();
}
else if (i==3) {
    resetScores();
}
else if (i==4){
    j++;
}
else{
    printf("%s\n",  "Incorrect input, please try again");

    int ch;
    /* remove all characters from the buffer */
    while(ch = getc(stdin), ch!='\n' && ch!=EOF)
        ;
    /* clear the error status of the input pointer */
    clearerr(stdin);

}


}

return 0;
int主菜单(){
int i=0;
int j=0;
虽然(j您实际上没有调用函数,但您只是声明了它们,例如:

if (i==1) {
    Player* playGame(Player *computer, Player *human, Card *deck);
    int testmethod();
}
应该是:

if (i==1) {
    player = playGame(computer, human, deck);
    testmethod();
}

(显然,
玩家
计算机
人类
甲板
需要事先定义/初始化)

请参见编辑*干杯,尽管我应该在询问之前解决这个问题。解决之后,xcode告诉我,这行中缺少一个预期的表达式:\n好的-您仍然需要修复
playGame
testMethod
-这些仍然只是函数声明,而不是函数调用-请参见上面的编辑。如果我将其更改为player=playGame(计算机、人类、甲板)它告诉我我缺少一个预期的标识符或(.注意上面答案中的最后一句话:您需要声明(或者初始化)作为参数传递给
playGame
的变量,以及保存函数结果的变量(
player
)。而没有看到最新版本的代码(以及缺少的函数)很难给出更具体的帮助,但是你现在应该有足够的信息来解决这个问题。好的,我想我发现了问题。在我调用menu方法之前,它们都在main方法中声明和初始化,我将这些声明移到menu方法中,现在我认为一切都很好。谢谢你的帮助。