Question: Complete save _ dist _ list function that saves N distances' values into a file For example, Integer Array for Distances Number of Distances to

Complete save_dist_list function that saves N distances' values into a file For example,
Integer Array for Distances
Number of Distances to Save
lab3_dist.dat
[1,1,7,23,-1]
4
11723
Note: the NEWLINE character (at the end of every line) is not visible.
The above example shows that save_dist_list function takes 4 distances from the distance array, converts integers into ASCII characters, as a result of "11723" in the data_buffer, then makes syscall to write 9 characters from this string into lab3_dist.dat file.
NOTE: you can safely assume
I. The distances to save are guaranteed positive/valid, e.g. N=4, the first four numbers in the array must be positive.
Arguments and Given parameters:
>> $a0: the address of the string that represents the output file name, "lab3_dist.dat".
Thought before starting to code: How to convert 23 into '2','3'? other examples, 123->'1',
'2','3'?
>> $a1: the base address of an integer array that stores distances
>> $a2: the number of distances to save from an integer array
>> data_buffer: the buffer that you use to hold data for file read/write (MAXIMUM: 300 bytes)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!