Lab #3 CS-2050 – Section B

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (3 votes)

1 Requirements
This lab is intended to test your ability to do pointer arithmetic. You will be provided with a main file in
your starter code, but any testing code you produce will not be graded in this lab.
1.1 loadGameScores
int * loadGameScores ( FILE * file , int * startIndex , int * length ) ;
Info: This function will read integers representing player counts into a dynamically allocated array
from the given file pointer. The first number in the file should be interpreted as the size of the resulting
array, and the second number in the file should be interpreted as 1 + the last index of the resulting
array. This function must check that the call to malloc() succeeds, such that the array was successfully
allocated.
The starting index of the array must be stored in the startIndex variable, and the size of the array
must be stored in the length variable, such that they both can be used in the calling function. The
pointer returned from this function must be offset by the correct amount, such that it can be properly
accessed using the startIndex variable in the calling function.
i
1.2 freeIntArray
void freeIntArray (int ** array , int startIndex ) ;
Info: This function takes a double int pointer as well as the starting index of the given array, and
frees the memory being pointed to. This function should also set the pointer to NULL in the calling
function.
i
2 Notice
Grading:
1. Write required read from file function
* 8 points
2. Write required free array function
* 4 points
!
1
Notice:
1. All of your lab submissions must compile under GCC using the −W all and −W error flags to be
considered for a grade.
2. You are expected to provide proper documentation in every lab submission, in the form of
code comments. For an example of proper lab documentation and a clear description of our
expectations, see the lab policy document.