How can I realloc in C++? It seems to be missing from the language – there is new and delete but not resize!
I need it because as my program reads more data, I need to reallocate the buffer to hold it. I don’t think deleteing the old pointer and newing a new, bigger one, is the right option.
Use ::std::vector!
becomes
Then
becomes
If you want to pass pointer into function, instead of
use
It is absolutely correct C++ code, because vector is a smart C-array.