Use std::fill:
std::fill(vect.begin(), vect.end(), 100);
Note that if you want to initialize a vector with the same value, you can use the appropriate constructor:
std::vector<int> v(5, 100);
assign can be used to "reset a vector", but if you just create a vector, use the constructor.
source
share