strdup

2018-11-11 16:00 更新

 原型:extern char *strdup(char *s);
       
 用法:#include <string.h>
 
 功能:復(fù)制字符串s
 
 說明:返回指向被復(fù)制的字符串的指針,所需空間由malloc()分配且可以由free()釋放。
 
 舉例:


     // strdup.c
     
     #include <syslib.h>
     #include <string.h>
     main()
     {
       char *s="Golden Global View";
       char *d;
       
       clrscr();
       
       d=strdup(s);
       printf("%s",d);
       getchar();
       return 0;
     }      


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)