Lab 3 - 2D Array Linked List

The purpose of this lab is to learn how to compile and edit pure C code by adding to the main() function of a 2D array implementation of linked lists.

Download the file lab3.c using wget, cp or vi copy/paste. Compile the code with the following command:

gcc -o lab3 lab3.c
The 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.

You run the resulting executable the same as you would C++ code:

./lab3
The main() function given in the code just adds numbers to the list. Your task for the lab is to add the following:
prompt the user for an element to search for
read in the element
call the search function and store its returned value
if search returned -1
  print/raise "Element not found" error
else
  call the delete function
  if the delete function succeeds
    print out the update list
  otherwise
    print/raise "Cannot delete" error
  end-if
end-if
All your code must be valid C code, not C++ code. Most of the C++ you learned in CMPS 221 (up to structures) is also valid C code. There are a few important differences however. You should familiarize yourself with C syntax now because some upper-division Computer Science classes are done with C instead of C++.

C code must use scanf() (or one of the other C input functions) for input and printf() (or one of the other C output functions) 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 Terry. If you work with a lab partner, be sure to CC the email to your lab partner or put BOTH of your names clearly in the email.