Below here is word for word from my assignment. We did just go over arrays in our last chapter and I did struggle to understand everything along with file streaming (assuming thats even whats expected). I'm not looking for code, just some help breaking it down so it makes more sense. I should add, this chapter we are learning pointers so I'd assume that would play apart in the assignment:
Write a function that accepts an int array and the arrays’ size arguments. The function should:
1. create a new array that is twice the size of the argument array.
2. copy the contents of the argument array to the new array and initialize the unused elements
of the second array with 0.
3. return a pointer to the new array.
Demonstrate the function by using it in a main program that reads an integer N (that is not more
than 50) from standard input and then reads N integers from a file named data into an array (DO
NOT use an absolute path to the data file). The program then passes that array to your array
expander function, and displays the values of the new expanded array, one value per line.
You may assume that the file data has at least N values. If the integer read in from standard input
exceeds 50 or is less than 0 the program terminates with an appropriate message.
Aucun commentaire:
Enregistrer un commentaire