Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int* AllocateDynamicMemory(int size) {
- int* dynamicArray = new int[size];
- return dynamicArray;
- }
- void PrintDynamicArray(int* Array,int size)
- {
- for(int i = 0; i < size; i++)
- {
- cout << *Array++ << " ";
- }
- }
- void FillDynamicArray(int* Array, int size)
- {
- for (size_t i = 0; i < size; i++)
- {
- *(Array + i) = rand() % 100;
- }
- }
- void DeleteDynamicMemory(int* memory)
- {
- delete[] memory;
- cout << " Memory DeAllocated " << endl;
- }
- int main()
- {
- int size = 10;
- int* Array = AllocateDynamicMemory(size);
- FillDynamicArray(Array, size);
- cout << " Press Enter to Delete Array " << endl;
- cin.get();
- DeleteDynamicMemory(Array);
- cin.get();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement