[~]$ cd [~]$ mkdir cs31 [~]$ cd cs31 [cs31]$ ls [cs31]$ mkdir weeklylab [cs31]$ ls weeklylab/ [cs31]$ cd weeklylab/ [weeklylab]$ mkdir week00 [weeklylab]$ cd week00/ [week00]$ cp ~adanner/public/cs31/week00/* ./ [week00]$ ls hello.c Makefile sample.c sample_messy.c [week00]$ pwd /home/adas/cs31/weeklylab/week00 [week00]$Source files with a .c extension must be compiled before being run. We will use the compiler gcc to compile our programs.
[week00]$ gcc hello.c -o hello [week00]$ ls hello* hello.c Makefile sample.c sample_messy.c [week00]$ ./hello Hello world [week00]$The -o option allows us to specify the name of the compiled executable. In this case, the name is hello without the .c extension. If the program compiles successfully, you can run the program by typing ./hello
In some instances, we will provide a Makefile to help automate the compile steps. If you type make at the command prompt, it will automatically build any necessary files needed as specified in the Makefile. Don't worry too much about Makefile syntax at this point. If you make changes to any of the source code, you will need to recompile or run make to compile new executables. Since the executables are automatically built from the source, it is safe to remove them. This is usually done using make clean.
Try reading, editing, compiling, and running the three sample programs provided.