#### How to solve a While loop that suddenly terminates itself?

**So, I have code to look for permutations. This code essentially takes input from the user until the user is satisfied with the input. However, when receiving more than 4x input, the code suddenly stuck/terminated itself. I’ve tried changing the array type to dynamic memory (I don’t really understand the concept), but the result is still the same.

Strangely when I test this code using http://cpp.sh/ it runs normally. I think the problem is on my computer (I used VS code and mingw to compile and run it. What do you think is wrong?**

``````#include <iostream>
#include <string>
using namespace std;

int main() {

int KombAngka;
bool Lanjut = true;
int x = 0;
int *Angka = new int(x);

string YaTidak;

while(Lanjut) {

cout << "Number-" << x + 1 << ": ";
cin >> Angka[x];

LoopYaTidak:

cout << "Are the numbers enough?(y/n)?: ";
cin >> YaTidak;

if (YaTidak == "y") {
Lanjut = false;
}
else if (YaTidak == "n") {
Lanjut = true;
}
else {
cout << "Enter the correct answer!(y/n)" << endl;
goto LoopYaTidak;
}

x++;

}

cout << "All numbers: (";

for (int z = 0; z <= x - 2; z++) {
cout << Angka[z] << ", ";
}

cout << Angka[x - 1] << ")" << endl;

cout << "The number of combinations of numbers used: ";
cin >> KombAngka;

int JumlahAngka = x;
const int StopLoop = JumlahAngka - KombAngka;

for (int i = JumlahAngka - 1; i > StopLoop; i--) {
JumlahAngka = JumlahAngka * i;
}

cout << "The number of queue numbers consisting of " << KombAngka << " different numbers are " << JumlahAngka << endl;

system("pause");
return 0;
}

``````

Source: Windows Questions C++