List Print
For this activity, you will be looking at a linked list.
Download
list.h
,
or copy it into your current directory on a CSE system by running
$ cp /web/cs1511/17s2/week11/files/list.h .
Make sure you understand
the list
and node
data structures
before beginning this task.
Create a file called listPrint.c
that includes the list.h
header file.
In it, you should implement listPrint
,
a function which takes a linked list,
and prints it to standard output.
It should have this prototype:
void listPrint (List l);
It should print out the list in this format,
where X indicates the NULL
pointer
at the end of the list:
1 -> 2 -> 3 -> 4 -> X
Don’t forget to print a new line character!
You should write your own tests in a separate file;
listPrint.c
should not contain a main
.
You’ll need to think about
how to test a function’s side effects:
remember that printing to standard output
is a side-effect.
To run some simple automated tests:
$ 1511 autotest listPrint
To run Styl-o-matic:
$ 1511 stylomatic listPrint.c Looks good!
You’ll get advice if you need to make changes to your code.
Submit your work with the give command, like so:
$ give cs1511 wk11_listPrint
Or, if you are working from home, upload the relevant file(s) to the wk11_listPrint activity on Give Online.