연속된 메모리 공간이며, 스텍에 할당됨
컴파일 단계에서 크기가 결정됨
* 배열의 2가지 스타일
1. c스타일
int a[10];
2. std스타일
array<int, 10> a;
코드
#include<bits/stdc++.h>
using namespace std;
int v[10];
int main()
{
for (int i = 1; i <= 10; i++) v[i - 1] = i;
for (int a : v) cout << a << " ";
cout << "\n";
auto a = find(v, v + 10, 100);
if(a == v + 10) cout << "not found" << "\n";
fill(v, v + 10, 10);
for(int a : v) cout << a << " ";
cout << "\n";
return 0;
}
'C++ > 기본 문법' 카테고리의 다른 글
<C++> string reverse(), substr() (0) | 2022.07.20 |
---|---|
<C++> fill과 memset, memcpy (0) | 2022.04.19 |
<C++> vector (0) | 2022.04.12 |
<C++> sort (0) | 2022.04.12 |
<C++> pair 와 tuple (0) | 2022.04.12 |