delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/21/16:22:02

From: "Al Amzeen (Alexandr Amzin)" <amzeen AT mtu-net DOT ru>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Arrays in C or a completely new way to restart your PC ;-)
Date: Fri, 21 Apr 2000 22:18:35 +0400
Organization: Fidolook Express page http://fidolook.da.ru
Lines: 65
Message-ID: <8dqa9s$l3$1@gavrilo.mtu.ru>
References: <0fd549f4 DOT 922d8d61 AT usw-ex0110-075 DOT remarq DOT com>
NNTP-Posting-Host: ppp109-93.dialup.mtu-net.ru
X-Trace: gavrilo.mtu.ru 956345469 675 212.188.109.93 (21 Apr 2000 19:31:09 GMT)
X-Complaints-To: usenet-abuse AT mtu DOT ru
NNTP-Posting-Date: 21 Apr 2000 19:31:09 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Fidolook Express V1.51rus for MS OE 5.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Greetings, Bernhard Stiftner <stiftnersoftwareNOstSPAM AT gmx DOT net DOT invalid>! You
wrote:
> Hi everyone...
Hi :).

> reboot a PC (even when running Windows), although I just
> wanted to declare an array in C  ;-) ...
Negative result is also a result ;).

(skip)
> I wanted to set up an array of pointers to some BITMAP
> structures of Allegro:
> BITMAP *ani1[5]; /* I think this sets up an array of 6
> pointers (ranging von 0 to 5) to these BITMAPs */
> PALLETE junk;
No. Stop. The bug crawling right here (honestly speaking, not right here but
in you comments and understanding. By declaration of massive:

BITMAP *ani1[5];

you declaring ONLY FIVE bitmaps in array -- from zero to four not including
five.

> void load_animation(void) { /* load the files ANI000.BMP to
> ANI005.BMP into the array */
>   int i;
>   char *str;
>   char *buf;
>   char *fname;
>   for (i=0; i<6; i++) {
So, that string needs to be changed:
for (i=0; i<5; i++) {
>     itoa(i-1, str, 10);
Looks pretty nice.  Is it starting from -1?  Try to change it to 'i'.
>     buf = strcat("ani100", str);
>     fname = strcat(buf, ".bmp");
>     ani1[i] = load_bitmap(fname, junk);
>     }
>   }
>
> void unload_animation(void) {
>   int i;
>   for (i=0; i<6; i++) {
And that too.
>     destroy_bitmap(ani1[i]);
>     }
>   }
> So, I don't know what's wrong with my code...


> PS: I'm currently trying to teach C/C++ myself (not an easy
> task - after all, I'm a 15 years old student and I have to
> invest ***huge*** amounts of time in school (although I try
> to reduce that to the absolute minimum...)), so I hope you
> understand that I'm having some problems with C/C++ [after
> I've got used too much to really easy things like pascal...]
btw, Pascal was created for teaching structural priogramming and C was
created for implement it for the most effective way ;).

> PPS: Feel free to use my code in your own programs - that's
> really useful stuff!!!  :-)
> PPPS: Don't laugh!!!
Ok, I will not as it is your license stuff :).


- Raw text -


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