Moving the code to a separate source file (and it's accompanying header file) is something which is easy to do later (just a copy/paste job).
First you edit your code so what you want to separate out is in a function (or set of related functions).
Say you have main.c like this.
Code:
#include <stdio.h>
void func ( char *msg ) {
printf( "%s\n", msg );
}
int main ( ) {
func("hello");
return 0;
}
After editing, you have 3 files.
This is func.h
Code:
#ifndef FUNC_H_INCLUDED
#define FUNC_H_INCLUDED
void func ( char *msg );
#endif
This is func.c
Code:
#include <stdio.h>
#include "func.h"
void func ( char *msg ) {
printf( "%s\n", msg );
}
And this is main.c
Code:
#include <stdio.h>
#include "func.h"
int main ( ) {
func("hello");
return 0;
}