Professional Documents
Culture Documents
Once you have the terminal open, you can see a list of your files with:
ls
Create a directory for cs2014 lab work:
mkdir cs204
Now switch to that directory:
cd cs204
Create a directory for your first lab:
mkdir lab1
Now switch to that directory
cd lab1
http://www.cs.tcd.ie/David.Gregg/cs2014/labs/sorts.c
http://www.cs.tcd.ie/David.Gregg/cs2014/labs/numbers.txt
On many (but not all) Unix machines you can use the wget command
to download files. For example:
wget http://www.cs.tcd.ie/David.Gregg/cs2014/labs/sorts.c
Open the C program using your favorite editor, such as gedit, nano,
vim or emacs. If you are working on one of the Linux machines in LG12,
]you can run gedit as follows:
gedit sorts.c &
The & at the end of the command tells the terminal to run the gedit
program, but not to wait for it to complete. This allows you to
type more commands before the gedit command completes. This is
what you want on a Linux machine running X-windows.
If you are running your terminal from a machine that is not running
X-windows, then you probably want to run your editor inside the
terminal program. In this case, you would use a simpler editor
such as nano, which runs inside the terminal.
nano sorts.c
Note that when you are using a terminal editor like nano, you
don't want to have the & character at the end of the command,
because the editor is running within the terminal. In this
case you will need a second terminal to compile and run your
program.
The existing sorts.c program uses the "funny" sort algorithm to sort
the numbers. In addition there are prototypes, but no code for bubble
sort, selection sort and insertion sort. Write the code for these
sorts, and test it out in this program. For selection sort, you can
use the existing findMin function (if you want).