C字串函式庫

维基百科,自由的百科全书
跳转至: 导航搜索

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
  1. ^ 描述內的字串可以指字元組字串或闊字串
轉換函數
  • mbtowc - converts the first multibyte character in a string to the matching wide character
  • wctomb - converts a wide character to the matching multibyte character

參考資料[编辑]

參看[编辑]

Wikibooks-logo.svg
您可以在維基教科書中查找此百科条目的相關電子教程: