Creating dynamic arrays

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 69
Reputation: DotNetUser is an unknown quantity at this point 
Solved Threads: 0
DotNetUser DotNetUser is offline Offline
Junior Poster in Training

Creating dynamic arrays

 
0
  #1
Feb 28th, 2006
I'm coding in VC++.net (managed C++). Is there a way to create dynamic arrays and preserving the data when the dimensions are changed? I know that Visual Basic can do this.

In VB:
ReDim Preserve mLn(UBound(mLn) + 1)
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: Creating dynamic arrays

 
0
  #2
Feb 28th, 2006
In C you would use realloc(). In C++ you have to emulate it. Allocate the new area, copy the old stuff to the new area, and free the old area.
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC