Vectors or Arrays?

Just as the title says, Vector or Arrays? Which do you prefer and why? Are there any true benefits from either one?
i prefer vectors in most cases
unlike arrays theyre dynamic in memory, they can be resized during the execution of program.

EDIT:
Example:

1
2
3
4
std::vector<int>vec(20,0); // vector of size 20 integers, all initialized with 0 value
vec.push_back(5); // vector can now store 21 integers, with value 5 at index 20
vec.push_back(4); // vector can now store 22 integers, with value 4 at index 21
vec.resize(50); // vector can now store 50 integers 

Last edited on
Topic archived. No new replies allowed.