/* testalloc1.cpp CIS 150 David Klick 6/26/08 Demonstration of allocating memory. */ #include using std::cin; using std::cout; void cont(); int main() { // create a new double memory location and store the pointer double *p1 = new double; // displays whatever was in that location // some implementations may set the memory to 0 values cout << *p1 << '\n'; // must access new location through pointer *p1 = 1.23456; cout << *p1 << '\n'; // free the memory we allocated delete p1; cont(); return 0; } /* void cont(); Arguments: none Returns: nothing Clears input buffer and pauses waiting for user to press Enter. */ void cont() { if (cin.rdbuf()->sungetc() != -1 && cin.get() != '\n') cin.ignore(80,'\n'); cout << "Press enter to continue..."; cin.get(); }