跳到主要内容

memcpy

注意

这个$函数以小写字母开头。

描述

用于将字节从一个位置复制到另一个位置

参数说明
dest[]目标数组,用于存放从源数组复制的字节
const source[]源数组
index = 0目标数组中开始复制的字节索引(以字节为单位)
numbytes要复制的字节数(非单元格数)
maxlength = sizeof (dest)目标缓冲区的最大单元格容量

返回值

成功时返回 true,失败时返回 false

示例

// 使用memcpy拼接两个字符串
new
destination[64] = "This is ",
source[] = "a string in a 32 Bit Array";

memcpy(destination, source, strlen(destination) * 4, sizeof source * 4, sizeof destination);
print(destination);
// 输出: This is a string in a 32 Bit Array

相关函数

  • strcmp: 比较两个字符串是否相同
  • strfind: 在字符串中搜索子串
  • strdel: 删除字符串的部分或全部内容
  • strins: 将字符串插入到另一个字符串中
  • strlen: 获取字符串长度
  • strmid: 从字符串中提取指定字符
  • strpack: 将字符串打包到目标缓冲区
  • strval: 转换字符串为数值
  • strcat: 拼接两个字符串