Hi,

I am teaching myself C by writing programs. I have some questions about proper practices..

1) How do I know when to break my program into separate files. I am currently working on a Star Trek program. It has 4 or 5 large functions. They are all in one file. It's only about 900 lines right now.

2) Should I take something that is only used in one place in my program and
make it a function on it's own?

3) What should I do if I have a set of functions I use in many of my programs.. for instance, a randomize() for srandom() and random() that reads /dev/random for it's seed. (so far I use it in two program and I have just cut and paste it between) another example would be a whole setup of
#define statements that I use to work with ANSI console stuff.

(I know I should probably use curses instead.. I am just learning curses)

4) Are global variables really bad?  Why?  In my star trek program I
have two arrays that are used everywhere. They contain "reality".
Passing them in to each function would be a problem.

Reply via email to