Programmer. 2016. 1. 28. 16:20

소스)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include<array>
#include<iostream>
 
#define Max_Size 10
 
void print(std::array<int, Max_Size> Target_Array)
{
    for (std::array<int, Max_Size>::iterator IterPos = Target_Array.begin(); IterPos != Target_Array.end(); ++IterPos)
        std::cout << *IterPos << " ";
    std::cout << std::endl;
}
void main()
{
    std::array<int, Max_Size > Array = { 0, };
    print(Array);
    Array.assign(5);
    print(Array);
}
cs


설명)


array에서의 assign(x) 함수는 배열의 모든내용이 뭐가 있든간에 전부 x값으로 채우게 됩니다.


갯수를 지정할 수는 없으며 배열 모든곳에 채워 주게됩니다.



결과)