Pointers and Arrays


Intro Video

Functions for Arrays

Static and Dynamic Arrays

Why do we need to pass size

Pointer Arithmetic

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 const *array,int size)
{
	LOG_S;
	cout << "Array Address" << array << endl;
	for(int loop =0; loop<size; loop++)
	{
     // array[loop]++;
     // the above line would change the values in the array
     // but since we dectared it to be const the compiler 
     // would not let it compile, this fucntion has no need to change the elements in the array
     // so it really should be a const itnt *

		if(loop)
		{
			cout << ",";
		}
		cout << array[loop];
	}
	cout << endl;
	LOG_E;
}

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:
Array Address0x7ffdf8aa9ba0
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
DIntArray:
Array Address0x5608872c97d0
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19
SIntArray:
Array Address0x7ffdf8aa9ba0
0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95
DIntArray:
Array Address0x5608872c97d0
0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95
SIntArray:
1st:0x7ffdf8aa9ba0
2nd:0x7ffdf8aa9ba4
5th:0x7ffdf8aa9bb0
DIntArray:
1st:0x5608872c97d0
2nd:0x5608872c97d4
5th:0x5608872c97e0
SIntArray:
1st:0x7ffdf8aa9ba0
2nd:0x7ffdf8aa9ba4
5th:0x7ffdf8aa9bb0
DIntArray:
1st:0x5608872c97d0
2nd:0x5608872c97d4
5th:0x5608872c97e0
temp contains the address 0x7ffdf8aa9bb0 and points to the value 20
temp contains the address 0x5608872c97e0 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