Я новичек с С, поэтому прошу сильно не пинать
Вот листинг
Код: Выделить всё
#include<graphics.h>
#include<stdlib.h>
#include"keyboard.h"
#include<conio.h>
//#include<stdio.h>
#define M_LEFT 120
#define M_RIGHT 300
#define M_TOP 20
#define M_BOTTOM 320
#define MIAU_X 500
#define MIAU_Y 420
#define ACTIVE_COLOR RED
#define PASSIVE_COLOR YELLOW
#define ACTIVE_BACK_COLOR BROWN
#define PASSIVE_BACK_COLOR DARKGREY
#define BORDER_COLOR GREEN
#define kbSpace 32
void Cat(void);
void Mouse(void);
void Dog(void);
void Sheep(void);
int GrMenu (char *Items[], int N, int Left, int Top, int Right, int Bottom);
void DrawMenu (char *Items[], int N, int Left, int Top, int Right, int Bottom, int active);
void main ( void )
{
char *Items[]={"Dog", "Cat", "Mouse", "Sheep", "Exit"};
int choice, N=5;
int a=DETECT, b;
initgraph (&a,&b, "");
setbkcolor (BLUE);
outtextxy (M_LEFT -10, M_TOP +10, "This typed only once!");
b=1;
do{
choice = GrMenu(Items, N, M_LEFT, M_TOP, M_RIGHT, M_BOTTOM);
switch(choice)
{
case -1:
case 4: b=0; break;
case 0: Dog(); break;
case 1: Cat(); break;
case 2: Mouse(); break;
case 3: Sheep(); break;
}
}
while(b);
closegraph();
}
int GrMenu(char *Items[], int N, int Left, int Top, int Right, int Bottom)
{
long sz=imagesize(Left, Top, Right, Bottom);
void *image=malloc(sz);
if(image==NULL) return -1;
getimage(Left, Top, Right, Bottom, image);
int choice=0, Done=0;
do{
DrawMenu(Items, N, Left, Top, Right, Bottom, choice);
int Key = GetKey();
switch (key)
{
case kbLeft: if(choice>0)choice--; else choice=N-1; break;
case kbRight: if(choice<N-1)choice++; else choice=0; break;
case kbEnter;
case kbSpace: Done=1; break;
}
} while(!Done);
putimage(Left, Top, image, COPY_PUT);
free(image);
return choice;
}
void DrawMenu(char *Items[], int N, int Left, int Top, int Right, int Bottom, int active)
{
setcolor(BORDER_COLOR);
rectangle(Left, Top, Right, Bottom);
setfillstyle(SOLID_FILL, PASSIVE_BACK_COLOR);
bar(Left+1, Top+1, Right-1, Bottom-1);
settextjustifi(CENTER_TEXT, CENTER_TEXT);
setfillstyle(SOLID_FILL, ACTIVE_BACK_COLOR);
int x;
int y=(Bottom+Top)/2;
int dx=(Right-Left)/(N+1);
int dy=(Bottom-Top)/2;
for (int i=0; i<N; i++)
{
x=Left+(i+1)*dx;
if (i==active){
setcolor(ACTIVE_COLOR);
fillellipse(x,y,dx-7,dy-5);
setcolor(ACTIVE_COLOR);
}
else
setcolor(PASSIVE_COLOR);
outtextxy(x,y,Items[i]);
}
}
viod Cat(void)
{
setcolor(RED);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, GREEN);
bar(MIAU_X, MIAU_Y, MIAU_X+100, MIAU_Y+50);
outtextxy(MIAU_X, MIAU_Y, "Mi-a-a-u!!!");
outtextxy(MIAU_X, MIAU_Y+30, "push and key");
getch();
}
viod Mouse(void)
{
setcolor(GREEN);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, RED);
bar(MIAU_X, MIAU_Y, MIAU_X+100, MIAU_Y+50);
outtextxy(MIAU_X, MIAU_Y, "Pi-pi-pi!!!");
outtextxy(MIAU_X, MIAU_Y+30, "push and key");
getch();
}
viod Dog(void)
{
setcolor(YELLOW);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, BROWN);
bar(MIAU_X, MIAU_Y, MIAU_X+100, MIAU_Y+50);
outtextxy(MIAU_X, MIAU_Y, "Gaw-gav!!!");
outtextxy(MIAU_X, MIAU_Y+30, "push and key");
getch();
}
viod Sheep(void)
{
setcolor(BLUE);
settextstyle(0, HORIZ_DIR, 1);
settextjustify(LEFT_TEXT, TOP_TEXT);
setfillstyle(SOLID_FILL, WHITE);
bar(MIAU_X, MIAU_Y, MIAU_X+100, MIAU_Y+50);
outtextxy(MIAU_X, MIAU_Y, "Be-e-e-e-e!!!");
outtextxy(MIAU_X, MIAU_Y+30, "push and key");
getch();
}
указывает на строку int Key = GetKey();error 21 function `GetKey` should have a prototype
Укажите в чем ошибка и как исправить?
--------------------------------------------------------------------------------
Добавлено сообщение
--------------------------------------------------------------------------------
Спасибо. С этим понял прочел о функции зарепил.
Код: Выделить всё
case kbEnter;
Нашел сам ошибка ;
--------------------------------------------------------------------------------
Добавлено сообщение
--------------------------------------------------------------------------------
Код: Выделить всё
case kbSpace: Funcs[choice](); break;
--------------------------------------------------------------------------------
Добавлено сообщение
--------------------------------------------------------------------------------
ну что есть решение в этой задачке?