delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/06/22:33:51

From: varobert AT colba DOT net
Message-Id: <3.0.32.19990706223331.0079f100@mail.colba.net>
X-Sender: varobert AT mail DOT colba DOT net
X-Mailer: Windows Eudora Pro Version 3.0 (32)
Date: Tue, 06 Jul 1999 22:33:43 -0400
To: djgpp AT delorie DOT com
Subject: Re: Dynamic Array - Need HELP
Mime-Version: 1.0
Reply-To: djgpp AT delorie DOT com

Why would the size of a pointer be 8 bytes long ? Shouldn't it be 4 bytes ?

At 10:55 PM 7/4/99 -0500, you wrote:
>> I want to create a array of size mpx by mpy.
>> After this code, sizeof(v) = 8, why ???
>> 
>
>well, because v is a pointer to a pointer, and the size of any pointer is
>8 bytes.  don't worry, your memory is allocated fine, it's just that since
>it is dynamically allocated, you can't use sizeof() to check how much
>memory you allocated.
>
>mark
>
>> unsigned char **v;
>> int mpx,mpy,i;
>> 
>> mpx=64;
>> mpy=48;
>> 
>> v = new unsigned char*[mpy];
>> for(i=0;i<mpy;i++)
>> {
>>   v[i]=new unsigned char[mpx];
>> }
>> 
>> 
>> 
>> 
>> 
>
>

- Raw text -


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