-
Notifications
You must be signed in to change notification settings - Fork 13
添加了C语言前置知识的模块 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Juryorca
wants to merge
6
commits into
FDUCSLG:main
Choose a base branch
from
Juryorca:add/c-pre-knowledge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+81
−0
Draft
添加了C语言前置知识的模块 #32
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # 编译器(Compiler) | ||
| 这篇文章将初步告诉你计算机如何“看懂”你的代码。 | ||
|
|
||
| ## 计算机能看懂什么 | ||
| 计算机能且只能直接看懂**机器语言**,也就是由 0 和 1 组成的二进制指令集,几乎不可读。 | ||
|
|
||
| 例如: | ||
| ``` | ||
| 1011000000000001 | ||
| ``` | ||
| 用`x86_64`汇编定义的指令来解释它,是: | ||
| ``` | ||
| mov al, 1 | ||
| ``` | ||
| - 前八位 `10110000` 可以理解为“将立即数放到`al`寄存器”的操作码 | ||
| - 后八位 `00000001` 是要存入的数字 1。 | ||
|
|
||
| 机器语言对人类很不友好,但cpu需要它来理解需要执行什么指令。我们(通常)不能直接使用 0/1 编程——这就是编译器存在的理由:把人能读、能写的高级语言(如 C)翻译成机器理解并执行的指令。 | ||
|
|
||
| ## 编译器做了什么 | ||
| TODO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # 编辑器(Editor)&&集成开发环境(Integrated Development Environment) | ||
|
|
||
| ## 编辑器 | ||
| ### 什么是编辑器? | ||
| 编辑器(或者说是文本编辑器)本是纯文本处理工具,仅用于编写/修改代码(如VS Code、记事本、Sublime Text),没有代码分析、编译等额外功能。 | ||
| 但为了方便大家编程,编辑器接入了扩展功能,使编码更加准确高效。我们称其为代码编辑器。 | ||
| - 语法高亮:按照编程语言规则(c,python,c++,java)用不同颜色标注关键字,变量,函数,使得代码更易读 | ||
| - 智能补全;基于代码规则和上下文自动提示代码片段(vscode的‘tap’代替思考) | ||
| ### 常见的编辑器 | ||
| - Windows记事本/Mac文本编辑/Linux vim | ||
| - VS code/GitHub网页编辑器 | ||
| - vscode环境配置请移步至.... | ||
|
|
||
|
|
||
| ## 集成开发环境(IDE)Dev-C++/Code::Blocks/X-code(Mac) | ||
| ### 什么是集成开发环境? | ||
| 集成开发环境 | ||
|
|
||
|
|
||
|
|
||
| ### 下载 | ||
| - Dev-C++(Windows)下载: | ||
| - Code::Blocks(windows)下载: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #index.md | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # 为什么要学 C 语言 | ||
|
|
||
| 学 C 语言的核心价值可以从以下三个维度来理解: | ||
|
|
||
| ## 一、深入理解计算机底层 | ||
| C 语言贴近硬件,能够直接操作内存并与底层资源交互,帮助你理解代码如何被计算机执行: | ||
|
|
||
| - 明白 `int a = 1;` 并不仅仅是“定义一个变量”,而是在内存中为该变量分配空间并存储二进制表示(在常见的 32/64 位平台上,`int` 往往占 4 字节,但不同平台可能不同)。 | ||
| - 理解“编译”是把人类可读的源码翻译成 CPU 能执行的机器指令(或汇编),以及汇编、链接的基本流程。 | ||
| - 学会使用指针、理解栈和堆、内存管理、对齐、调用约定等底层概念,这些知识会让你在调试、性能优化和系统设计时有更直观的判断力。 | ||
|
|
||
| ## 二、多领域的基础工具 | ||
| C 在很多核心领域仍然不可或缺,学会后能覆盖很多高价值场景: | ||
|
|
||
| - 系统开发:操作系统内核(如 Linux)、驱动程序、固件与嵌入式系统(单片机、智能设备)。 | ||
| - 底层软件:编译器、数据库底层实现、网络协议栈等。 | ||
| - 高性能场景:数值计算、工业控制、部分游戏引擎底层模块(多数现代大型游戏引擎使用 C++,但底层思想与性能优化与 C 密切相关)。 | ||
| - 其它:高性能网络服务、实时系统、微控制器开发等。 | ||
|
|
||
| 学会 C 可以让你更容易进入这些领域或理解这些领域的源码与设计。 | ||
|
|
||
| ## 三、锻炼基本功,降低后续学习成本 | ||
| C 的语法和编程风格要求你显式说明类型并手动管理资源,这会培养良好的工程习惯: | ||
|
|
||
| - 关注内存与资源管理,学会发现和避免内存泄漏、悬空指针等常见问题。 | ||
| - 熟练掌握流程控制(`if`、`switch`、`for`、`while`)与函数设计,这些结构是大多数编程语言的共通模板。 | ||
| - C 的严谨性迫使你理解计算机在做什么(数据在虚拟内存中如何存储、函数调用如何进行、IO 的原理等),对这些内容的理解会让你在转学其他语言(如 Python、C++、Go、Rust)时事半功倍。 | ||
|
|
||
| ## 注意事项 | ||
| - C 功能强但容易出现低级错误(越界、悬指针、未定义行为等),调试难度相对较高。学习时务必养成良好的编码规范、重视调试工具使用。 | ||
| - 在现代软件工程中,选择 C 还是更高层语言应根据项目需求(开发效率 vs. 执行效率 vs. 可维护性)权衡。 | ||
|
|
||
| ## 简短结论 | ||
| - 如果你的目标是做底层开发、嵌入式系统、操作系统或追求高性能,学 C 是非常必要的基础。 | ||
| - 如果你想打好编程基础、理解计算机原理,C 是一块极好的跳板。 | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The index file contains only a placeholder comment '#index.md' without any actual documentation content. Consider adding meaningful content such as an introduction to C pre-knowledge topics, a table of contents, or links to related sections.