Is there any equivalent function of memset for vectors in C++ ?
(Not clear() or erase() method, I want to retain the size of v
You can use assign method in vector:
Assigns new contents to the vector, replacing its current contents, and modifying its size accordingly(if you don't change vector size just pass vec.size() ).
For example:
vector vec(10, 0);
for(auto item:vec)cout<- 1
for(auto item:vec)cout<
Cited: http://www.cplusplus.com/reference/vector/vector/assign/