Я пытаюсь составить случайные числа и циклы для создания игрового автомата. Это часть моего заключительного проекта моего курса. Как только это рабочая программа, я также пытаюсь создать библиотеку curses. Я включил сообщения об ошибках ниже. Я использую программное обеспечение 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|
Кроме того, когда вы пишете void foo();, вам наверняка понадобится void foo(void);.





Ваши открывающая и закрывающая скобки { неверны.
В основном вы не замкнули цикл while и имеете лишнюю закрывающую скобку в функции fnSlot1.
Подобные проблемы можно легко обнаружить с помощью последовательной схемы отступов. В вашей программе у вас есть разные пробелы для каждого отступа.
Я бы также предложил использовать другой редактор (отличный от CodeBlocks). Один, с правильным линтером!
Code :: Blocks не является компилятором.