Mail Archives: djgpp/1999/01/27/14:22:15
On Tue, 26 Jan 1999 13:09:10 -0800, Marvin G Wise Jr
<mgwise AT seidata DOT com> so kindly spent valuable time writing:
>
>Well, if this is the function prototype in your header file then it
>should have a semicolon at the end...
>
> char *getsafe(char *buffer, int count);
>
Ok, I tried this, and got a few more errors. Now my program looks
like this, both modules compile just fine -- but when the linker gets
to them it gives me an error:
creating multiple.exe:
Error: getsafe.o: In function 'getsafe':
getsafe.c(8): Error multiple definition of 'getsafe'
0:getsafe.c(8): Error first defined here.
Sorry for the waste of bandwidth, but here are my proggies again. I
am this | | close!!
/*getsafe.h */
char *getsafe(char *buffer, int count);
/*getsafe.c */
#include <stdio.h>
#include <string.h>
extern char result;
extern int result_num;
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;
}
/*main.c */
#include <string.h>
#include <stdlib.h>
#include "getsafe.h"
char result[80];
int result_num=sizeof(result);
int main(void)
{
printf("Enter up to %d characters: ",result_num-1);
getsafe(result, result_num);
printf("your string is %s",result);
return 0;
}
Thanks again!
Stuart
----
Stuart Hall
Connecticut, USA
* return address: f p r i n t @ i n a m e . c o m *
- Raw text -