Mail Archives: djgpp/1998/01/27/00:01:22
In article <34CD2F30 DOT 65C7 AT usa DOT net>, Kharis Knightwind <kknightwind AT usa DOT net>
writes:
>Hmm well I was messing around with the allegro
>readkey command and it
>gave me this starnge errorhere is the code.
>
>{
> int
>allegro_init();
> int install_keyboard();
>
> printf("think I got it.\n");
> int readkey();
> return(0);
>}
>
>and when its compiling Rhide says there is a parse
>error before int in
>the readkey line...yet if I place that line somewhere
>else it doesnt say
>anything..plus it doesnt work...just
>wonderin.
Begginer that I am, it looks like you have declared the function readkey()
instead of using it. The "int" before the function shows that it is a
declaration. The compiler complains because it expects to see declarations
before you start doing other stuff in the function.
e.g.
int main()
{
/*declare & sometimes initialize stuff */
int i = 2;
int aFunction(); /* declares a function that's */
/* defined elsewhere */
/*use stuff */
printf("the number is %d\n", i);
aFunction();
return 0;
}
However, you don't have to declare the readkey() function because it is already
declared in the allegro.h file. All you have to do is #include that file.
Then you can just write stuff like the ex1.c file in your allegro/examples
directory.
--Ed (Myknees)
- Raw text -