So I am trying to make a program that stores user input into a dynamic array but I cant do it right. When I try to put a number let us say 1, and I want to try again then I want to view history, the only thing that shows up is the last number I have input. And sometimes there is a large number sowing up like 1214098101909279242 like that.
Here is my code:
#include<iostream>
using namespace std;
int main(){
const int size = 20;
int *num = new int[size];
char answer;
while(true){
cout<<"ENTER NUMBER: \n";
cin>>*num;
cout<<"TRY AGAIN? ";
cin>>answer;
switch(answer){
case 'y':
num[size+1];
system("cls");
break;
default:
cout<<"INPUT HISTORY: \n";
for(int i=0;i<=size;i++){
cout<<num[i];
}
}
}
return 0;
}