#include <string.h>
|
char *
strdup (const char *str); |
If insufficient memory is available, NULL is returned and errno is set to ENOMEM.
#include <string.h> #include <stdio.h> int main() { char* ptr; ptr = (char *)strdup("abcde"); printf("Duplicated string %s\n",ptr); ptr = (char *)strdup("Hello Hi"); printf("Duplicated string %s\n",ptr); return 0; }
Output
Duplicated string abcde Duplicated string Hello Hi
© 2005-2007 Nokia |