Skip to content

Strings: char arrays and the null terminator · ⁨字符串:字符数组与结束符⁩

English

Text is an array of chars

  • C has no separate string type. A string is just an array of char.
  • char word[] = "hi"; actually stores 'h', 'i', and a hidden '\0' at the end.
  • You can read one character at a time with an index, exactly like any array.
中文

文本就是字符数组

  • C 没有单独的字符串类型。字符串就是一个 char 数组。
  • char word[] = "hi"; 实际上存了 'h'、'i',以及末尾一个隐藏的 '\0'。
  • 你可以用下标一个字符一个字符地读,和任何数组完全一样。

Handout

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩