Header files should never contain code - Only Defines/Typedefs/Function prototypes/etc. Where you put your code is in .c files.
So, first right click on the Header Files folder of your current project and select: "New -> C Header File."
Then fill in the "New C Header File" window. Now make a new .c source file in the "Source Files" folder with the same name as the header file you just created. In your main.c file add the statement: "#include "MyHeader.h" "(where MyHeader is the header file you just created). The header file is in quotes instead of these: <> because it's a local file to the project. Also add the same statement in the .c source file you just created.
Now, your going to need whats called a "inclusion guard" in your MyHeader.h file, so it isn't complied twice (since it's included in two .c files: main.c and MyHeader.c). Here's how a inclusion guard looks:
Code:
#ifndef MYHEADER_H
#define MYHEADER_H
// add all your Defines/Typedefs/Function prototypes/etc. here
#endif
And that's all. Put all of your code that you want in a separate file in the MyHeader.c file. All functions should be prototyped in the MyHeader.h file only, and all your #defines should be in there too.
When the compiler sees that there is a MyHeader.h file it will look at the source file folder for a matching .c file. When it sees it, it simply compiles it along with the rest of the code. So you don't need to put a "#include "MyHeader.c" " anywhere in your code.
If all that was kind of confusing, then have a look here:
http://www.gamedev.net/page/resourc...amming/organizing-code-files-in-c-and-c-r3173
That's how I figured out how to do all this stuff, and you might want to read it even if you did understand my explanation.
Dan