Xref: utzoo unix-pc.general:3079 comp.lang.c:19377 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!uunet!ateng!chip From: chip@ateng.com (Chip Salzenberg) Newsgroups: unix-pc.general,comp.lang.c Subject: Re: strdup() "need source" Keywords: big.banner Message-ID: <1989Jun15.155525.29929@ateng.com> Date: 15 Jun 89 15:55:25 GMT References: <124@sssphx.UUCP> Distribution: usa Organization: A T Engineering, Tampa, FL Lines: 29 According to rl@sssphx.UUCP (Rod Longhofer): >I am trying to compile big banner on a unix-pc, SYSV 3.5 and >need the function strdup() if someone would be so kind to send >it to me it would be appreciated.. Easier done than said... /* * strdup() * Duplicate a string in malloc'd memory and return the * address of the duplicate, or NULL if memory exhausted. */ char * strdup(s) char *s; { char *p; if (s == NULL || (p = malloc(strlen(s) + 1)) == NULL) return NULL; (void) strcpy(p, s) return p; } -- You may redistribute this article only to those who may freely do likewise. Chip Salzenberg | or A T Engineering | Me? Speak for my company? Surely you jest!