1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
 
using namespace std;
 
int main()
{
    int* arr = nullptr;
    int* temp = nullptr;
 
    for (int i = 1; i <= 100; i++) {
        arr = new int[i];
        arr[i - 1= i;
        if (temp != nullptr) {
            for (int j = 0; j < i; j++) {
                arr[j] = temp[j];
            }
        }
        delete[] temp;
        temp = new int[sizeof(arr) / sizeof(int)];
        for (int j = 0; j < i; j++) {
            temp[j] = arr[j];
        }
        delete[] arr;
        cout << "반복" << i << endl;
    }
 
    return 0;
}
cs


for 문 돌리면서 i크기의 동적배열을 만들어서 값을 넣고 그 값을 temp에 보관한 다음에 arr은 해제하고, 다시 새롭게 늘어난 i크기 만큼 동적할당을 해주고 temp에 보관해놓은 걸 가져와서 넣어주고 하는 코드입니다.
근데 이게 한 20번에서 30번 정도 돌다보면 작동이 중지되는데 왜 그런지를 모르겠습니다.
아예 안되면 몰라도 왜 중간에 멈추는지 모르겠네요...... 
도와주세요 ㅠㅠ