Starting from:

$29

Exercise 2- Advanced Programming

Instructions: 
Step 1: Complete the ReadFile(), AddRecord() and DeleteList() functions according to the pseudo code provided. ReadFile() reads records from the file and calls AddRecord(). AddRecord() adds a record to the tail of the list (see week-3 lecture notes). DeleteList() deletes all the dynamic memory (records) in the list. Test your code with the main() provided to see that the records are being read and displayed on the screen via the DisplayAllRecs() function.
Step 2: Implement the FindRecord() function according to the pseudo code provided. FindRecord() should ask the user for a phone number and display the found record on the screen. Test your code again using the main provided.
Step 3: Implement the RemoveRecord() function according to the pseudo code provided. RemoveRecord() should display the record at the head of the list on the screen and delete it. Again, test your code using the main() provided.
Step 4: Replace the fixed size Name and Address arrays in the PhoneRecord struct with dynamic memory that is the same size as the strings. To do this replace the Name and Address arrays in the struct with char* pointers and modify the AddRecord() function so that it reads the name and address into a temp array and then allocates the right amount of memory to the struct pointers and copies the strings into that memory. Also, modify DeleteList() so that it also deletes the memory allocated to the dynamic arrays. Test your program again and make sure the output looks like “output.txt”.

More products