zoukankan      html  css  js  c++  java
  • strdup

    #include <string.h>
    char *strdup(const char *s);

    description:

    strdup()函数返回一个指向新字符串的指针,该字符串与s字符串副本。 新字符串的内存是通过malloc获得的,可以通过free释放。

    return value:

    返回值成功时,strdup()函数将返回指向副本字符串的指针。 如果没有足够的可用内存,它将返回NULL,并设置errno来指示错误原因。

    #include <stdio.h>
    #include <string.h>
    int main(void)
    {
         char *src ="This is the strdup test!";
         char *des;
         des = strdup(src);
         printf("dest: %s
    ",des);
        free(des);
         return 0;
    
    }
  • 相关阅读:
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    5.14
    5.13
    5.12
  • 原文地址:https://www.cnblogs.com/iuyy/p/13492986.html
Copyright © 2011-2022 走看看