C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 11-26-2009, 02:03 PM   #1
Registered User
 
Join Date: Nov 2009
Posts: 60
Program Organisation in multiple files

Suppose I want a program that uses a struct author. As I plan to make a big program, I want to organise it in different files:

test.c will contain the main(), and will make use of the struct author

author.h will contain the struct declaration and function declarations that work with author objects.

author.c will contain the function implementations.

So, the main file (test.c) will #include "author.h"

My problem is that when I run this code, I won't work unless I put the struct declaration in both author.h and author.c:

Code:
struct author {
    /*members go here*/
};
typedef struct author author;
What am I overlooking?
Or is this the wrong way to organise a program?
hilarius is offline   Reply With Quote
Old 11-26-2009, 02:13 PM   #2
Registered User
 
C_ntua's Avatar
 
Join Date: Jun 2008
Posts: 1,266
Did you include author.h on author.c as well?
C_ntua is offline   Reply With Quote
Old 11-26-2009, 02:20 PM   #3
Registered User
 
Join Date: Nov 2009
Posts: 60
No I didn't and now I feel soooo stupid!

Thanks, now it works with the struct declaration in author.h!
hilarius is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
header files and multiple files Dedalus C Programming 5 06-16-2009 09:21 AM
Allowing user selection of directory so program can run .exe files? Tripod87 C Programming 4 07-24-2008 09:02 AM
WM_COPYDATA and mutex selecting multiple files gh0st Windows Programming 2 10-27-2006 02:22 PM
Multiple source files for one program gflores C++ Programming 3 08-15-2004 02:32 AM
Using multiple source files: Multiple Declarations & Wrong line numbers Inquirer C++ Programming 1 05-01-2003 02:52 PM


All times are GMT -6. The time now is 09:36 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22