Mail Archives: djgpp/2000/02/03/12:15:06
From: | "Robert B. Clark" <rclark AT iquest DOT net>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: My program's a machine killer!
|
Organization: | ClarkWehyr Enterprises
|
Message-ID: | <0paj9sgcf064paiv56h1tb5aei3r0bncpk@4ax.com>
|
References: | <2d1m4.294$oU2 DOT 94919 AT tw12 DOT nn DOT bcandid DOT com>
|
X-Newsreader: | Forte Agent 1.7/32.534
|
MIME-Version: | 1.0
|
Lines: | 62
|
Date: | Thu, 03 Feb 2000 11:30:06 -0500
|
NNTP-Posting-Host: | 209.43.53.111
|
X-Trace: | news1.iquest.net 949595418 209.43.53.111 (Thu, 03 Feb 2000 11:30:18 EDT)
|
NNTP-Posting-Date: | Thu, 03 Feb 2000 11:30:18 EDT
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
"Brian" <none AT noemail DOT com> wrote:
>When I run the short little program below, my PC reboots. I don't have VESA
>so I set my graphics mode to VGA 320x200. I don't know if this is a problem.
I must preface this with the assertion that I am not familiar with
Allegro. That being said, I do have a few comments on your code.
>char *listbox_getter(int index, int *list_size)
>{
> static char *strings[] =
> {
> "Entry 1", "Entry 2", "Entry 3"
> };
>
> if (index < 0)
> {
> *list_size = 3;
> return NULL;
> }
You might want to also check for index > 2 here. Try this alternative:
#define NUM_ENTRIES 3
char *listbox_getter(int index, int *list_size)
{
static char *strings[NUM_ENTRIES] =
{
"Entry1", "Entry2", "Entry3"
};
if (index < 0 || index >= NUM_ENTRIES)
{
*list_size = NUM_ENTRIES;
return NULL;
}
else
return strings[index];
}
As a matter of fact (if it makes sense to the rest of your code), you
might want to consider making index and list_size unsigned ints or
size_t values, just to avoid having to check for the negative condition.
>#define LISTBOX_OBJECT 3
>
>int main(int argc)
This is an incorrect declaration. Either use
int main(void)
if you do not need the command line arguments, or
int main(int argc, char *argv[]) /* or equivalent */
if you do.
--
Robert B. Clark
Visit ClarkWehyr Enterprises On-Line at http://www.iquest.net/~rclark/ClarkWehyr.html
- Raw text -