fill () function to use

 

 

 

 

fill () function can be a certain period or interval array for a vessel is assigned the same value. A substantially with memset place.

Test code:

#include<iostream>

#include<algorithm>

using namespace std;

int main () {

int a[3] = {1,2,3};

fill(a,a+3,3);

for(int i=0;i<3;i++)

cout<<a[i]<<endl;

vector<char> v(5);

fill(v.begin(),v.end(),'*');        

for(auto it=v.begin();it!=v.end();it++)

cout<<*it;

}

Output:

3

3

3

*****

Guess you like

Origin www.cnblogs.com/younanyihu/p/12366952.html