strdup() "need source"

Dave Hammond daveh at marob.masa.com
Fri Jun 16 21:57:42 AEST 1989


Sorry, folks.  I tried to `R'eply to this, but something called
/usr/lib/news/recmail appears missing (I don't administer news here,
I just read it).

To: rl at sssphx.UUCP
Subject: Re: strdup() "need source"

In article <124 at sssphx.UUCP> you write:
>I need the function strdup() if someone would be so kind to send [...]

Hmm, off the top of my head:

/* return a malloc'd copy of STRING or Null for errors */
char *
strdup(string)
char *string;
{
	char *malloc(), *strcpy();
	char *area = (char *)0;
	int n;
	if (string && (area = malloc(strlen(string)+1))
		(void) strcpy(area, string);
	return(area);
}

--
Dave Hammond
daveh at marob.masa.com



More information about the Comp.lang.c mailing list