The purpose of this lab is to add the tail
index to a 2D array
implementation of a linked list. The secondary purpose of this lab is to learn
how to compile and edit C code, as opposed to C++ code.
Download the file 2d_array_list.c and compile it with the following command:
gcc -o lab3 2d_array_list.cThe
gcc
command invokes the C compiler. It uses the same command
line options as g++
. The file extension .c
is used
for C source code, while the extension .cpp
is reserved for C++
source code.
You run the resulting executable the same as you would C++ code:
./lab3The file contains a 2D array implementation of linked lists which does NOT have a tail index. Your task for this lab is to implement the tail index, as discussed in class on Monday. You will need to do the following things:
init()
, insert()
and
delete()
functions to set the index appropriately.
menu()
function to have an option to do a
tail insertion:
7. Insert an item at the tail of the list
main()
to support Option 7.
It will prompt the user for an integer, read it in and then call
insert()
. It will use the index of the tail for the position
parameter for insert()
C code must use scanf()
for input and printf()
for
output. You can NOT use cin or cout. See the provided main()
for
how to use scanf()
and printf()
in C.
Additionally, your comments must be in the /* comment */
format
and cannot be // comment
. And C does not support the
bool
datatype, nor the keywords true
and
false
. You have to use the integer equivalents of 0 and 1 in
C code, as the provided code does.
Email your updated source code to me.