#include "stdafx.h"
#include <iostream>
#include <sstream>
#include <string>
#include <new>
using namespace std;
int* makelist (int a)
{
cout << "Initializing memory for operation, please wait... \n";
int * lenghth;
lenghth = new (nothrow) int [a];
if (lenghth == 0)
{
cout << "ERROR ALLOCATING MEMORY!\n";
return 0;
}
cout << "Done!\n";
return(lenghth);
}
void clearmem (int * addy, int lenghth)
{
cout << "Freeing memory please wait...\n";
delete[lenghth] addy;
cout << "Done!";
}
void pause()
{
cin.ignore();
cin.get();
}
int main()
{
int a;
int a_const;
int * list_location;
cout << "Enter the number of numbers you want to find in the Fibonaci sequence.\n";
cin >> a;
a_const = a;
if (a == 0)
{
cout << "Ummmm so you started this program to not use it.... im not going\nto calculate the 0th number -.-\npress enter to close...";
pause();
return 0;
}
list_location = makelist (a);
clearmem(list_location, a_const);
pause();
return 0;
}



// rememb-o-matic
#include <iostream>
#include <new>
using namespace std;
int main ()
{
int i,n;
int * p;
cout << "How many numbers would you like to type? ";
cin >> i;
p= new (nothrow) int[i];
if (p == 0)
cout << "Error: memory could not be allocated";
else
{
for (n=0; n<i; n++)
{
cout << "Enter number: ";
cin >> p[n];
}
cout << "You have entered: ";
for (n=0; n<i; n++)
cout << p[n] << ", ";
delete[] p;
}
return 0;
}