For this assignment you will follow a similar workflow to the Hello, world! activity. You should have received another email from git-keeper with a clone URL for this assignment. To get started, clone the repository for this assignment into the directory that you created for this class in the in-class activity. Refer back to the in-class activity instructions to remind yourself how to clone an assignment.
This repository contains two files:
program_one.c
and
program_two.c
. Start by opening
program_one.c
in your text editor. The contents of this file are based on Exercise 5 from Chapter 2 of the book.
This program contains a number of errors. Before you start fixing the errors, try compiling the program. Make sure you have entered the directory for this assignment in the terminal using
cd
and then run the following command:
gcc program_one.c -o program_one
The compiler should complain about a number of errors. If
gcc
tells you that the file does not exist, you are likely in the wrong directory in the terminal. Refer back to the instructions for the in class activity about using
cd
to change directories.
Now try fixing the program and re-running the above command. You will know that the program compiled successfully if there is no output from the command. Make sure to remember to save your program in your editor before you compile!
If the program compiled, it will have produced a file named
program_one
, since we specified the name of the file to create with
-o program_one
. You can now run the program with this command:
./program_one
Hopefully the program produced the output you expect. If not, go back and try to fix the program again, re-compile the program, and try to run it again.
Now open
program_two.c
in your editor and fix that program as well. Be sure to compile and run the program to make sure it works before you submit. You will need to adjust the compile command so that you are compiling
program_two.c
instead of
program_one.c
.
Once your programs are working correctly, commit and push your changes using
git
like this. To add changes to multiple files you can either run
git add
twice (once for each file) or you can run
git add
once and give it both filenames like this:
git add program_one.c program_two.c
To commit:
git commit -m "Fixed programs"
And to push:
git push
Check your email to ensure that git-keeper got your submission and that the tests passed. If there were errors, fix your program again and repeat the above 3 steps.
Your grade for this exercise will be out out of 3 points:
program_one.c
program_two.c