strdup 字符串复制 free

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
int main()
{

        char *s = "golden gold view";
        char *d;
        d = strdup(s);
        if(NULL != d)
        {
          printf("%s\n",d);
          free(d);
        }

        return 0;
}
~

  

posted on 2022-06-17 00:37  lydstory  阅读(48)  评论(0)    收藏  举报

导航