| | |
Multiple files
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Sep 2006
Posts: 327
Reputation:
Solved Threads: 22
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
main.c
game.c
enemy.c
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?
and I'm wondering if I'm going about this right.
game.h
C Syntax (Toggle Plain Text)
#ifndef GAME_ #define GAME_ extern void game (void); extern void enemyFunc (void); extern int enemyPosX; #endif
C Syntax (Toggle Plain Text)
int main (void) { game(); }
C Syntax (Toggle Plain Text)
#include "game.h" int enemyPosX = 452; void game (void) { enemyFunc(); }
C Syntax (Toggle Plain Text)
#include "game.h" void enemyFunc (void) { enemyPosX -= 4; }
and put
extern void enemyFunc (void);
in it instead of in game.h, to have a header defining each .c file?
>If I were to do it, I would need to include "game.h" in enemy.c
>as well seeing as I'm using the variable enemyPosX from it?
I would move everything that pertains to enemies into enemy.h. Then you would need to include enemy.h in game.c, which is a smidge more intuitive.
>as well seeing as I'm using the variable enemyPosX from it?
I would move everything that pertains to enemies into enemy.h. Then you would need to include enemy.h in game.c, which is a smidge more intuitive.
New members chased away this month: 5
![]() |
Similar Threads
- parsing multiple files in current directory (Perl)
- making multiple files (Java)
- uploading multiple files, 'post' not working off server (works fine off local host) (JSP)
- problems writing multiple files (Perl)
- multiple file searching (C)
- Working with array of files (C++)
- Use Java to remove a block of html from a number of files? (Java)
- ie.content can't delete files (Web Browsers)
- How to Rename Multiple Files with Windows Explorer (Windows tips 'n' tweaks)
Other Threads in the C Forum
- Previous Thread: Need help with Data Structure and Algorithms
- Next Thread: pause until any key pressed in linux
Views: 2105 | Replies: 4
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable visualstudio voidmain() wab win32 windows.h






