Skip to main content

Goals 

  • Set up your git repository.
  • Review C programming topics.

Credits

This lab was developed by Prof. L. Felipe Perrone. Permission to reuse this material in parts or in its entirety is granted provided that this credits note is not removed. Additional students files associated with this lab, as well as any existing solutions can be provided upon request by e-mail to: perrone[at]bucknell[dot]edu

Academic Responsibility

It should go without saying that all the work that you will turn in for this lab will be yours. Do not surf the web to get inspiration for this assignment, do not include code that was not written by you, do not have AI generate code for you. You should try your best to debug your code on your own, but it’s fine to get help from a colleague as long as that means getting assistance to identify the problem and doesn’t go as far as receiving source code to fix it (in writing or orally).

Set Up

Choose a programming text editor to use. We will not use any IDE (such as Eclipse or Visual Studio) so that you can start to develop some self-reliance. (This will prepare you to transition into CSCI 315 later on.) Choose one of the two following editors to us this semester:

  • vim (classic; uses small amount of memory; widely available on barebones environments)
  • emacs (classic; not so small memory footprint)

There are reference cards and tutorials for these editors everywhere on the Internet; find one that works for you. You will want to know how to create new files, open files, save files, and use any editor functionality that might help you when writing programs.

All the programming work for this course will be turned in via a git repository. You need to take some time to set up your repo.

  • If you never generated your own ssh keys, open a terminal and run the ssh-keygen as follows.
    • Be sure to use the C option to specify your bucknell email (with quotes):
      ssh-keygen -t rsa -b 4096 -C “<your userid>@bucknell.edu”
    • Press enter to use the default file name for your key files.
    • Press enter to use an empty passphrase.
  • Open a web browser and follow the link https://gitlab.bucknell.edu to access  our Gitlab installation.
  • Authenticate with your Bucknell credentials.
  • Create a new (blank) project called csci307 (make sure to use all lowercase).
    • Enter csci307-S25 for Project name.
    • Look at the Project URL line. After the https://gitlab.bucknell.edu prefix, use the pull down menu to select your user id. In the next text entry box, enter cscsi307 for project slug.
    • Leave everything else with their default values and press the button Create project.
  • Back in your local terminal, run the following command:
    • git clone https://gitlab.bucknell.edu/YOURUSERID/csci307-sp25.git
    • Provide your system credentials (user id and password), if you are asked for them.
  • Still at the terminal, change into your csci307 directory and inside it, create a Labs directory (with this exact name!). Next, inside ~/csci307/Labs, create a directory called Lab1. In future labs, you will need to create one such directory for each of the lab assignments.

Dig deeper into git. If you want to start exploring features of git that you don’t quite master,  here’s a tutorial to get you started; feel free to look for others if you don’t like it. YouTube has many interesting video tutorials, if your learning style is more visual.

As you are working with the C language, http://cdecl.or) can help you “translate” a line of C code into English. It might come in handy when you are trying to understand whether the code you wrote really means what you think it means.

Before you start, do the following on a terminal:

cd ~/csci307/Labs/Lab1
cp ~perrone/csci307/Labs/Lab1/* .

Problem 1

Complete the code for the following functions in file slist.c: namely slist_create, slist_add_front, and slist_add_back. Instructions for what you need to do are provided in the file itself. You can use the Makefile provided to compile your code with:

$ make slist.o

Problem 2

Complete the code for the traverse function in file slisttest.c. This function will exercise the code you wrote for Problem 1 and expose bugs you may have introduced. When you are done editing your code, compile it with the Makefile provided by doing:

$ make 

After you debug your code and get everything working correctly, add, commit and push your files to your gitlab as follows:

git add *.h
git add *.c
git commit -m "lab1 completed" 
git push

Grading rubric

The rubric below shows the number of points that will be earned for each item that compiles and runs correctly. If the item does not compile correctly, 60% of the total points will be deducted. If the item compiles correctly and runs with major errors, 40% of the total points will be deducted. If the item compiles correctly and runs with minor errors, 20% of the total points will be deducted.

  1. slist_create [15 points]
  2. slist_add_back [25 points]
  3. slist_add_front [25 points]
  4. traverse [35 points]