C语言字符串函数详解(1)

来源:互联网 发布:java代码防止反编译 编辑:程序博客网 时间:2024/05/01 06:23
 

void *memset(void *dest, int c, size_t count);                            

//将dest前面count个字符置为字符c.      返回dest的值.

void *memcpy(void *dest, const void *src, size_t count);   

从src复制count字节的字符到dest. 与memmove功能一样, 只是不能处理src和dest出现重叠.返回dest的值.

void *memchr(const void *buf, int c, size_t count);           

 在buf前面count字节中查找首次出现字符c的位置. 找到了字符c或者已经搜寻了count个字节, 查找即停止.操作成功则返回buf中首次出现c的位置指针, 否则返回NULL.

void *_memccpy(void *dest, const void *src, int c, size_t count);   

从src复制0个或多个字节的字符到dest. 当字符c被复制或者count个字符被复制时, 复制停止.如果字符c被复制, 函数返回这个字符后面紧挨一个字符位置的指针. 否则返回NULL.

int memcmp(const void *buf1, const void *buf2, size_t count);     

比较buf1和buf2前面count个字节大小. 返回值< 0, 表示buf1小于buf2;返回值为0, 表示buf1等于buf2;返回值> 0, 表示buf1大于buf2.

size_t strlen(const char *string);                                                          

 获取字符串长度, 字符串结束符NULL不计算在内.没有返回值指示操作错误.

char *strrev(char *string);                                                                        

将字符串string中的字符顺序颠倒过来. NULL结束符位置不变.返回调整后的字符串的指针.

char *_strupr(char *string);                                                                    

将string中所有小写字母替换成相应的大写字母, 其它字符保持不变.返回调整后的字符串的指针.

char *_strlwr(char *string);                                                                    

 将string中所有大写字母替换成相应的小写字母, 其它字符保持不变.返回调整后的字符串的指针.

char *strchr(const char *string, int c);                                                  

查找字符c在字符串string中首次出现的位置, NULL结束符也包含在查找中.

返回一个指针, 指向字符c在字符串string中首次出现的位置, 如果没有找到, 则返回NULL.

char *strrchr(const char *string, int c);                                             

 查找字符c在字符串string中最后一次出现的位置, 也就是对string进行反序搜索, 包含NULL结束符.

 返回一个指针, 指向字符c在字符串string中最后一次出现的位置, 如果没有找到, 则返回NULL.

char *strstr(const char *string, const char *strSearch);             

 在字符串string中查找strSearch子串.  返回子串strSearch在string中首次出现位置的指针.

如果没有找到子串strSearch, 则返回NULL. 如果子串strSearch为空串, 函数返回string值.

char *strcat(char *strDestination, const char *strSource);          

将源串strSource添加到目标串strDestination后面, 并在得到的新串后面加上NULL结束符.

 char *strncat(char *strDestination, const char *strSource, size_t count);        

将源串strSource开始的count个字符添加到目标串strDest后.

char *strcpy(char *strDestination, const char *strSource);           

复制源串strSource到目标串strDestination所指定的位置, 包含NULL结束符.

char *strncpy(char *strDestination, const char *strSource, size_t count);    

 将源串strSource开始的count个字符复制到目标串strDestination所指定的位置.

char *strset(char *string, int c);                                                               

将string串的所有字符设置为字符c, 遇到NULL结束符停止.

char *strnset(char *string, int c, size_t count);                                  

 将string串开始count个字符设置为字符c,

size_t strspn(const char *string, const char *strCharSet);                 

查找任何一个不包含在strCharSet串中的字符在string串中首次位置序号.

size_t strcspn(const char *string, const char *strCharSet);           

 查找strCharSet串中任何一个字符在string串中首次出现的位置序号, 包含字符串结束符NULL.

char *strpbrk(const char *string, const char *strCharSet);              

查找strCharSet串中任何一个字符在string串中首次出现的位置,

int strcmp(const char *string1, const char *string2);                      

  比较字符串string1和string2大小.

int strncmp(const char *string1, const char *string2, size_t count);   

比较字符串string1和string2大小,只比较前面count个字符.

原创粉丝点击