命名空間
變體
動作

以空字元結尾的位元組字串

出自 cppreference.com
< c‎ | 字串

以空字元終止的位元組字串(Null-terminated byte string,簡稱 NTBS)是一個非零位元組序列,後跟一個值為零的位元組(終止空字元)。位元組字串中的每個位元組對應某種字元集中的一個字元。例如,字元陣列 {'\x63','\x61','\x74','\0'} 是一個以 ASCII 編碼儲存字串 "cat" 的 NTBS。

目錄

[編輯] 函式

字元分類
定義於標頭檔 <ctype.h>
檢查字元是否為英數
(函式) [編輯]
檢查字元是否為字母
(函式) [編輯]
檢查字元是否為小寫字母
(函式) [編輯]
檢查字元是否為大寫字母
(函式) [編輯]
檢查字元是否為數字
(函式) [編輯]
檢查字元是否為十六進位字元
(函式) [編輯]
檢查字元是否為控制字元
(函式) [編輯]
檢查字元是否為圖形字元
(函式) [編輯]
檢查字元是否為空白字元
(函式) [編輯]
檢查字元是否為水平空白字元
(函式) [編輯]
檢查字元是否為可列印字元
(函式) [編輯]
檢查字元是否為標點符號
(函式) [編輯]
字元操作
將字元轉換為小寫
(函式) [編輯]
將字元轉換為大寫
(函式) [編輯]

注意:未來可能會向標頭檔 <ctype.h> 新增更多以 tois 開頭,並後接小寫字母的函式,因此包含該標頭檔的程式不應定義這些名稱。

ASCII 值 字元

iscntrl
iswcntrl

isprint
iswprint

isspace
iswspace

isblank
iswblank

isgraph
iswgraph

ispunct
iswpunct

isalnum
iswalnum

isalpha
iswalpha

isupper
iswupper

islower
iswlower

isdigit
iswdigit

isxdigit
iswxdigit

十進位 十六進位 八進位
0–8 \x0\x8 \0\10 控制碼 (NUL 等) ≠0 0 0 0 0 0 0 0 0 0 0 0
9 \x9 \11 定位字元 (\t) ≠0 0 ≠0 ≠0 0 0 0 0 0 0 0 0
10–13 \xA\xD \12\15 空白字元 (\n, \v, \f, \r) ≠0 0 ≠0 0 0 0 0 0 0 0 0 0
14–31 \xE\x1F \16\37 控制碼 ≠0 0 0 0 0 0 0 0 0 0 0 0
32 \x20 \40 空格 0 ≠0 ≠0 ≠0 0 0 0 0 0 0 0 0
33–47 \x21\x2F \41\57 !"#$%&'()*+,-./ 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
48–57 \x30\x39 \60\71 0123456789 0 ≠0 0 0 ≠0 0 ≠0 0 0 0 ≠0 ≠0
58–64 \x3A\x40 \72\100 :;<=>?@ 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
65–70 \x41\x46 \101\106 ABCDEF 0 ≠0 0 0 ≠0 0 ≠0 ≠0 ≠0 0 0 ≠0
71–90 \x47\x5A \107\132 GHIJKLMNOP
QRSTUVWXYZ
0 ≠0 0 0 ≠0 0 ≠0 ≠0 ≠0 0 0 0
91–96 \x5B\x60 \133\140 [\]^_` 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
97–102 \x61\x66 \141\146 abcdef 0 ≠0 0 0 ≠0 0 ≠0 ≠0 0 ≠0 0 ≠0
103–122 \x67\x7A \147\172 ghijklmnop
qrstuvwxyz
0 ≠0 0 0 ≠0 0 ≠0 ≠0 0 ≠0 0 0
123–126 \x7B\x7E \173\176 {|}~ 0 ≠0 0 0 ≠0 ≠0 0 0 0 0 0 0
127 \x7F \177 刪除字元 (DEL) ≠0 0 0 0 0 0 0 0 0 0 0 0
數值格式之間的轉換
定義於標頭檔 <stdlib.h>
將位元組字串轉換為浮點數值
(函式) [編輯]
將位元組字串轉換為整數值
(函式) [編輯]
將位元組字串轉換為整數值
(函式) [編輯]
將位元組字串轉換為無號整數值
(函式) [編輯]
將位元組字串轉換為浮點數值
(函式) [編輯]
將浮點數值轉換為位元組字串
(函式) [編輯]
定義於標頭檔 <inttypes.h>
將位元組字串轉換為 intmax_tuintmax_t
(函式) [編輯]
字串操作
定義於標頭檔 <string.h>
將一個字串複製到另一個字串
(函式) [編輯]
從一個字串複製特定數量的字元到另一個字串
(函式) [編輯]
串接兩個字串
(函式) [編輯]
串接兩個字串的特定數量字元
(函式) [編輯]
轉換字串,使得 strcmp 的結果與 strcoll 相同
(函式) [編輯]
(C23)
分配字串的副本
(函式) [編輯]
分配指定長度的字串副本
(函式) [編輯]
字串檢查
定義於標頭檔 <string.h>
傳回給定字串的長度
(函式) [編輯]
比較兩個字串
(函式) [編輯]
比較兩個字串中特定數量的字元
(函式) [編輯]
依據當前區域設定比較兩個字串
(函式) [編輯]
尋找字元第一次出現的位置
(函式) [編輯]
尋找字元最後一次出現的位置
(函式) [編輯]
傳回僅包含另一個位元組字串中出現的字元,
其最長初始區段的長度
(函式) [編輯]
傳回僅包含另一個位元組字串中出現的字元,
傳回僅包含另一個位元組字串中未出現的字元,
(函式) [編輯]
在一個字串中尋找另一個字串中任意字元首次出現的位置
(函式) [編輯]
尋找子字串第一次出現的位置
(函式) [編輯]
在位元組字串中尋找下一個標記 (token)
(函式) [編輯]
字元陣列操作
定義於標頭檔 <string.h>
在陣列中搜尋字元第一次出現的位置
(函式) [編輯]
比較兩個緩衝區
(函式) [編輯]
使用字元填滿緩衝區
(函式) [編輯]
將一個緩衝區複製到另一個
(函式) [編輯]
移動一個緩衝區到另一個
(函式) [編輯]
將一個緩衝區複製到另一個,遇到指定分隔符時停止
(函式) [編輯]
其他
定義於標頭檔 <string.h>
傳回給定錯誤碼的文字版本
(函式) [編輯]

[編輯] 參考資料

延伸內容
  • C23 標準 (ISO/IEC 9899:2024)
  • 7.4 字元處理 <ctype.h> (頁碼:待定)
  • 7.8 整數類型的格式轉換 <inttypes.h> (頁碼:待定)
  • 7.22 一般公用程式 <stdlib.h> (p: 待定)
  • 7.24 字串處理 <string.h> (頁碼:待定)
  • 7.31.2 字元處理 <ctype.h> (頁碼:待定)
  • 7.31.5 整數類型的格式轉換 <inttypes.h> (頁碼:待定)
  • 7.31.12 一般公用程式 <stdlib.h> (p: 待定)
  • 7.31.13 字串處理 <string.h> (頁碼:待定)
  • K.3.6 通用工具 <stdlib.h> (頁碼:待定)
  • K.3.7 字串處理 <string.h> (頁碼:待定)
  • C17 標準 (ISO/IEC 9899:2018)
  • 7.4 字元處理 <ctype.h> (頁碼:待定)
  • 7.8 整數類型的格式轉換 <inttypes.h> (頁碼:待定)
  • 7.22 一般公用程式 <stdlib.h> (p: 待定)
  • 7.24 字串處理 <string.h> (頁碼:待定)
  • 7.31.2 字元處理 <ctype.h> (頁碼:待定)
  • 7.31.5 整數類型的格式轉換 <inttypes.h> (頁碼:待定)
  • 7.31.12 一般公用程式 <stdlib.h> (p: 待定)
  • 7.31.13 字串處理 <string.h> (頁碼:待定)
  • K.3.6 通用工具 <stdlib.h> (頁碼:待定)
  • K.3.7 字串處理 <string.h> (頁碼:待定)
  • C11 標準 (ISO/IEC 9899:2011)
  • 7.4 字元處理 <ctype.h> (頁碼:200-204)
  • 7.8 整數類型的格式轉換 <inttypes.h> (頁碼:217-220)
  • 7.22 一般公用程式 <stdlib.h> (p: 340-360)
  • 7.24 字串處理 <string.h> (頁碼:362-372)
  • 7.31.2 字元處理 <ctype.h> (頁碼:455)
  • 7.31.5 整數類型的格式轉換 <inttypes.h> (頁碼:455)
  • 7.31.12 一般公用程式 <stdlib.h> (p: 456)
  • 7.31.13 字串處理 <string.h> (頁碼:456)
  • K.3.6 通用工具 <stdlib.h> (頁碼:604-613)
  • K.3.7 字串處理 <string.h> (頁碼:614-623)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.4 字元處理 <ctype.h> (頁碼:181-185)
  • 7.8 整數類型的格式轉換 <inttypes.h> (頁碼:198-201)
  • 7.20 一般公用程式 <stdlib.h> (p: 306-324)
  • 7.21 字串處理 <string.h> (頁碼:325-334)
  • 7.26.2 字元處理 <ctype.h> (頁碼:401)
  • 7.26.4 整數類型的格式轉換 <inttypes.h> (頁碼:401)
  • 7.26.10 一般公用程式 <stdlib.h> (p: 402)
  • 7.26.11 字串處理 <string.h> (頁碼:402)
  • C89/C90 標準 (ISO/IEC 9899:1990)
  • 4.3 字元處理 <ctype.h>
  • 4.10 一般公用程式 <stdlib.h>
  • 4.11 字串處理 <string.h>
  • 4.13.2 字元處理 <ctype.h>
  • 4.13.7 一般工具 <stdlib.h>
  • 4.13.8 字串處理 <string.h>

[編輯] 參見

C++ 文件 關於 Null-terminated byte strings (以空字元終止的位元組字串)
English Deutsch 日本語 中文(简体) 中文(繁體)