zoukankan      html  css  js  c++  java
  • strdup ()函数

      原型:extern char *strdup(char *s);
      用法:#include <string.h>
      功能:复制字符串s
      说明:返回指向被复制的字符串的指针,所需空间由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);
      free(d);
      getchar();
      return 0;
      }
          

       运行结果:

        Golden Global View

  • 相关阅读:
    实验四
    实验三
    实验二
    实验一
    6
    5
    4
    3
    shiyan2
    实验1
  • 原文地址:https://www.cnblogs.com/eagleking0318/p/6521293.html
Copyright © 2011-2022 走看看