Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
If you're going to use the terminal to compile, then you should learn to use make, at least in a simple way. It makes life much easier. Here's a simple example, you really don't need to get any more complicated than this for a simple program, just assume everything depends on any interface in any header. And assuming I wrote it correctly off the top of my head. note: use tabs for indents after rules.

Code:
#
# a very simple makefile
# assumes you have main.c, main.h
# and other files all of which are similar, i.e. file.c and file.h
# all in the same directory
# and any *.c needs to recompile when any *.h changes
#

CC=gcc -O1 -std=c89 -Wall -pedantic
FILES = main.o file1.o file2.o\
  file3.o etc.o

myprog: $(FILES)
	$(CC) -o myprog $(FILES)
	strip myprog

%.o: %.c *.h
	$(CC) -o $*.o -c $*.c
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.