delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/27/00:01:22

From: myknees AT aol DOT com (Myknees)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: readkey()
Date: 27 Jan 1998 04:49:00 GMT
Lines: 48
Message-ID: <19980127044900.XAA01251@ladder01.news.aol.com>
NNTP-Posting-Host: ladder01.news.aol.com
References: <34CD2F30 DOT 65C7 AT usa DOT net>
Organization: AOL http://www.aol.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019