C字串函式庫
维基百科,自由的百科全书
| 建議将此條目或章節併入String.h。(討論) |
C字串函式庫是C語言裡負責各種字符串處理操作功能的標準函式庫,例如:複製,連接,標記化和搜索等。
包含的函數 [编辑]
| 字元組字串 | 闊字串 | 描述[note 1] | |
|---|---|---|---|
| 字符串 處理 |
strcpy |
wcscpy |
複製字串內容 |
strncpy |
wcsncpy |
writes exactly n bytes/wchar_t to a string, copying from given string or adding nulls | |
strcat |
wcscat |
appends one string to another | |
strncat |
wcsncat |
apponds no more than n bytes/wchar_t from one string to another | |
strxfrm |
wcsxfrm |
transforms a string according to the current locale | |
| 字符串檢查 | strlen |
wcslen |
傳回字符串的長度 |
strcmp |
wcscmp |
比較兩條字符串的內容 | |
strncmp |
wcsncmp |
compares a specific number of bytes/wchar_t in two strings | |
strcoll |
wcscoll |
compares two strings according to the current locale | |
strchr |
wcschr |
finds the first occurrence of a byte/wcahr_t in a string | |
strrchr |
wcsrchr |
finds the last occurrence of a byte/wchar_t in a string | |
strspn |
wcsspn |
finds in a string the first occurrence of a byte/wchar_t not in a set | |
strcspn |
wcscspn |
finds in a string the last occurrence of a byte/wchar_t not in a set | |
strpbrk |
wcspbrk |
finds in a string the first occurrence of a byte/wchar_t in a set | |
strstr |
wcsstr |
finds the first occurrence of a substring in a string | |
strtok |
wcstok |
splits string into tokens | |
| Miscellaneous | strerror |
不適用 | generates and reports a string containing an error message derived from the given error code |
| Memory manipulation |
memset |
wmemset |
fills a buffer with a repeated byte/wchar_t |
memcpy |
wmemcpy |
copies one buffer to another | |
memmove |
wmemmove |
copies one buffer to another, possibly overlapping, buffer | |
memcmp |
wmemcmp |
compares two buffers | |
memchr |
wmemchr |
finds the first occurrence of a byte/wchar_t in a buffer | |
|
|||
- 轉換函數
mbtowc- converts the first multibyte character in a string to the matching wide characterwctomb- converts a wide character to the matching multibyte character
參考資料 [编辑]
參看 [编辑]
- C語言字串語法 for source code syntax, including backslash escape sequences.
- 字串函數
- Null-terminated string