Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

dynamic memory in c++

#include <iostream>

int main()
{
  int* ptr = new int(5);
  
  int* arr = new int[3];
  arr[0] = 96;
  arr[1] = 45;
  arr[2] = 72;
  
  std::cout << *ptr << "
";// output: 5
  
  for (int i = 0; i < 3; i++)
  {
    std::cout << arr[i] << " ";
  } // output: 96 45 72
}
 
PREVIOUS NEXT
Tagged: #dynamic #memory
ADD COMMENT
Topic
Name
6+8 =