Pointers and Arrays

Intro Video

Funtions for Arrays

Static and Dynamic Arrays

Why do we need to pass size

Pointer Arithmatic

Resizing Arrays

copy over the files provided for you add the code described in the comments to main1.cpp add the code to perform each action directly under each comment
File: main1.cpp
``````
//  static arrays versus dynamic arrays
#include "cmpslib19.h"
#include "easylogging++.h"
INITIALIZE_EASYLOGGINGPP

void PrintArray(int*array,int size)
{
LOG(INFO) << "Start " <<  __PRETTY_FUNCTION__ << endl;
cout << "Array Address" << array << endl;
for(int loop =0; loop<size; loop++)
{
if(loop)
{
cout << ",";
}
cout << array[loop];
}
cout << endl;
LOG(INFO) << "End " <<  __PRETTY_FUNCTION__ << endl;
}

int main()
{
InitializeLogger("main1.log");

// create a static int array of size 20 named SIntArray

// create a dynamic int array of size 20 named DIntArray

// use a for loop to populate both arrays with the values 0-19 , use the [] operator

// use the PrintArray functions to print them both out

//use a for loop to populate both arrays with the values 0 to 100 in increments of 5
// loop from 0 to 19 and set the value to (loop*5)
// 0*5, 1*5, 2*5
// ,   do not use the [] operator

// use the PrintArray functions to print both arrays

// print out the address of the first  , second and fifth element of both arrays, use the & and [] operators

// print out the address of the first  , second and fifth element of both arrays, do NOT  use the & and [] operators

// create an int * temp

// set temp to the begining of SIntArray

// increment temp pointer by 4

//  print out the value ( address ) of temp  and the value it points to

// set temp to the begining of DIntArray

// increment the pointer by 4

//  print out the value ( address ) of temp  and the value it points to

// clean up the Dynamic array
return 0;
}

``````

use the runable example as a guide
File: sample_output
``````
SIntArray:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
DIntArray:
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
SIntArray:
0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95
DIntArray:
0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95
SIntArray:
1st:0x7fffc955f750
2nd:0x7fffc955f754
5th:0x7fffc955f760
DIntArray:
1st:0x55a10d84c7d0
2nd:0x55a10d84c7d4
5th:0x55a10d84c7e0
SIntArray:
1st:0x7fffc955f750
2nd:0x7fffc955f754
5th:0x7fffc955f760
DIntArray:
1st:0x55a10d84c7d0
2nd:0x55a10d84c7d4
5th:0x55a10d84c7e0
temp contains the address 0x7fffc955f760 and points to the value 20
temp contains the address 0x55a10d84c7e0 and points to the value 20
``````

```to get a good grade
------------------
1. make sure your code compiles without warnings
2. make sure your output matches the example
3. if a comment says to do something , do it right below that comment line
4. at the VERY LEAST log the start and end of all functions
```