Toledo
0
Q:

c++ vector fill

#include <algorithm>
#include <vector>
 
std::fill(v.begin(), v.end(), value);
1
// C++ program to demonstrate working of fill() 
#include <bits/stdc++.h> 
using namespace std; 
  
int main() 
{ 
    vector<int> vect(8); 
  
    // calling fill to initialize values in the 
    // range to 4 
    fill(vect.begin() + 2, vect.end() - 1, 4); 
  
    for (int i = 0; i < vect.size(); i++) 
        cout << vect[i] << " "; 
  
    return 0; 
} 
0

New to Communities?

Join the community