Skip to content

Commit 2c10c76

Browse files
committed
doc: add keywords document.
1 parent a6671a9 commit 2c10c76

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

docs/c_keywords.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
C 关键字
2+
===
3+
4+
C 语言一共有32个关键字,如下表所示:
5+
6+
关键字 | 说明 | 关键字 | 说明
7+
---- | ---- | ---- | ----
8+
auto | 声明自动变量 | static | 声明静态变量
9+
short | 声明短整型变量或函数 | volatile | 说明变量在程序执行中可被隐含地改变
10+
[int](./c_variables.md) | 声明整型变量或函数 | void | 声明函数无返回值或无参数,声明无类型指针
11+
long | 声明长整型变量或函数 | [if](./c_conditions.md) | 条件语句
12+
[float](./c_variables.md) | 声明浮点型变量或函数 | [else](./c_conditions.md) | 条件语句否定分支(与 if 连用)
13+
double | 声明双精度变量或函数 | [switch](./c_switch.md) | 用于开关语句
14+
[char](./c_strings.md) | 声明字符型变量或函数 | case | 开关语句分支
15+
[struct](./c_structs.md) | 声明结构体变量或函数 | [for](./c_for_loop.md) | 一种循环语句
16+
union | 声明共用数据类型 | do | 循环语句的循环体
17+
[enum](./c_enum.md) | 声明枚举类型 | [while](./c_while_loop.md) | 循环语句的循环条件
18+
typedef | 用以给数据类型取别名 | goto | 无条件跳转语句
19+
[const](./c_constants.md) | 声明只读变量 | [continue](./c_break_continue.md) | 结束当前循环,开始下一轮循环
20+
unsigned | 声明无符号类型变量或函数 | [break](./c_break_continue.md) | 跳出当前循环
21+
signed | 声明有符号类型变量或函数 | default | 开关语句中的“其他”分支
22+
extern | 声明变量是在其他文件正声明 | sizeof | 计算数据类型长度
23+
register | 声明寄存器变量 | return | 子程序返回语句(可以带参数,也可不带参数)循环条件

docs/c_structs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@ int main() {
100100
return 0;
101101
}
102102
```
103+
<!--rehype:style= background: #ff000036;-->
103104

104105
会出现错误:
105106

106107
```bash
107108
prog.c:12:15: error: assignment to expression with array type
108109
```
110+
<!--rehype:style= background: #ff000036;-->
109111

110112
但是,有一个解决方案! 您可以使用 `strcpy()` 函数并将值分配给 `s1.myString`,如下所示:
111113

idoc.chapters.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@
3636
- /: 结构
3737
- c_structs.md: C 结构 Structures
3838

39+
- /: 参考
40+
- c_keywords.md: C 关键字 Keywords
41+

0 commit comments

Comments
 (0)