I have this C program with multiple files and I want to introduce a new file called enemy.c.
and I'm wondering if I'm going about this right.
game.h
#ifndef GAME_
#define GAME_
extern void game (void);
extern void enemyFunc (void);
extern int enemyPosX;
#endif
main.c
int main (void)
{
game();
}
game.c
#include "game.h"
int enemyPosX = 452;
void game (void)
{
enemyFunc();
}
enemy.c
#include "game.h"
void enemyFunc (void)
{
enemyPosX -= 4;
}
The program works but I'm wondering if I should make a new file called enemy.h
and put
extern void enemyFunc (void);
in it instead of in game.h, to have a header defining each .c file?