Make sure you link the two files together and you can just declare the function:
Code:
// file1.c
void function( void ) {
// stuff
}
Code:
// file2.c
void function( void );
int main( void ) {
function();
}
Code:
C:\> gcc file1.c file2.c
It's probably better to add a header file to do that for you though. Then you can add more stuff any not have to keep typing a declaration every time you want to use it:
Code:
// file1.h
#ifndef _FILE1_H_
#define _FILE1_H_
void function( void );
#endif
Code:
// file1.c
#include "file1.h"
void function( void ) {
// stuff
}
Code:
// file2.c
#include "file1.h"
int main( void ) {
function();
}
Code:
C:\> gcc file1.c file2.c