Export (0) Print
Expand All

array::fill

Erases a array and copies the specified elements to the empty array.

void fill(
   const Type& _Val
);

Parameter

Description

_Val

The value of the element being inserted into the array.

fill replaces each element of the array with the specified value.

// array_fill.cpp
// compile with: /EHsc
#include <array>
#include <iostream>

int main( )
{
   using namespace std;
   array<int, 2> v1 = {1, 2};
   array<int, 2>::iterator iter;

   cout << "v1 = " ;
   for (iter = v1.begin(); iter != v1.end(); iter++)
      cout << *iter << " ";
   cout << endl;

   v1.fill(3);
   cout << "v1 = " ;
   for (iter = v1.begin(); iter != v1.end(); iter++)
      cout << *iter << " ";
   cout << endl;
}

v1 = 1 2
v1 = 3 3

Header: <array>

Namespace: std

Show:
© 2014 Microsoft