We continued to develop our linked list code, adding a recursive append function as well as iterative and recursive delete functions. Our final version of the code can be found in
I augmented this code with a recursive delete function,
deleteRecurReturn
that performs the delete through the
return, instead of through the paramenter. It is thus passed a
ListNode;nbsp;*
instead of a ListNode **
.
Make sure you read and understand this function!
We now step back a minute from arrays and pointers and look at the larger picture and issues of source code decomposition into separate files.
Let's look at arrDemo2.c next. It's the exact same program as one of our old array programs EXCEPT:
There's some tricky looking stuff in arraylib.h - the #ifndef pre-processor directive. This is to prevent multiple includes of the same source (since recall that #include implies copy and paste). We'll discuss this in lecture.
To successfully compile the arrDemo2.c program, we need to compile both arrDemo2.c and arraylib.c together, i.e., gcc -ansi -pedantic -Wall arrDemo2.c arraylib.c
Why don't we need to list the .h files on our gcc compilation command line?