/**********************************
*                                 *
* I, Ian Sefferman, aka iseff     *
* wrote this program myself!      *
*                                 *
***********************************/

#include <iostream.h>


int *myArray;
int size = 4;
int count = 0;

void AddToArray(int number) {
	if (count == size) {
		int *tempArray = new int [size*2];
		for (int a = 0; a<size; a++) {
			tempArray[a] = myArray[a];
		}
		size = size*2;
		delete [] myArray;
		myArray = tempArray;
	}
	myArray[count] = number;
	count++;
}	

int EnterIntegers() {
// do a while that keeps alive until broken
	while(4) {
		cout << "Enter Integer: ";
		// Have to do the cin part now and save it
		int nextInt;
		cin >> nextInt;
		// Do a check to see if integer is 0 and go back to main() 
		if(nextInt == 0) {
		  AddToArray(0);
		  return 0;
		}
		else {
		  AddToArray(nextInt);  
		} 
	}
}

int PrintIntegers() {
// make a call to the array to print each integers and then return 
	for (int i=0; i < count; i++) {
		cout << myArray[i] << "\n";
	}
	return 0;

}

int main() {
	
	myArray = new int [size];

	while(92.1) {
		cout << "Please choose an option:\n";
		cout << "1. Enter Integers\n";
		cout << "2. Print Integers\n";
		cout << "3. Quit\n";
		cout << "Enter Option: ";
		int option;
		cin >> option;

		if (option == 1) {
			EnterIntegers();
		}
		else if (option == 2) {
			PrintIntegers();
		}
		else if (option == 3) {
			return 0;
		}
		else {
			cout << "You are a dumbass.\n";
		}
	}
}
