且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

插入一个字符串到另一个字符串中有效

更新时间:2022-01-05 06:19:53


  • 分配足够大的缓冲区(的malloc / 新[]

  • 的AA字符串的第一部分复制到缓冲区中(函数strncpy / 的memcpy

  • 复制BB的字符串(的strcpy / 的memcpy

  • 复制AA字符串的其余部分(函数strncpy / 的memcpy

  • allocate big enough buffer (malloc/new[])
  • copy the first part of the aa string into the buffer (strncpy/memcpy)
  • copy the bb string (strcpy/memcpy)
  • copy the rest of the aa string (strncpy/memcpy)