"Greg P." <> wrote in message
news

1y1b.3347$ nk.net...
> "Allen" <allen-terri-> wrote in message
> news:OJx1b.109648$...
> | I have an array that I don't know the size requirement until
run-time.
> | The way I handle this is:
> |
> | int* piMyData;
> |
> | piMyData = (int*)LocalAlloc(LPTR, sizeof(int)*iDataCount);
> //MS-specific
>
> Remember that you are posting to a "C++" newsgroup, not "C":
> piMyData = static_cast<int*>(LocalAlloc(LPTR, sizeof(int)*iDataCount));
>
> | I also have a 2D char array that I don't know the size requirement
> until
> | run-time. Is there a similar method for handling this?
>
> Do you mean similar in terms of using native win32 (non standard) methods?
> That is off topic here. There is a simple way that many novices use to
> figure out the total size of any array (though it is frowned upon):
>
> size_t size = sizeof(array[0][0]) * sizeof(array);
Hi Greg,
No, I'm not trying to determine the size. Also, I'm using a very old
compiler that doesn't have vectors and besides, I don't have any experience
using the STL.
I'm looking for a method similar to the first one I gave to create
storage for a 2D array that I don't know the size of until run-time (at
which time, I do).
In the first example, I get iDataCount and create an array at piMyData.
Then, I can:
piMyData[i] = iSomeInt;
I want to get iXCount and iYCount and create a 2D array that I can
access:
pszMyData[x][y] = "a";
--
Best wishes,
Allen
No SPAM in my email !!