Useful little things for the assignment
Enumerations
Enumerations are useful if you've variables which take on
values from a small set. We looked at two examples for enumerations
in class:
Also, we coded the two programs e1.c and
week.c during the session.
Function Pointers
We looked at the two example programs
Queues
Many people were trying to use linked lists in order to implement their
queues. In our situation it might be easier to use simply an array and two
variables for the begin and the end of the queue.
- the Queue code q.c implements this basic idea.
- Here's a fancy implementation of the array idea. This implementation
allows you to have as many queues as you want, etc...
queue.h,
queue.c,
testQueue.c
- this afternoon, Hany and I coded a queue implementation based on a linked list:
list.h
Debugging
You might want to use the debugger gdb in case you're stuck with segmentation
faults, bus errors, etc. If you never had any of these problems, you can try the program
bug.c. In order to use the debugger,
you should compile your code with option -g.
gcc -g bug.c
and run the executable a.out to get the segmentation fault. Next, start the debugger with
gdb a.out
The most useful commands in the debugger are
- run
- list
- break
- where
- next
- step
- help
I recommend that you get familiar with this powerful tool! (Also, check out the man page for
gdb and dbx).
XServer
It's possible to allow an unix machine to open a window on a Windows95/98 or NT computer.
However, you would need to install some software to do so - but you'll have lots of benefits.
Check out
http://www.microimages.com/freestuf/mix/mix.htm and
http://www.hummingbird.com/
Also, I'll check with people who are using PCs more frequently than me...
.emacs
Here's a downsized version of my .emacs file. If you
want your emacs to come up with similar key-bindings and syntax highlighting
you should put this file in your home directory as .emacs