Main PDF Lesson 5
Main PDF Lesson 5
Syntax:
typedef Known_Type_Definition New_Type_Name;
Example:
typedef int* IntPtr;
The type name IntPtr can then be used to declare
pointers to dynamic variables of type int, as in the
following:
a = new double[array_size];
delete [] a;
#include <iostream>
using namespace std;
int main(){
int size;
cout << "Enter size of an array "; Output:
cin >> size;
int *array = new int[size];
cout << "Input " << size << endl;
for (int i = 0; i < size ;i++)
{ cin >> array[i]; }
cout << "The contents of the array ";
for (int i = 0; i < size ;i++)
{ cout << array[i] << " "; }
delete [] array;
return 0;
}
https://www.geeksforgeeks.org/how-do-dynamic-arrays-work/
https://www.programiz.com/cpp-programming/pointers-arrays