Mail Archives: djgpp/1999/03/01/15:21:21

From: Endlisnis <s257m AT unb DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: VESA 1.2 Again.. And also an array of pointers
Date: Mon, 01 Mar 1999 14:51:47 -0400
Organization: BrunNet
Lines: 32
Message-ID: <>
References: <36D2EEAD DOT AFEA8808 AT geocities DOT com>
Mime-Version: 1.0
X-Mailer: Mozilla 4.04 [en] (Win95; U)
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

The Beyonder wrote:

> But first I need to learn how to create an array of
> pointers (dynamic array).  Is it done like this:
> long int *alpha = (long int *) malloc( number );
> alpha[x] = (long int *) address;
> I seriously think that this is wrong, how do I do it this?

long int** alpha = (long int **) malloc(number_of_expected_pointers);
alpha[x] = (long int *) address;

    With a single '*', you are only making an array of 'long int's.  The
second '*' makes it an array of integer pointers.  Remember, each entry in
that array (each alpha[x]) will have to be individually initialized:
for(int x=0; x<number_of_expected_pointers; x++)
 alpha[x] = (long int*) malloc(size_of_this_array);

PS:  In DJGPP "long int" is the same as "int".  Their both 32-bits.

     (\/) Endlisnis (\/)
          s257m AT unb DOT ca
          Endlisnis AT GeoCities DOT com
          Endlisnis AT BrunNet DOT Net
          Endlisnis AT HotMail DOT com

- Raw text -

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