Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how could I resize an array

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How could I possibly resize an array in Visual C++? I don't need to keep the data, I just need to resize a 2-D array, thanks for the help

 
You can use STL data structures such as 'vetor' or 'set'
#include <vector> or #include <set>
Read documentation in MSDN (Also on microsoft's site)
These are very easy to use and can be sorted by inner methods.
 
or you could do a wasteful, but easier to follow way such as

char* array1 = new char[size];
.
.


char* array2 = new char[size2]

for (int i = 0; i < sizeof(array1); i++)
array2 = array1;

delete[] array1;

(ie create a new array of whatever size, copy, delete the old one)
 
Sorry, for some reason the indexes didn't show up,


its supposed to be

array2 = array1;
 
#include<stdlib.h> and use realloc John Fill
1c.bmp


ivfmd@mail.md
 
ok for whatever reason the &quot;'open square bracket' i 'close square bracket'&quot; does not show up in this forum. sigh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top