home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Programmer's Library 1.3
/
Microsoft-Programers-Library-v1.3.iso
/
sampcode
/
prof_c
/
14view
/
strdup.c
< prev
next >
Encoding:
Amiga
Atari
Commodore
DOS
FM Towns/JPY
Macintosh
Macintosh JP
NeXTSTEP
RISC OS/Acorn
UTF-8
Wrap
C/C++ Source or Header
|
1988-08-11
|
244 b
|
18 lines
/*
* strdup -- duplicate a string
*/
#include <stdio.h>
#include <malloc.h>
#include <string.h>
char *
strdup(str)
char *str;
{
char *buf;
buf = malloc(strlen(str) + 1);
return (buf == NULL ? buf : strcpy(buf, str));
}