#ifndef __HAVE_ARCH_STRCPY
/**
* strcpy - Copy a %NUL terminated string
* @dest: Where to copy the string to
* @src: Where to copy the string from
*/
char *strcpy(char *dest, const char *src)
{
char *tmp = dest; while ((*dest++ = *src++) != '\0')
/* nothing */;
return tmp;
}

char *strcpy

 /**
* memcpy - Copy one area of memory to another
* @dest: Where to copy to
* @src: Where to copy from
* @count: The size of the area.
*
* You should not use this function to access IO space, use memcpy_toio()
* or memcpy_fromio() instead.
*/
void *memcpy(void *dest, const void *src, size_t count)
{
char *tmp = dest;
const char *s = src; while (count--)
*tmp++ = *s++;
return dest;
}

void *memcpy

strcpy和memcpy主要有以下3方面的区别。
1、复制的内容不同。strcpy只能复制字符串,而memcpy可以复制任意内容,例如字符数组、整型、结构体、类等。
2、复制的方法不同。strcpy不需要指定长度,它遇到被复制字符的串结束符"\0"才结束,所以容易溢出。memcpy则是根据其第3个参数决定复制的长度。
3、用途不同。通常在复制字符串时用strcpy,而需要复制其他类型数据时则一般用memcpy

 #ifndef __HAVE_ARCH_STRCMP
/**
* strcmp - Compare two strings
* @cs: One string
* @ct: Another string
*/ int strcmp(const char *cs, const char *ct)
{
unsigned char c1, c2; while () {
c1 = *cs++;
c2 = *ct++;
if (c1 != c2)
return c1 < c2 ? - : ;
if (!c1)
break;
}
return ;
}

int strcmp

 /**
* strncmp - Compare two length-limited strings
* @cs: One string
* @ct: Another string
* @count: The maximum number of bytes to compare
*/
int strncmp(const char *cs, const char *ct, size_t count)
{
unsigned char c1, c2; while (count) {
c1 = *cs++;
c2 = *ct++;
if (c1 != c2)
return c1 < c2 ? - : ;
if (!c1)
break;
count--;
}
return ;
}

int strncmp

 /**
* strlen - Find the length of a string
* @s: The string to be sized
*/
size_t strlen(const char *s)
{
const char *sc; for (sc = s; *sc != '\0'; ++sc)
/* nothing */;
return sc - s;
}

size_t strlen

 /**
* memset - Fill a region of memory with the given value
* @s: Pointer to the start of the area.
* @c: The byte to fill the area with
* @count: The size of the area.
*
* Do not use memset() to access IO space, use memset_io() instead.
*/
void *memset(void *s, int c, size_t count)
{
char *xs = s; while (count--)
*xs++ = c;
return s;
}

void *memset

 /**
* memmove - Copy one area of memory to another
* @dest: Where to copy to
* @src: Where to copy from
* @count: The size of the area.
*
* Unlike memcpy(), memmove() copes with overlapping areas.
*/
void *memmove(void *dest, const void *src, size_t count)
{
char *tmp;
const char *s; if (dest <= src) {
tmp = dest;
s = src;
while (count--)
*tmp++ = *s++;
} else {
tmp = dest;
tmp += count;
s = src;
s += count;
while (count--)
*--tmp = *--s;
}
return dest;
}

void *memmove

 /**
* memcmp - Compare two areas of memory
* @cs: One area of memory
* @ct: Another area of memory
* @count: The size of the area.
*/
int memcmp(const void *cs, const void *ct, size_t count)
{
const unsigned char *su1, *su2;
int res = ; for (su1 = cs, su2 = ct; < count; ++su1, ++su2, count--)
if ((res = *su1 - *su2) != )
break;
return res;
}

int memcmp

最新文章

  1. Uri.AbsoluteUri 与 Uri.ToString() 的区别
  2. 状态压缩 UVALive 6068 The Little Girl who Picks Mushrooms (12长春C)
  3. 通过ping确定网卡mtu
  4. .NET序列化的一点技巧
  5. WEB性能测试:你应该带上VisualStudio2010
  6. HTML5新增的一些属性和功能之六——拖拽事件
  7. gnuplot
  8. Activity之间定时跳转
  9. GitHub使用(二) - 新建文件夹
  10. 小白学爬虫-在无GUI的CentOS上使用Selenium+Chrome
  11. 1.3 正则表达式和python语言-1.3.6匹配多个字符串
  12. 在MyEclipse使用Git新建分支,并上传分支---图文教程
  13. http 请求 post get 长度限制
  14. js解密
  15. ps切图插件
  16. ESXI部署OVF模板提示用户已取消操作处理方法
  17. android 学习视频汇总
  18. js-jquery-SweetAlert【一】使用
  19. Git_分支管理
  20. Windoows窗口程序七

热门文章

  1. 如何在 Azure 虚拟机里配置条带化
  2. java笔记--正则表达式的运用(包括电话,邮箱验证等)
  3. SQL Server -&gt;&gt; 高可用与灾难恢复(HADR)技术之 -- Windows故障转移群集
  4. matlab 黑白格子
  5. 捡了一个非常淫荡的PHP后门,给跪了
  6. Java的日期时间
  7. python 中logging的日志封装
  8. Hive分区表创建,增加及删除
  9. 1053. [HAOI2007]反素数ant【DFS+结论】
  10. 【模板】Tarjan算法与有向图的强连通性