Mail Archives: djgpp/1999/08/01/20:28:54
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 ?
- Raw text -