-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0465f0f
commit b313696
Showing
38 changed files
with
561 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,33 @@ | ||
# 程序设计辅学 线下授课 | ||
|
||
欢迎来到竺院辅学程设线下授课版块🤗。你可以在左侧导航栏中详细浏览本模块的内容。 | ||
|
||
## 课程简介 | ||
|
||
程序设计课程讲述的内容较为表象。实质上,C 语言是一门很难的编程语言,不懂编译原理、操作系统和计算机体系结构无法获得深入的理解。我们希望通过线下辅学授课,为具有 C 语言基础或愿意深入学习这门语言的同学提供更深入、更底层方面的知识扩展,让同学们在计算机而非算法题的语境下理解 C 语言。 | ||
|
||
## 课程安排 | ||
|
||
2023-2024 学年,程序设计辅学线下授课课题组同学有: | ||
|
||
| 姓名 | 班级 | | ||
| :--- | :--- | | ||
| 朱宝林 | 混合2205 | | ||
| 李英琦 | 图灵2201 | | ||
| 谢集 | 混合2206 | | ||
| 胡育玮 | 混合2206 | | ||
| 苏煜程 | 图灵2201 | | ||
| 孙兆江 | 混合2204 | | ||
|
||
课程安排如下: | ||
|
||
| 节次 | 内容 | 时间 | 地点 | 课前资料 | PPT 与讲义 | | ||
| :--- | :--- | :--- | :--- | :--- | :--- | | ||
| 1 | 程序编译过程与调试 | | | [准备开发与调试环境](lecture1/pre_class.md) | [讲义](lecture1/lecture1.md) | | ||
| 2 | 类型系统与内存模型 | | | | | | ||
| 3 | I/O 与文件 | | | | | | ||
| 4 | C 标准库 | | | | | | ||
| 5 | 数据结构与算法 | | | | | | ||
|
||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains 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,54 @@ | ||
# 程序与编译过程 | ||
|
||
<!-- prettier-ignore-start --> | ||
!!! abstract "内容提要" | ||
|
||
- C 语言程序的基本结构 | ||
- 编译过程:从源代码到可执行文件 | ||
<!-- prettier-ignore-end --> | ||
|
||
## 导言 | ||
|
||
一般来说,C 语言课程的第一节课上,老师会从数的表示讲起,再到数据类型、变量、表达式,再到语句、函数等内容。但我觉得还有一些计算机的基础知识,它与 C 的语言部分关系不大,但却能让你对 C 语言的程序有更深刻的理解。因此我决定在辅学的第一节开头为大家简要补充这样一些基础知识: | ||
|
||
- 程序究竟是什么? | ||
- 程序是如何从源代码变成可执行文件的? | ||
|
||
## 程序的编译过程 | ||
|
||
我们都知道计算机是由数字电路构成的。数字电路只能处理 0 和 1,因此计算机中的任何数据都必须使用二进制表示,就像同学们在课上学到的那样。程序也是如此。在计算机刚刚诞生的阶段,工程师们不得不使用 0 和 1 和计算机打交道,就像下面的图一样。事实上,现代计算机的结构与 70 年前并没有本质上的不同。我们仍然不能直接对 CPU 说:为我计算 $1 + 1$ ,而仍然要把这个指令翻译一系列 0 和 1,只是翻译工作交给编译器来完成了。下面展示了程序设计语言的发展历史,编译过程其实就是这一历史的反向。 | ||
|
||
<!-- prettier-ignore-start --> | ||
::cards:: | ||
|
||
[ | ||
{ | ||
"title": "机器语言 Machine Code", | ||
"content": "这是第一代编程语言,也是计算机唯一能识别的语言。上图展示了世界上第一个计算机程序,它用来找出一个数最大的因数。", | ||
"image": "https://cdn.bowling233.top/images/2023/07/202307142052574.png" | ||
}, | ||
{ | ||
"title": "汇编语言 Assembly Language", | ||
"content": "这是第二代编程语言,其实就是机器语言的助记符。它使得程序员不用再直接与 0 和 1 打交道,程序的可读性也更强了。上图显示了将两个整数相加的汇编代码。", | ||
"image": "https://cdn.bowling233.top/images/2023/07/202307142105177.png" | ||
}, | ||
{ | ||
"title": "高级语言 High-level Language", | ||
"content": "这是第三代编程语言,它让程序员们不用再关注计算机结构上的细节,而是将注意力转移到要解决的问题上来。", | ||
}, | ||
|
||
] | ||
|
||
::/cards:: | ||
<!-- prettier-ignore-end --> | ||
|
||
GCC 是最经典的 C 语言编译器。当我们使用命令 `gcc -o test test.c` 编译一个 C 语言程序时,GCC 会调用一系列的程序将源代码翻译成汇编语言、再翻译成机器语言,最后经过链接产生可执行文件。下图展示了这个过程。 | ||
|
||
![](https://cdn.bowling233.top/images/2023/07/202307142109343.png) | ||
|
||
1. 预处理:由 C 预处理器(C Preprocessor)完成,它将源代码中的宏定义展开,将头文件中的内容插入到源代码中,删除注释等。预处理后的代码文件以 `.i` 为后缀。 | ||
2. 编译:由 C 编译器(C Compiler)完成,它将预处理后的文件翻译成汇编语言。编译后得到的汇编代码文件以 `.s` 为后缀。 | ||
3. 汇编:由汇编器(Assembler)完成,它将汇编代码翻译成机器语言。汇编后得到的机器代码文件以 `.o` 为后缀。 | ||
4. 链接:由链接器(Linker)完成,它将多个目标文件链接成一个可执行文件。链接后得到的可执行文件以 `.exe` 为后缀。 | ||
|
||
这里解释一下链接步骤。为什么要链接?模块化思想在程序设计中很重要。比如我写了一个在屏幕上显示图像的函数,把它编译成了机器码。你的程序需要使用这个图形库,你不用把我的源代码搬过去,或者我不想让你知道我的源代码。你只需要使用链接器把我的机器码和你的机器码链接起来就能生成一个功能完整的源程序了。 |
Oops, something went wrong.