0
How do I keep from wasting allocated memory?
I figured the basic code out but not sure how to refine it. https://code.sololearn.com/c05eQhmuY9vK/?ref=app
10 Answers
+ 11
use vector?
+ 9
I would just use push_back() for each item for now.
Vectors resize dynamically when ever new data is added.
You can use reserve [vector.reserve(size_t)] to make the vector array a certain size to increase the speed of adding items, but generally the speed gained is negligible.
+ 9
also try out <string> instead of char arrays. :)
+ 8
They are super easy. Think dynamically sized arrays.
+ 8
https://code.sololearn.com/c4XHX17H4Xvt/?ref=app
have a look at this code example. It may help
+ 1
I will mess with pointers. Have not learned alot about vectors yet. I understand what they are but not sure of working with them yet.
+ 1
@Jay. I am reading this. Is the shrink to fit member function what we qould use? Or am I jumping to far in.