CIS 150 Pointers and arrays lab

Objectives

  • Dynamically allocate an array
  • Free dynamically allocated memory
  • Access array elements using pointers
  • Pass pointers to functions

Requirements

  • Modify the supplied program (ptrLab.cpp) to make it work properly.
  • No global variables are allowed.
  • No [ ] are allowed except for steps 2 (dynamic allocation) and 9 (de-allocation). All array access must be done using pointer notation.

Program to be modified

Example run of program

68 58 58 52 44 43 74 55 69 12 16 12 58 62 11 85 17 80 48 49 84 77 9 66 58 The sum of the array is 1265 Records in file: 25 Sum of records in file: 1265

Rubric

  • Note: Points may be deducted for not having documentation comments, improper indentation, using tabs in the source code, and other violations of the style conventions used in this course.
  • 2 points: for getting the fillArray function working properly
  • 2 points: for getting the displayArray function working properly
  • 2 points: for getting the writeArray function working properly
  • 2 points: for getting the sumArray function working properly
  • 1 point: for allocating and de-allocating the dynamic array memory properly
  • 1 point: for having the mainline working properly