From: varobert AT colba DOT net Message-Id: <3.0.32.19990801181614.007b9130@mail.colba.net> X-Sender: varobert AT mail DOT colba DOT net X-Mailer: Windows Eudora Pro Version 3.0 (32) Date: Sun, 01 Aug 1999 18:16:16 -0400 To: djgpp AT delorie DOT com Subject: Re: BITMAP pointers w/ Allegro. Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com Ok, you might want to try one of the following: main(void) { //init the screen mode, palette, etc. BITMAP *bmp; function(&bmp); //Blit, animate, transform, etc. } void function(BITMAP** bmp) { *bmp = create_bitmap(320, 240); return; } function must be declared void in this case because C/C++ default to int if the type is not specified. You must also pass the adress of the bitmap to the function because the value of bmp gets changed when allocating memory for it. Or, you may want to try this: main(void) { //Init the screen mode, palette, etc. BITMAP *bmp = function(); //Blit, animate, etc. } BITMAP *function() { BITMAP *bmp = create_bitmap(320, 240); return bmp; } At 03:19 PM 8/1/99 -0700, you wrote: > I've got a beginners question about the BITMAP pointer. I have a >program that is generally structured like so: > >main(void) >{ > BITMAP *bmp; > function(bmp); >} > >function(BITMAP *bmp) >{ > bmp = create_bitmap(320, 240); >} > > This small program seems to make 2 bitmap data structures when I only >want one, because whenever I try and use the newly created bitmap later in >the main() function, it gives me crazy values which seem uninitalized. How >do I pass the bitmap by reference so I can edit its value in sub-functions? >What am I doing wrong? Thanks for any comments! > -Ike > > > - GodOfWar Computers are getting faster, smaller and cheaper with time. Does that mean that Microsoft invented time travel ?