UP | HOME

Hello Project
COP-3402

Table of Contents

1. Overview

In this project you will create a "hello, world!\n" program. That might sound easy, but the catch is you will need to create it using the command-line development workflow shown in class that we'll be using for all projects in the class, including the emacs editor, make build automation, and git version control for submission.

2. git setup

Be sure to complete the git exercise before attempting this project.

Create a new local repository, following the directions in the git exercise (including running git push --set-upstream submission master in the last step) and set the local and remote repository URLs to be the following locations, replacing NID with your UCF NID:

Local repository ~/cop3402spring25/hello
Remote repository gitolite3@eustis3.eecs.ucf.edu:cop3402/$USER/hello

3. Create the "hello, world!\n" program with emacs

Using either emacs in eustis, record yourself using script (see instructions below) writing, compiling, and running a hello world program in C, i.e., a program that uses printf to write "hello, world!\n" to the console.

3.1. Enter your local repository

cd ~/cop3402spring25/hello

If your ~/cop3402spring25 directory does not exist yet, be sure to do git setup first.

3.2. Start recording

script -T hello.timing hello.script

3.3. Use emacs to create a hello world program called hello.c, then compile it and run it

emacs hello.c

Create a C program that prints "hello, world!\n" (remember this is case sensitive and don't forget the \n).

Then save and exit (for emacs, Ctrl-x Ctrl-s then Ctrl-x Ctrl-c).

Make sure your compiles and runs correctly:

gcc -o hello hello.c
./hello

3.4. Stop recording

exit

(or Ctrl-D on the empty command prompt.)

3.5. Verify that your recording works by replaying it yourself

scriptreplay hello.timing hello.script 2

The 2 is optional and will replay it at 2x speed. You can use a higher number as well to replay faster. Use Ctrl-C to stop playback.

4. Creating a Makefile

4.1. Enter your local repository

cd ~/cop3402spring25/hello

If your directory does not exist yet, be sure to do git setup first.

4.2. Edit your Makefile

emacs Makefile

Hand-type the following Makefile. Use tab for indentation (not spaces), or your Makefile will not work.

.PHONY: all clean

all: hello

hello: hello.c
        gcc -o hello hello.c

clean:
        rm -f hello

Then save and exit (for emacs, Ctrl-x Ctrl-s then Ctrl-x Ctrl-c).

4.3. Test your Makefile

make

You should see the following output. (Do not type this into bash; this is what the Makefile will run for you):

gcc -o hello hello.c

If you receive compiler errors, be sure your hello.c is correct. If you receive make errors, double-check the Makefile contents against the previous step and make sure you are using tab not spaces for indentation.

If you have already built your program and not modified hello.c since, then you will see something like

make: Nothing to be done for 'all'.

or something like this

make: 'hello' is up to date.   

5. Creating a .gitignore file

It's good practice to omit generated, binary files from source version control, such as your hello program binary. Source version control tools are geared towards source code, program binaries dramatically increase the size of the repository, and the program binary should be easily buildable from source, especially if you have good build automation. Other tools, such as package managers, may be more appropriate for distributing program binaries.

5.1. Go to the root of your repo

Be sure you are in the root of your repo, in this case ~/cop3402spring25/hello:

cd ~/cop3402spring25/hello

5.2. Make sure the hello file exists

To illustrate what the .gitignore file does, let's make sure the file hello exists (it may already if you have built your program):

touch hello

(touch creates an empty file or updates the timestamp of an existing file).

5.3. Validate the untracked file

git status

This should output something like this:

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        hello
        Makefile
  hello.c
  hello.script
  hello.timing

nothing added to commit but untracked files present (use "git add" to track)

There may be other content, but be sure that hello is under Untracked files:. This tells you that hello is untracked, i.e., it is in the working tree but not staged or committed. If you don't see this, be sure you are in the root of your repo and that the hello file exists. If it still is not show as untracked, then you may have accidentally added hello to your repo already. Remove it with these instructions.

5.4. Create a .gitignore file

emacs .gitignore

Put the names (or patterns) of files to exclude from the output, one per line:

*~
hello

*~ ignores emacs backup files. hello ignores the hello file.

Save and exit (for emacs, Ctrl-x Ctrl-s then Ctrl-x Ctrl-c).

5.5. Validate that git no longer considers hello untracked

git status

This should output something like this:

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
        Makefile
  hello.c
  hello.script
  hello.timing

nothing added to commit but untracked files present (use "git add" to track)

Notice that hello is no longer under Untracked files, but now the new file .gitignore is. Add and commit this file so that all users of your repo will see it.

git add .gitignore
git commit .gitignore

Enter a commit message, e.g.,

Add a .gitignore file
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Changes to be committed:
#       new file:   .gitignore
#

Save and exit (for emacs, Ctrl-x Ctrl-s then Ctrl-x Ctrl-c).

5.6. Check git status for a clean working tree

git status

This should output something like:

On branch master
nothing to commit, working tree clean

or

On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Makefile
  hello.c
  hello.script
  hello.timing

nothing added to commit but untracked files present (use "git add" to track)

if you have uncommitted files.

Notice .gitignore is no longer untrack, because it was committed. But hello is also untracked, not because it was committed, but because you have asked git to ignore it.

6. Submitting your program via git

6.1. Add and commit each file

Enter

git add hello.c
git commit hello.c

Enter an appropriate commit message.

If you encounter errors or do not know how to use the emacs editor, please be sure to complete the git exercise before proceeding. Then setup this project's git repository.

Then enter

git add hello.timing hello.script
git commit hello.timing hello.script

Enter an appropriate commit message and then do

git add Makefile
git commit Makefile

Enter an appropriate commit message and finally do (if you haven't already done this here)

git add .gitignore
git commit .gitignore

Enter an appropriate commit message.

6.2. Push the repository

git push

You should see something similar to this:

Enumerating objects: 14, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 264 bytes | 264.00 KiB/s, done.
Total 13 (delta 0), reused 0 (delta 0), pack-reused 0
To eustis3.eecs.ucf.edu:cop3402/NID/hello
   0721d93..886c6f7  master -> master

If you encounter errors, be sure to complete the git exercise before proceeding. Then setup this project's git repository.

7. Self-check

7.1. Remove the previous self-check

If you have already run the self-check, you can remove it like this

rm -rf ~/tmp/hello_selfcheck

Double-check the path carefully to avoid deleting the wrong directory.

7.2. Make a fresh clone of your project

git clone gitolite3@eustis3.eecs.ucf.edu:cop3402/$USER/hello ~/tmp/hello_selfcheck

You should see something like

Cloning into '/home/net/NID/tmp/hello_selfcheck'...
done.

If you see

fatal: destination path '/home/net/NID/tmp/hello_selfcheck already exists and is not an empty directory.

then remove the previous self-check.

7.3. Enter the fresh clone's directory

cd ~/tmp/hello_selfcheck

7.4. Double-check that the five required files are submitted

ls -a

You should see the five required files (hello.c, hello.script, hello.timing, Makefile, .gitignore), .git, ., .., and (optionally) a README.md file, e.g.,

.
..
.git
README.md
hello.c
hello.script
hello.timing
Makefile
.gitignore

The order does not matter. If you have a README.md, that is okay. If you have hello or any other program binary, remove it with these instructions and rerun the self-check.

You can also validate what files are actually in the repo like this:

git ls-tree --full-tree -r --name-only HEAD

7.5. Be sure that make works correctly

make

This should only create the hello program and do nothing else (not run the program either).

Running ls should show the hello program now in the directory.

7.6. Make sure hello runs correctly

./hello

This should output hello, world! on its own line, i.e.,

hello, world!

If you see a missing "\n", which will have the command-prompt immediately after the text, e.g.,

hello, world!NID:~/cop3402spring25/hello$ 

or if you see a missing comma, missing exclamation point, any capitalized letters, go back and follow the directions closely.

7.7. Make sure make clean works

make clean

This should remove the hello binary. Confirm that it is gone with ls.

7.8. Make sure make and ./hello still work after clean

make
./hello

You should get the same behavior as before with make and ./hello.

7.9. Make sure your terminal recording works

scriptreplay hello.timing hello.script 2

You should see a recording of yourself opening emacs, entering the hello world program, saving, and exiting.

8. Grading schema

Criterion Points
The git repo exists 1
The repo contains the five required files 1
The repo does not contain hello or any program binaries 2
The replay shows using emacs to code 2
The Makefile works correctly 1
The program runs correctly 1
TOTAL 8

9. Grading script

Log in to eustis and run the following to get the script

mkdir -p ~/grading/cop3402spring25
cd ~/grading/cop3402spring25
wget https://www.cs.ucf.edu/~gazzillo/teaching/cop3402spring25/files/hello_grader.sh

Then to grade, run the following,

bash hello_grader.sh $USER

Note that this grade does not include any late penalty and therefore may differ from your actual grade in webcourses.

Author: Paul Gazzillo

Created: 2025-02-03 Mon 08:57

Validate