From: noname AT noname DOT org (Stuart Hall) Newsgroups: comp.os.msdos.djgpp Subject: Problem implementing multiple moduled program Date: Wed, 27 Jan 1999 14:00:27 GMT Organization: Connix - The Connecticut Internet Exchange Lines: 90 Message-ID: <36b41be7.2525182@news> NNTP-Posting-Host: m5.aetna.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Newsreader: Forte Agent 1.5/32.452 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Good morning. I asked once before how to make a multiple module program, and I got some answers but once again I am stuck. I wish to implement a "getsafe" function that I can include in most of my programs - and I have attached my first attempt. /* begin "getsafe.h" */ char *getsafe(char *buffer, int count) /* --- */ Is there anything else I need in a header file? DJGPP specific -- what do I need to do with a .h file, just save-as, or do I need to compile it? /* begin "main.c" */ #include #include #include #include "getsafe.h" /* char result[80]; */ /* int result_num=sizeof(result); */ int main(void) /* I get a "parse error before {" */ { printf("Enter up to %d characters: ",result_num-1); getsafe(result, result_num); printf("your string is %s",result); return 0; } /* ----- */ On the above program, I also tried defining result[80], and result_num in the body of main, in the body of my getsafe() module, and leaving it out. Either way, the compiler would give me an error about I did get an error when putting #include about a file not found, but as soon as I put it in quotes the error went away. My errors: In function 'getsafe' main.c(7) Parse error before '{' main.c(6) Parm types given both in parm list and separately /* Begin Getsafe.c module */ #include #include char result[80]; int result_num=sizeof(result); char *getsafe(char *buffer, int count) { char *result = buffer, *np; if ((buffer==NULL) || (count <1)) result = NULL; else if (count == 1) *result = '\0'; else if ((result = fgets(buffer, count, stdin)) != NULL) if ((np = strchr(buffer, '\n'))) *np = '\0'; return result; } /* ----- compiles without errors --- */ Any hints? I am sure my program is riddled with errors, but after reading a few tutorials I can't quite figure it out. It seems like I am missing a getsafe function prototype from my getsafe.h header file or from getsafe.c, but none of my examples had it. Hmmmm. Thanks in advance for your help. BTW, when run as a singular program I have no problem implementing my getsafe function. Stuart Hall ---- Stuart Hall Connecticut, USA * return address: f p r i n t @ i n a m e . c o m *