#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

string函数库的原型的更多相关文章

  1. PHP用mb_string函数库处理与windows相关中文字符

    昨天想批处理以前下载的一堆文件,把文件里的关键内容用正则匹配出来,集中处理.在操作文件时遇到一个问题,就是windows操作系统中的编码问题. 我们都知道windows中(当然是中文版),文件名和文件 ...

  2. Lua 中的string库(字符串函数库)总结

    (字符串函数库)总结 投稿:junjie 字体:[增加 减小] 类型:转载 时间:2014-11-20我要评论 这篇文章主要介绍了Lua中的string库(字符串函数库)总结,本文讲解了string库 ...

  3. 【C++实现python字符串函数库】一:分割函数:split、rsplit

    [C++实现python字符串函数库]split()与rsplit()方法 前言 本系列文章将介绍python提供的字符串函数,并尝试使用C++来实现这些函数.这些C++函数在这里做单独的分析,最后我 ...

  4. PHP函数库(other)

    PHP函数库(other) Session函数: session_abort — Discard session array changes and finish session session_ab ...

  5. C语言常用的库文件(头文件、函数库)

    C语言常用的库文件(头文件.函数库) C系统提供了丰富的系统文件,称为库文件.C的库文件分为两类,一类是扩展名为".h"的文件,称为头文件,在前面的包含命令中我们已多次使用过.在& ...

  6. 标准C函数库的使用方法

    本篇介绍若干经常使用的标准C函数的使用方法,主要介绍stdio(标准输入输出).math(数字函数库).time(时间函数库).stdlib(标准函数库)string(标准字符串函数)等. 最后更新  ...

  7. 初识函数库libpcap

    由于工作上的需要,最近简单学习了抓包函数库libpcap,顺便记下笔记,方便以后查看 一.libpcap简介    libpcap(Packet Capture Library),即数据包捕获函数库, ...

  8. C 函数库 (libc,glibc,uClibc,newlib)

    glibc glibc和libc都是Linux下的C函数库,libc是Linux下的ANSI C的函数库:glibc是Linux下的GUN C的函数库:GNU C是一种ANSI C的扩展实现.ANSI ...

  9. js常用的函数库

    阻止冒泡.默认行为.事件捕获 /* funname preventEventPropagation * desc 阻止冒泡事件&阻止默认行为&阻止事件捕获 * params {name ...

随机推荐

  1. ionic项目编译打包(android平台)

    ionic项目相关开发工作完成之后(建立ionic工程项目可以参考上一篇文章ionic项目工程建立),就可以进行项目的编译打包apk应用包. 打包编译需要在平台环境下,这里只记录下android平台打 ...

  2. java笔记--局部内部类认识与理解

    java内部类 内部类应用最多的场景是在编写GUI程序时,将大量的事件监听处理放在了内部类中进行 --如果朋友您想转载本文章请注明转载地址"http://www.cnblogs.com/XH ...

  3. Java中执行.exe文件

    public static void main(String args[]){ try { String command ="notepad"; // 笔记本 Process ch ...

  4. NAT原理简介、各种 ADSL Modem 及路由器的端口映射方法

    NAT原理简介 NAT英文全称是“Network Address Translation”,中文意思是“网络地址转换”,它是一个IETF(Internet Engineering Task Force ...

  5. POP动画[3]

    POP动画[3] 这一节主要讲解POP动画的自定义动画属性. POP动画中有一个参数,叫timingFunction,与CoreAnimation中的一个参数CAMediaTimingFunction ...

  6. Asp.Net MVC 开发技巧(一)

    开发程序时的流程: 1.设计数据模型. 数据模型最为重要,不仅关系到数据的存储,同时程序的可扩展性,效率也受影响,甚至决定开发工作量.所以要极其认真的设计数据库的表和相关字段. 建完基本的数据模型后, ...

  7. LeetCode算法题 菜鸟总结

    近期准备抽出一点时间,刷一些题防止手生,毕竟codemonkey,吃饭的手艺不能忘. ······································· 基本的题目都是基于java语言解答 ...

  8. 第一次课堂作业之Circle

    1.问题描述: Create a program that asks for the radius of a circle and prints the area of that circle, us ...

  9. 解决Could not commit JPA transaction RollbackException: Transaction marked as rollbackOnly

    项目测试发生问题,方法正常结束,但是报了 Could not commit JPA transaction; nested exception is javax.persistence.Rollbac ...

  10. 由JDK源码学习ArrayList

    ArrayList是实现了List接口的动态数组.与java中的数组相比,它的容量能动态增长.ArrayList的三大特点: ① 底层采用数组结构 ② 有序 ③ 非同步 下面我们从ArrayList的 ...