Игровой автомат в программе C с петлями - PullRequest
0 голосов
/ 30 ноября 2018

Я пытаюсь сделать случайные числа и циклы, чтобы создать игровой автомат.Это часть моего финального проекта для моего курса.Когда это рабочая программа, я также пытаюсь создать библиотеку проклятий.Ниже приведены сообщения об ошибках, которые я использую Code::Blocks программное обеспечение, которое я могу загрузить для свободного программирования.Я не понимаю, как это не работает должным образом ... Кто-нибудь может помочь?

#include <stdio.h>
#include <time.h>
#include <windows.h>

int intSlot1, intSlot2, intSlot3;

void fnGotoXY(short x, short y);
void fnSlotMachine();
void fnSlot1();
void fnSlot2();
void fnSlot3();

int main()
{
    srand(time(0));
    fnSlotMachine();
    while (1) {
        fnSlot1();
        fnSlot2();
        fnSlot3();
    }
}

void fnGotoXY(short x, short y)
{
    COORD pos = { x, y };
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}

void fnSlotMachine()
{
    fnGotoXY(5, 5);
    printf(" x^---------------------------^x\n");
    printf("      |oOoOoOoOoOoOoOoOoOoOoOoOoOoOo|\n");
    printf("      \\_____________________________/\n");
    printf("      /__$$$__\\  /__$$$__\\  /__$$$__\\");
    fnGotoXY(5, 12);
    printf(" <*^*^*^*>  <*^*^*^*>  <*^*^*^*>");
}

void fnSlot1()
{
    Sleep(50);
    fnGotoXY(5, 9);
    intSlot1 = rand() % 9;
    printf(" | %i %i %i |\n", intSlot1, intSlot1, intSlot1);
    fnGotoXY(2, 10);
    printf("    | %i %i %i |\n", intSlot1, intSlot1, intSlot1);
    fnGotoXY(2, 11);
    printf("    | %i %i %i |", intSlot1, intSlot1, intSlot1);
}

void fnSlot2()
{
    Sleep(50);
    fnGotoXY(17, 9);
    intSlot2 = rand() % 9;
    printf("| %i %i %i |\n", intSlot2, intSlot2, intSlot2);
    fnGotoXY(17, 10);
    printf("| %i %i %i |\n", intSlot2, intSlot2, intSlot2);
    fnGotoXY(17, 11);
    printf("| %i %i %i |", intSlot2, intSlot2, intSlot2);
}


void fnSlot3()
{
    Sleep(50);
    fnGotoXY(27, 9);
    intSlot3 = rand() % 9;
    printf("| %i %i %i |\n", intSlot3, intSlot3, intSlot3);
    fnGotoXY(27, 10);
    printf("| %i %i %i |\n", intSlot3, intSlot3, intSlot3);
    fnGotoXY(27, 11);
    printf("| %i %i %i |", intSlot3, intSlot3, intSlot3);
}

Компилятор Код :: Блоки :

C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|16|undefined reference to `fnSlotMachine'|
C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|18|undefined reference to `fnSlot1'|
C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|60|undefined reference to `fnGotoXY'|
C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|63|undefined reference to `fnGotoXY'|
C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|65|undefined reference to `fnGotoXY'|
C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|73|undefined reference to `fnGotoXY'|
C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|76|undefined reference to `fnGotoXY'|
obj\Debug\main.o:C:\Users\Admin\Documents\PROGRAMMING\runner\main.c|78|more undefined references to `fnGotoXY' follow|

1 Ответ

0 голосов
/ 30 ноября 2018

Ваши открывающие и закрывающие скобки { неверны.

В основном вы не закрыли цикл while и у вас есть дополнительная закрывающая скобка в функции fnSlot1

Подобные проблемы могут быть легко обнаружены последовательной схемой отступов.В вашей программе у вас разные пробелы для каждого отступа.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...