Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3A. Complete load_pts_file function that reads multiple pairs of numbers from a file and finds the distance between every two numbers on a number line:
3A. Complete load_pts_file function that reads multiple pairs of numbers from a file and finds the distance between every two numbers on a number line: Few steps as the guidance 1) Open/Read the .dat file into a pre-allocated given space, data_buffer. 2) The format is fixed in every single line of the file, parse the content and interpret each as an integer number. 3) Finding distances from the every-two-number, iteratively store the distance to an integer array (note: the base address is given in $a1 ). 4) Return the number of distances calculated. For example, The above example shows that load_pts_file function - opens/reads lab3_pts.dat file (into data_buffer), - parses and interprets ' 1 ' as the integer numbers, 1 , and ' 2 ' as 2 - finds the distance of 1 and 2 to be 1 and updates the distance array - repeats the above two until the end of file, then returns 4 distances calculated. NOTE: you can safely assume I. the file will strictly follow such SPACE > format in every single line. II. there will be at least one line in the file. III. The file won't exceed 300 bytes, i.e. you don't need to worry about out of memory in the given space, data_buffer. IV. The default values in data_buffer were all 0. Arguments and Given parameters: >> \$a0: the address of the string that represents the input file name, "lab3_pts.dat". >> a1 : the base address of an integer array that will be used to store distances >> 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started