Question: Exercise # 1 : Implement the getInputArray function [ 2 0 pts ] The first thing program hw 7 main program does is call

Exercise \#1: Implement the getInputArray function [20 pts]
The first thing program hw7 main program does is call a getInputArray function. The C prototype of this function is as follows:
char *getInputArray(int *num_elements);
You must implement this function in hw7 functions.asm (which contains an empty placeholder for it). Function getInputarray does:
- Reads a positive integer (the "element count", n)
- Sets * num_elements to n
- Allocates an array for \( n \) bytes
- Reads in n 1-byte positive integers and stores them in order in the array
- Returns a pointer to the first element of the array
To implement this function you need to allocate memory. To this end you should call the allocate memory function, which is provided in hw7 functions.asm. This function takes a number of bytes as argument and allocates a contiguous zone of this many bytes. Its return value is the address of the first bytes in that allocated zone.
Here are example interactions with the program for various input:
```
%./hw7_main_program
5
12
43
23
1
6
```
The 5 entered values are: 12432316
findFirstIndex not implemented!
\[
\begin{array}{l}
\%./ h w 7\_\text {main_program }\\
8\\
1
\end{array}
\]
Exercise \ # 1 : Implement the getInputArray

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 Programming Questions!