Description
1 Requirements
This lab is intended to test your ability to dynamically allocate memory. 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 readLongFromFile
long * readLongFromFile ( FILE * file , int * length ) ;
Info: This function will read Long Decimal Integers 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. This
function must check that the call to malloc() succeeds, such that the array was successfully allocated.
i
1.2 freeLongArray
void freeLongArray ( long ** array ) ;
Info: This function takes a double long pointer 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
* 7 points
2. Write required free array function
* 3 points
!
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.
!
1