文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>memcpy函数用法

memcpy函数用法

时间:2009-04-02  来源:oldstorm

memcpy

  原型:extern void *memcpy(void *dest, void *src, unsigned int count);
  用法:#include <string.h>
  功能:由src所指内存区域复制count个字节到dest所指内存区域。
  说明:src和dest所指内存区域不能重叠,函数返回指向dest的指针。
  举例:
  // memcpy.c
  #include <stdio.h>
  #include <string.h>
  int main(int argc, char* argv[])
  {
  char *s="Golden Global View";
  char d[20];
  clrscr();
  memcpy(d,s,strlen(s));
  d[strlen(s)]='\0';
  printf("%s",d);
  getchar();
  return 0;
  }
  截取view
  #include <string.h>
  int main(int argc, char* argv[])
  {
  char *s="Golden Global View";
  char d[20];
  memcpy(d,s+14,4);
  //memcpy(d,s+14*sizeof(char),4*sizeof(char));也可
  d[5]='\0';
  printf("%s",d);
  getchar();
  return 0;
  }
  输出结果:
  View
  初始化数组
  char msg[10];
  memcpy(msg,0,sizeof(msg));
相关阅读 更多 +
排行榜 更多 +
暗夜格斗手游

暗夜格斗手游

棋牌卡牌 下载
魔渊之刃手游

魔渊之刃手游

角色扮演 下载
像素火影次世代手游版

像素火影次世代手游版

体育竞技 下载