In Class Week8: Thursday
Copy the files for today's class into your week8 directory, then change
into that directory and check the contents:
% cd ~/cs21/
% mkdir week8
% cd week8
% cp ~newhall/public/cs21/week8/ptrexample.c .
% cp ~newhall/public/cs21/week8/printaddr.c .
% cp ~newhall/public/cs21/week8/dynarray.c .
% ls
- Open up the ptrexample.c and we will trace through it together in
class.
- Open printaddr.c and add the arguments to the printf
statements to printout the specified value. Compile and run your program.
What does this tell you about where different variables are located in
memory?
- Open dynarray.c. You will implement a function that returns a
dynamically allocated array of int values initialized with values entered
by the user. The function will read in a value for the number of ints to
be read in (the size of the array), dynamically allocate an array of that
size, and then fill it with values entered by the user. The function will
return the dynamically allocated array, and will "return" the size of
the array using pass-by-reference.