Dynamically Extending Arrays?
-
Is it possible to dynamically extend an (int) array? I have an array of x elements, and at run time I want to add additional elements. ie. Array.push() The only way I can think of would be using memcpy and malloc, but that'd get a bit messy. Oh, and I'm using Dev C++.
-
Is it possible to dynamically extend an (int) array? I have an array of x elements, and at run time I want to add additional elements. ie. Array.push() The only way I can think of would be using memcpy and malloc, but that'd get a bit messy. Oh, and I'm using Dev C++.
normal array can not be extend Your best choice is using Vector (in C++ Standard Template Library - available with all C++ compiler). Vector allows direct access to elements and also works like a dynamic list.
-
Is it possible to dynamically extend an (int) array? I have an array of x elements, and at run time I want to add additional elements. ie. Array.push() The only way I can think of would be using memcpy and malloc, but that'd get a bit messy. Oh, and I'm using Dev C++.
yes, vector is good choice, except u wanna write a dynamic array by urself.
life is like a box of chocolate,you never know what you r going to get.