本文共 1758 字,大约阅读时间需要 5 分钟。
c语言库函数 字符串
Mostly, every C compiler provides a set of useful library functions for handling strings. Here is a list of more commonly used functions with their uses:
通常,每个C编译器都会提供一组有用的库函数来处理字符串。 这是更常用的功能及其用途的列表:
Function | Use |
---|---|
strlen | To find length of a string |
strlwr | To convert all characters of a string to lowercase |
strupr | To convert all characters of a string to uppercase |
strcpy | To copy one string into another |
strncpy | To copy first n characters of a string into another |
strdup | To duplicate a string |
strrev | To reverse a string |
strcat | To append one string at the end of another string |
strncat | To append first n characters of a string at the end of another |
strcmp | To compare two strings |
strncmp | To compare first n characters of two strings |
strcmpi | To compare two strings without regarding the case(“I” denotes the func. Ignores case) |
stricmp | Similar to strcmpi |
strnicmp | To compare first n characters of two strings without regarding case |
strchr | To find first occurrence of a given ‘character’ in a string |
strrchr | To find last occurrence of a given ‘character’ in a string |
strstr | To find first occurrence of a given ‘string’ in another string |
strset | Sets all characters of a string to a given character |
strnset | Sets first n characters of a string to a given character |
功能 | 用 |
---|---|
len | 查找字符串的长度 |
Strlwr | 将字符串的所有字符转换为小写 |
Struts | 将字符串的所有字符转换为大写 |
strcpy | 将一个字符串复制到另一个 |
结构 | 将字符串的前n个字符复制到另一个 |
strdup | 复制字符串 |
施特雷夫 | 反转字符串 |
strcat | 在另一个字符串的末尾附加一个字符串 |
Strncat | 将字符串的前n个字符附加在另一个字符的末尾 |
strcmp | 比较两个字符串 |
strncmp | 比较两个字符串的前n个字符 |
strcmpi | 比较两个字符串时不考虑大小写(“ I”表示函数,忽略大小写) |
tric | 类似于strcmpi |
Strnicmp | 比较两个字符串的前n个字符而不考虑大小写 |
strchr | 查找字符串中给定“字符”的首次出现 |
strrchr | 查找字符串中给定“字符”的最后一次出现 |
strstr | 查找另一个字符串中给定“字符串”的首次出现 |
strset | 将字符串的所有字符设置为给定字符 |
结构集 | 将字符串的前n个字符设置为给定字符 |
翻译自:
c语言库函数 字符串
转载地址:http://kivzd.baihongyu.com/