|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『楼 主』:
C语言(四个字)http://www.shucunwang.com/RunCode/c/
使用 LLM 解释/回答一下
http://www.shucunwang.com/RunCode/c/
http://codepad.org/TIbKemXJ
http://www.manonggu.com/biancheng/
C 语言资源大全中文版
https://github.com/jobbole/awesome-c-cn
【生肉】比较C语言和机器语言 (英语,看示范)
https://www.bilibili.com/video/av11237858
颖思教学网(turbo c为主的C语言内容)
http://www.winyes.com/
B站C语言
https://www.bilibili.com/video/av9430200/?from=search&seid=8131884833781373784
搜狗 turbo c 中文版 下载 (用运行向导中的汉化版本,使用虚拟机模式运行程序)
http://xiazai.sogou.com/detail/34/16/902784868571182432.html?uID=440DBA3D4F0A900A00000000598FB273
c语言
锁定
同义词 c(计算机语言)一般指c语言
本词条由“科普中国”百科科学词条编写与应用工作项目 审核 。
C语言是一门通用计算机编程语言,应用广泛。C语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。
尽管C语言提供了许多低级处理的功能,但仍然保持着良好跨平台的特性,以一个标准规格写出的C语言程序可在许多电脑平台上进行编译,甚至包含一些嵌入式处理器(单片机或称MCU)以及超级电脑等作业平台。
二十世纪八十年代,为了避免各开发厂商用的C语言语法产生差异,由美国国家标准局为C语言订定了一套完整的国际标准语法,称为ANSI C,作为C语言最初的标准。
中文名
C语言
外文名
The C Programming Language
类 别
计算机程序设计语言
创始人
Dennis MacAlistair Ritchie
创始时间
1972年
发 源
BCPL语言
主要编译器
Clang、GCC、MSVC、Turbo C等
启发语言
B语言、汇编、ALGOL68
操作系统
多平台
目录
1 发展历史
2 编程开发
▪ 编译器
▪ 集成开发环境(IDE)
▪ Hello World
3 语言标准
▪ K&R C
▪ ANSI C / C89标准
▪ C99标准
▪ C11标准
4 语言特点
▪ 基本特性
▪ 特有特点
▪ 优缺点
▪ C11新特性
5 语言组成
▪ 基本构成
▪ 关键字
▪ 语法结构
▪ 程序结构
▪ 函数
▪ 运算符号
6 经典错误
发展历史
C语言之所以命名为C,是因为 C语言源自Ken Thompson发明的B语言,而 B语言则源自BCPL语言。
1967年,剑桥大学的Martin Richards对CPL语言进行了简化,于是产生了BCPL(Basic Combined Programming Language)语言。
c语言宣传图 c语言宣传图
20世纪60年代,美国AT&T公司贝尔实验室(AT&T Bell Laboratory)的研究员Ken Thompson闲来无事,手痒难耐,想玩一个他自己编的,模拟在太阳系航行的电子游戏——Space Travel。他背着老板,找到了台空闲的机器——PDP-7。但这台机器没有操作系统,而游戏必须使用操作系统的一些功能,于是他着手为PDP-7开发操作系统。后来,这个操作系统被命名为——UNIX。
1970年,美国贝尔实验室的 Ken Thompson,以BCPL语言为基础,设计出很简单且很接近硬件的B语言(取BCPL的首字母)。并且他用B语言写了第一个UNIX操作系统。
1971年,同样酷爱Space Travel的Dennis M.Ritchie为了能早点儿玩上游戏,加入了Thompson的开发项目,合作开发UNIX。他的主要工作是改造B语言,使其更成熟。
1972年,美国贝尔实验室的 D.M.Ritchie 在B语言的基础上最终设计出了一种新的语言,他取了BCPL的第二个字母作为这种语言的名字,这就是C语言。
1973年初,C语言的主体完成。Thompson和Ritchie迫不及待地开始用它完全重写了UNIX。此时,编程的乐趣使他们已经完全忘记了那个"Space Travel",一门心思地投入到了UNIX和C语言的开发中。随着UNIX的发展,C语言自身也在不断地完善。直到今天,各种版本的UNIX内核和周边工具仍然使用C语言作为最主要的开发语言,其中还有不少继承Thompson和Ritchie之手的代码。
在开发中,他们还考虑把UNIX移植到其他类型的计算机上使用。C语言强大的移植性(Portability)在此显现。机器语言和汇编语言都不具有移植性,为x86开发的程序,不可能在Alpha,SPARC和ARM等机器上运行。而C语言程序则可以使用在任意架构的处理器上,只要那种架构的处理器具有对应的C语言编译器和库,然后将C源代码编译、连接成目标二进制文件之后即可运行。
1977年,Dennis M.Ritchie发表了不依赖于具体机器系统的C语言编译文本《可移植的C语言编译程序》。
C语言继续发展,在1982年,很多有识之士和美国国家标准协会为了使这个语言健康地发展下去,决定成立C标准委员会,建立C语言的标准。委员会由硬件厂商,编译器及其他软件工具生产商,软件设计师,顾问,学术界人士,C语言作者和应用程序员组成。1989年,ANSI发布了第一个完整的C语言标准——ANSI X3.159—1989,简称“C89”,不过人们也习惯称其为“ANSI C”。C89在1990年被国际标准组织ISO(International Organization for Standardization)一字不改地采纳,ISO官方给予的名称为:ISO/IEC 9899,所以ISO/IEC9899: 1990也通常被简称为“C90”。1999年,在做了一些必要的修正和完善后,ISO发布了新的C语言标准,命名为ISO/IEC 9899:1999,简称“C99”。 在2011年12月8日,ISO又正式发布了新的标准,称为ISO/IEC9899: 2011,简称为“C11”。
编程开发
编译器
GCC,GNU组织开发的开源免费的编译器
MinGW,Windows操作系统下的GCC
Clang,开源的BSD协议的基于LLVM的编译器
Visual C++ :: cl.exe,Microsoft VC++自带的编译器
集成开发环境(IDE)
CodeBlocks,开源免费的C/C++ IDE
CodeLite,开源、跨平台的C/C++集成开发环境
Orwell Dev-C++,可移植的C/C++IDE
C-Free
Light Table
Visual Stdio系列
Hello World
下面是一个在标准输出设备 (stdout) 上,印出 "Hello, world!" 字符串的简单程序。类似的程序,通常作为初学编程语言时的第一个程序:
1
2
3
4
5
6
7
#include <stdio.h>
int main(void)
{
printf("Hello, world!");
return 0;
}
语言标准
K&R C
起初,C语言没有官方标准。1978年由美国电话电报公司(AT&T)贝尔实验室正式发表了C语言。布莱恩·柯林汉(Brian Kernighan) 和 丹尼斯·里奇(Dennis Ritchie) 出版了一本书,名叫《The C Programming Language》。这本书被 C语言开发者们称为K&R,很多年来被当作 C语言的非正式的标准说明。人们称这个版本的 C语言为K&R C。
K&R C主要介绍了以下特色:
结构体(struct)类型
长整数(long int)类型
无符号整数(unsigned int)类型
把运算符=+和=-改为+=和-=。因为=+和=-会使得编译器不知道使用者要处理i = -10还是i =- 10,使得处理上产生混淆。
即使在后来ANSI C标准被提出的许多年后,K&R C仍然是许多编译器的最 准要求,许多老旧的编译器仍然运行K&R C的标准。
ANSI C / C89标准
1970到80年代,C语言被广泛应用,从大型主机到小型微机,也衍生了C语言的很多不同版本。
1983年,美国国家标准协会(ANSI)成立了一个委员会X3J11,来制定 C语言标准。
1989年,美国国家标准协会(ANSI)通过了C语言标准,被称为ANSI X3.159-1989 "Programming Language C"。因为这个标准是1989年通过的,所以一般简称C89标准。有些人也简称ANSI C,因为这个标准是美国国家标准协会(ANSI)发布的。
1990年,国际标准化组织(ISO)和国际电工委员会(IEC)把C89标准定为C语言的国际标准,命名为ISO/IEC 9899:1990 - Programming languages -- C 。因为此标准是在1990年发布的,所以有些人把简称作C90标准。不过大多数人依然称之为C89标准,因为此标准与ANSI C89标准完全等同。
1994年,国际标准化组织(ISO)和国际电工委员会(IEC)发布了C89标准修订版,名叫ISO/IEC 9899:1990/Cor 1:1994 ,有些人简称为C94标准。
1995年,国际标准化组织(ISO)和国际电工委员会(IEC)再次发布了C89标准修订版,名叫ISO/IEC 9899:1990/Amd 1:1995 - C Integrity ,有些人简称为C95标准。
C99标准
1999年1月,国际标准化组织(ISO)和国际电工委员会(IEC)发布了C语言的新标准,名叫ISO/IEC 9899:1999 - Programming languages -- C ,简称C99标准。这是C语言的第二个官方标准。
在C99中包括的特性有:
增加了对编译器的限制,比如源程序每行要求至少支持到 4095 字节,变量名函数名的要求支持到 63 字节(extern 要求支持到 31)。
增强了预处理功能。例如:
宏支持取可变参数 #define Macro(...) __VA_ARGS__
使用宏的时候,允许省略参数,被省略的参数会被扩展成空串。
支持 // 开头的单行注释(这个特性实际上在C89的很多编译器上已经被支持了)
增加了新关键字 restrict, inline, _Complex, _Imaginary, _Bool
支持 long long, long double _Complex, float _Complex 等类型
支持不定长的数组,即数组长度可以在运行时决定,比如利用变量作为数组长度。声明时使用 int a 的形式。不过考虑到效率和实现,不定长数组不能用在全局,或 struct 与 union 里。
变量声明不必放在语句块的开头,for 语句提倡写成 for(int i=0;i<100;++i) 的形式,即i 只在 for 语句块内部有效。
允许采用(type_name){xx,xx,xx} 类似于 C++ 的构造函数的形式构造匿名的结构体。
复合字面量:初始化结构的时候允许对特定的元素赋值,形式为:
struct test{int a,b;} foo = { .a = {1}, .a = 2 };
struct test{int a, b, c, d;} foo = { .a = 1, .c = 3, 4, .b = 5 }; // 3,4 是对 .c,.d 赋值的
格式化字符串中,利用 \u 支持 unicode 的字符。
支持 16 进制的浮点数的描述。
printf scanf 的格式化串增加了对 long long int 类型的支持。
浮点数的内部数据描述支持了新标准,可以使用 #pragma 编译器指令指定。
除了已有的 __line__ __file__ 以外,增加了 __func__ 得到当前的函数名。
允许编译器化简非常数的表达式。
修改了 /% 处理负数时的定义,这样可以给出明确的结果,例如在C89中-22 / 7 = -3, -22% 7 = -1,也可以-22 / 7= -4, -22% 7 = 6。 而C99中明确为 -22 / 7 = -3, -22% 7 = -1,只有一种结果。
取消了函数返回类型默认为 int 的规定。
允许 struct 定义的最后一个数组不指定其长度,写做 (flexible array member)。
const const int i 将被当作 const int i 处理。
增加和修改了一些标准头文件,比如定义 bool 的 <stdbool.h> ,定义一些标准长度的 int 的 <inttypes.h> ,定义复数的 <complex.h> ,定义宽字符的 <wctype.h> ,类似于泛型的数学函数 <tgmath.h>, 浮点数相关的 <fenv.h>。 在<stdarg.h> 增加了 va_copy 用于复制 ... 的参数。里增加了 struct tmx ,对 struct tm 做了扩展。
输入输出对宽字符以及长整数等做了相应的支持。
GCC和其它一些商业编译器支持C99的大部分特性。
C11标准
2011年12月8日,国际标准化组织(ISO)和国际电工委员会(IEC)再次发布了C语言的新标准,名叫ISO/IEC 9899:2011 - Information technology -- Programming languages -- C ,简称C11标准,原名C1X。这是C语言的第三个官方标准,也是C语言的最新标准。
新的标准提高了对C++的兼容性,并增加了一些新的特性。这些新特性包括:
对齐处理(Alignment)的标准化(包括_Alignas标志符,alignof运算符, aligned_alloc函数以及<stdalign.h>头文件。
_Noreturn 函数标记,类似于 gcc 的 __attribute__((noreturn))。
_Generic 关键字。
多线程(Multithreading)支持,包括:
_Thread_local存储类型标识符,<threads.h>头文件,里面包含了线程的创建和管理函数。
_Atomic类型修饰符和<stdatomic.h>头文件。
增强的Unicode的支持。基于C Unicode技术报告ISO/IEC TR 19769:2004,增强了对Unicode的支持。包括为UTF-16/UTF-32编码增加了char16_t和char32_t数据类型,提供了包含unicode字符串转换函数的头文件<uchar.h>.
删除了 gets() 函数,使用一个新的更安全的函数gets_s()替代。
增加了边界检查函数接口,定义了新的安全的函数,例如 fopen_s(),strcat_s() 等等。
增加了更多浮点处理宏。
匿名结构体/联合体支持。这个在gcc早已存在,C11将其引入标准。
静态断言(static assertions),_Static_assert(),在解释 #if 和 #error 之后被处理。
新的 fopen() 模式,(“…x”)。类似 POSIX 中的 O_CREAT|O_EXCL,在文件锁中比较常用。
新增 quick_exit() 函数作为第三种终止程序的方式。当 exit()失败时可以做最少的清理工作。
语言特点
基本特性
C++语言代码 C++语言代码
1、高级语言:它是把高级语言的基本结构和语句与低级语言的实用性结合起来的工作单元。
2、结构式语言:结构式语言的显著特点是代码及数据的分隔化,即程序的各个部分除了必要的信息交流外彼此独立。这种结构化方式可使程序层次清晰,便于使用、维护以及调试。C 语言是以函数形式提供给用户的,这些函数可方便的调用,并具有多种循环、条件语句控制程序流向,从而使程序完全结构化。
4、代码级别的跨平台:由于标准的存在,使得几乎同样的C代码可用于多种操作系统,如Windows、DOS、UNIX等等;也适用于多种机型。C语言对编写需要进行硬件操作的场合,优于其它高级语言。
5、使用指针:可以直接进行靠近硬件的操作,但是C的指针操作不做保护,也给它带来了很多不安全的因素。C++在这方面做了改进,在保留了指针操作的同时又增强了安全性,受到了一些用户的支持,但是,由于这些改进增加语言的复杂度,也为另一部分所诟病。Java则吸取了C++的教训,取消了指针操作,也取消了C++改进中一些备受争议的地方,在安全性和适合性方面均取得良好的效果,但其本身解释在虚拟机中运行,运行效率低于C++/C。一般而言,C,C++,java被视为同一系的语言,它们长期占据着程序使用榜的前三名。
特有特点
C语言是一个有结构化程序设计、具有变量作用域(variable scope)以及递归功能的过程式语言。
C语言传递参数均是以值传递(pass by value),另外也可以传递指针(a pointer passed by value)。
不同的变量类型可以用结构体(struct)组合在一起。
只有32个保留字(reserved keywords),使变量、函数命名有更多弹性。
部份的变量类型可以转换,例如整型和字符型变量。
通过指针(pointer),C语言可以容易的对存储器进行低级控制。
预编译处理(preprocessor)让C语言的编译更具有弹性。
优缺点
优点
1、简洁紧凑、灵活方便
C语言一共只有32个关键字,9种控制语句,程序书写形式自由,区分大小写。把高级语言的基本结构和语句与低级语言的实用性结合起来。C 语言可以像汇编语言一样对位、字节和地址进行操作,而这三者是计算机最基本的工作单元。
C语言的 Hello World 程序 C语言的 Hello World 程序
2、运算符丰富
C语言的运算符包含的范围很广泛,共有34种运算符。C语言把括号、赋值、强制类型转换等都作为运算符处理。从而使C语言的运算类型极其丰富,表达式类型多样化。灵活使用各种运算符可以实现在其它高级语言中难以实现的运算。
3、数据类型丰富
C语言的数据类型有:整型、实型、字符型、数组类型、指针类型、结构体类型、共用体类型等。能用来实现各种复杂的数据结构的运算。并引入了指针概念,使程序效率更高。
4、表达方式灵活实用
C语言提供多种运算符和表达式值的方法,对问题的表达可通过多种途径获得,其程序设计更主动、灵活。它语法限制不太严格,程序设计自由度大,如对整型量与字符型数据及逻辑型数据可以通用等。
5、允许直接访问物理地址,对硬件进行操作
由于C语言允许直接访问物理地址,可以直接对硬件进行操作,因此它既具有高级语言的功能,又具有低级语言的许多功能,能够像汇编语言一样对位(bit)、字节和地址进行操作,而这三者是计算机最基本的工作单元,可用来写系统软件。
6、生成目标代码质量高,程序执行效率高
C语言描述问题比汇编语言迅速,工作量小、可读性好,易于调试、修改和移植,而代码质量与汇编语言相当。C语言一般只比汇编程序生成的目标代码效率低10%~20%。
7、可移植性好
C语言在不同机器上的C编译程序,86%的代码是公共的,所以C语言的编译程序便于移植。在一个环境上用C语言编写的程序,不改动或稍加改动,就可移植到另一个完全不同的环境中运行。
8、表达力强
C语言有丰富的数据结构和运算符。包含了各种数据结构,如整型、数组类型、指针类型和联合类型等,用来实现各种数据结构的运算。C语言的运算符有34种,范围很宽,灵活使用各种运算符可以实现难度极大的运算。
C语言能直接访问硬件的物理地址,能进行位(bit)操作。兼有高级语言和低级语言的许多优点。
它既可用来编写系统软件,又可用来开发应用软件,已成为一种通用程序设计语言。
另外C语言具有强大的图形功能,支持多种显示器和驱动器。且计算功能、逻辑判断功能强大。
缺点
1、 C语言的缺点主要表现在数据的封装性上,这一点使得C在数据的安全性上有很大缺陷,这也是C和C++的一大区别。
2、 C语言的语法限制不太严格,对变量的类型约束不严格,影响程序的安全性,对数组下标越界不作检查等。从应用的角度,C语言比其他高级语言较难掌握。也就是说,对用C语言的人,要求对程序设计更熟练一些。
C11新特性
1、对齐处理(Alignment)的标准化(包括_Alignas标志符,alignof运算符,aligned_alloc函数以及<stdalign.h>头文件)。
2、_Noreturn 函数标记,类似于 gcc 的 __attribute__(noreturn)。
3、_Generic关键字。
4、多线程(Multithreading)支持,包括:_Thread_local存储类型标识符,<threads.h>;头文件,里面包含了线程的创建和管理函数。
5、增强的Unicode的支持,基于C Unicode技术报告ISO/IEC TR 19769:2004,增强了对Unicode的支持。包括为UTF-16/UTF-32编码增加了char16_t和char32_t数据类型,提供了包含unicode字符串转换函数的头文件<uchar.h>.
6、删除了 gets() 函数,使用一个新的更安全的函数gets_s()替代。
7、增加了边界检查函数接口,定义了新的安全的函数,例如 fopen_s(),strcat_s()等等。
8、增加了更多浮点处理宏。
9、匿名结构体/联合体支持,这个在gcc早已存在,C11将其引入标准。
10、静态断言(Static assertions),_Static_assert(),在解释 #if 和 #error 之后被处理。
11、新的 fopen()模式,(“…x”),类似 POSIX 中的 O_CREAT|O_EXCL,在文件锁中比较常用。
12、新增 quick_exit()函数作为第三种终止程序的方式。当 exit()失败时可以做最少的清理工作。
13、_Atomic类型修饰符和<stdatomic.h>头文件。
语言组成
基本构成
数据类型
C的数据类型包括:整型、字符型、实型或浮点型(单精度和双精度)、枚举类型、数组类型、结构体类型、共用体类型、指针类型和空类型。
常量与变量
常量其值不可改变,符号常量名通常用大写。
变量是以某标识符为名字,其值可以改变的量。标识符是以字母或下划线开头的一串由字母、数字或下划线构成的序列,请注意第一个字符必须为字母或下划线,否则为不合法的变量名。变量在编译时为其分配相应存储单元。
数组
如果一个变量名后面跟着一个有数字的中括号,这个声明就是数组声明。字符串也是一种数组。它们以ASCII的NULL作为数组的结束。要特别注意的是,方括内的索引值是从0算起的。
指针
如果一个变量声明时在前面使用 * 号,表明这是个指针型变量。换句话说,该变量存储一个地址,而 *(此处特指单目运算符 * ,下同。C语言中另有 双目运算符 *) 则是取内容操作符,意思是取这个内存地址里存储的内容。指针是 C 语言区别于其他同时代高级语言的主要特征之一。
指针不仅可以是变量的地址,还可以是数组、数组元素、函数的地址。通过指针作为形式参数可以在函数的调用过程得到一个以上的返回值,不同于return(z)这样的仅能得到一个返回值。
指针是一把双刃剑,许多操作可以通过指针自然的表达,但是不正确的或者过分的使用指针又会给程序带来大量潜在的错误。
字符串
C语言的字符串其实就是以'\0'字符结尾的char型数组,使用字符型并不需要引用库,但是使用字符串就需要C标准库里面的一些用于对字符串进行操作的函数。它们不同于字符数组。使用这些函数需要引用头文件<string.h>。
文件输入/输出
在C语言中,输入和输出是经由标准库中的一组函数来实现的。在ANSI C中,这些函数被定义在头文件<stdio.h>;中。
标准输入/输出
有三个标准输入/输出是标准I/O库预先定义的:
stdin标准输入
stdout标准输出
stderr输入输出错误
运算
C语言的运算非常灵活,功能十分丰富,运算种类远多于其它程序设计语言。在表达式方面较其它程序语言更为简洁,如自加、自减、逗号运算和三目运算使表达式更为简单,但初学者往往会觉的这种表达式难读,关键原因就是对运算符和运算顺序理解不透不全。当多种不同运算组成一个运算表达式,即一个运算式中出现多种运算符时,运算的优先顺序和结合规则显得十分重要。在学习中,对此合理进行分类,找出它们与数学中所学到运算之间的不同点之后,记住这些运算也就不困难了,有些运算符在理解后更会牢记心中,将来用起来得心应手,而有些可暂时放弃不记,等用到时再记不迟。
先要明确运算符按优先级不同分类,《C程序设计》运算符可分为15种优先级,从高到低,优先级为1 ~ 15,除第2.13级和第14级为从右至左结合外,其它都是从左至右结合,它决定同级运算符的运算顺序。
关键字
关键字又称为保留字,就是已被C语言本身使用,不能作其它用途使用的字。例如关键字不能用作变量名、函数名等标识符
由ISO标准定义的C语言关键字共32个:
auto double int struct break else long switch
case enum register typedef char extern return union
const float short unsigned continue for signed void
default goto sizeof volatile do if while static inline
restrict _Bool _Complex _Imaginary _Generic
基本数据类型
void:声明函数无返回值或无参数,声明无类型指针,显示丢弃运算结果。(C89标准新增)
char:字符型类型数据,属于整型数据的一种。(K&R时期引入)
int:整型数据,表示范围通常为编译器指定的内存字节长。(K&R时期引入)
float:单精度浮点型数据,属于浮点数据的一种。(K&R时期引入)
double:双精度浮点型数据,属于浮点数据的一种。(K&R时期引入)
_Bool:布尔型(C99标准新增)
_Complex:复数的基本类型(C99标准新增)
_Imaginary:虚数,与复数基本类型相似,没有实部的纯虚数(C99标准新增)
_Generic:提供重载的接口入口(C11标准新增)
类型修饰关键字
short:修饰int,短整型数据,可省略被修饰的int。(K&R时期引入)
long:修饰int,长整型数据,可省略被修饰的int。(K&R时期引入)
long long:修饰int,超长整型数据,可省略被修饰的int。(C99标准新增)
signed:修饰整型数据,有符号数据类型。(C89标准新增)
unsigned:修饰整型数据,无符号数据类型。(K&R时期引入)
restrict:用于限定和约束指针,并表明指针是访问一个数据对象的唯一且初始的方式。(C99标准新增)
复杂类型关键字
struct:结构体声明。(K&R时期引入)
union:联合体声明。(K&R时期引入)
enum:枚举声明。(C89标准新增)
typedef:声明类型别名。(K&R时期引入)
sizeof:得到特定类型或特定类型变量的大小。(K&R时期引入)
inline:内联函数用于取代宏定义,会在任何调用它的地方展开。(C99标准新增)
存储级别关键字
auto:指定为自动变量,由编译器自动分配及释放。通常在栈上分配。与static相反。当变量未指定时默认为auto。(K&R时期引入)
static:指定为静态变量,分配在静态变量区,修饰函数时,指定函数作用域为文件内部。(K&R时期引入)
register:指定为寄存器变量,建议编译器将变量存储到寄存器中使用,也可以修饰函数形参,建议编译器通过寄存器而不是堆栈传递参数。(K&R时期引入)
extern:指定对应变量为外部变量,即标示变量或者函数的定义在别的文件中,提示编译器遇到此变量和函数时在其他模块中寻找其定义。(K&R时期引入)
const:指定变量不可被当前线程改变(但有可能被系统或其他线程改变)。(C89标准新增)
volatile:指定变量的值有可能会被系统或其他线程改变,强制编译器每次从内存中取得该变量的值,阻止编译器把该变量优化成寄存器变量。(C89标准新增)
流程控制关键字
跳转结构
return:用在函数体中,返回特定值(如果是void类型,则不返回函数值)。(K&R时期引入)
continue:结束当前循环,开始下一轮循环。(K&R时期引入)
break:跳出当前循环或switch结构。(K&R时期引入)
goto:无条件跳转语句。(K&R时期引入)
分支结构
if:条件语句,后面不需要放分号。(K&R时期引入)
else:条件语句否定分支(与if连用)。(K&R时期引入)
switch:开关语句(多重分支语句)。(K&R时期引入)
case:开关语句中的分支标记,与switch连用。(K&R时期引入)
default:开关语句中的“其他”分支,可选。(K&R时期引入)
编译
#define 预编译宏
#if 表达式 #else if 表达式 #else #endif 条件编译
#ifdef 宏 #else #endif 条件编译
#ifndef 宏 #else #endif 条件编译与条件编译
语法结构
顺序结构
顺序结构的程序设计是最简单的,只要按照解决问题的顺序写出相应的语句就行,它的执行顺序是自上而下,依次执行。
例如:a = 3,b = 5,现交换a,b的值,这个问题就好像交换两个杯子水,这当然要用到第三个杯子,假如第三个杯子是c,那么正确的程序为:c = a; a = b; b = c;执行结果是a = 5,b = c = 3如果改变其顺序,写成:a = b; c = a; b =c;则执行结果就变成a = b = c = 5,不能达到预期的目的,初学者最容易犯这种错误。顺序结构可以独立使用构成一个简单的完整程序,常见的输入、计算,输出三步曲的程序就是顺序结构,例如计算圆的面积,其程序的语句顺序就是输入圆的半径r,计算s = 3.14159*r*r,输出圆的面积s。不过大多数情况下顺序结构都是作为程序的一部分,与其它结构一起构成一个复杂的程序,例如分支结构中的复合语句、循环结构中的循环体等。
选择结构
顺序结构的程序虽然能解决计算、输出等问题,但不能做判断再选择。对于要先做判断再选择的问题就要使用选择结构。选择结构的执行是依据一定的条件选择执行路径,而不是严格按照语句出现的物理顺序。选择结构的程序设计方法的关键在于构造合适的分支条件和分析程序流程,根据不同的程序流程选择适当的选择语句。选择结构适合于带有逻辑或关系比较等条件判断的计算,设计这类程序时往往都要先绘制其程序流程图,然后根据程序流程写出源程序,这样做把程序设计分析与语言分开,使得问题简单化,易于理解。程序流程图是根据解题分析所绘制的程序执行流程图。
循环结构
循环结构可以减少源程序重复书写的工作量,用来描述重复执行某段算法的问题,这是程序设计中最能发挥计算机特长的程序结构,C语言中提供四种循环,即goto循环、while循环、do while循环和for循环。四种循环可以用来处理同一问题,一般情况下它们可以互相代替换,但一般不提倡用goto循环,因为强制改变程序的顺序经常会给程序的运行带来不可预料的错误。
特别要注意在循环体内应包含趋于结束的语句(即循环变量值的改变),否则就可能成了一个死循环,这是初学者的一个常见错误。
三个循环的异同点:用while和do…while循环时,循环变量的初始化的操作应在循环体之前,而for循环一般在语句1中进行的;while循环和for循环都是先判断表达式,后执行循环体,而do…while循环是先执行循环体后判断表达式,也就是说do…while的循环体最少被执行一次,而while循环和for就可能一次都不执行。另外还要注意的是这三种循环都可以用break语句跳出循环,用continue语句结束本次循环,而goto语句与if构成的循环,是不能用break和 continue语句进行控制的。
顺序结构、分支结构和循环结构并不彼此孤立的,在循环中可以有分支、顺序结构,分支中也可以有循环、顺序结构,其实不管哪种结构,均可广义的把它们看成一个语句。在实际编程过程中常将这三种结构相互结合以实现各种算法,设计出相应程序,但是要编程的问题较大,编写出的程序就往往很长、结构重复多,造成可读性差,难以理解,解决这个问题的方法是将C程序设计成模块化结构。
具体内容:
for循环
for循环结构是c语言中最具有特色的循环语句,使用最为灵活方便,它的一般形式为:
for(表达式1;表达式2;表达式3)循环体语句 。(其中;不能省略)
表达式
表达式1为初值表达式,用于在循环开始前为循环变量赋初值。
表达式2是循环控制逻辑表达式,它控制循环执行的条件,决定循环的次数。
表达式3为循环控制变量修改表达式,它使for循环趋向结束。
循环体语句是在循环控制条件成立的情况下被反复执行的语句。
但是在整个for循环过程中,表达式1只计算一次,表达式2和表达式3则可能计算多次,也可能一次也不计算。循环体可能多次执行,也可能一次都不执行。
先执行表达式2,然后执行循环结构,最后表达式3,一直这样循环下去。
for循环语句是c语言种功能最为强大的语句,甚至在一定程度上可以代替其他的循环语句。
do
do循环结构,do 1 while⑵;的执行顺序是1->2->1...循环,2为循环条件。
while
while循环结构,while(1) 2; 的执行顺序是1->2->1...循环,1为循环条件
以上循环语句,当循环条件表达式为真则继续循环,为假则跳出循环。
程序结构
C语言的模块化程序结构用函数来实现,即将复杂的C程序分为若干模块,每个模块都编写成一个C函数,然后通过主函数调用函数及函数调用函数来实现一大型问题的C程序编写,因此常说:C程序=主函数+子函数。因此,对函数的定义、调用、值的返回等中要尤其注重理解和应用,并通过上机调试加以巩固。
判断语句(选择结构):
if 语句:“如果”语句;if—else 语句:“若…(则)…否则…”语句;switch 语句:“切换”语句;switch—case:“切换—情况”语句。
循环语句(循环结构):
while 语句:“当…”语句;do—while 语句:“做…当…(时候)”语句;for 语句:条件语句(即“(做)…为了…”语句)。
跳转语句(循环结构:是否循环):
goto 语句:“转舵”语句,也称“跳转”语句;break 语句:“中断”(循环)语句,即结束整个循环;continue 语句:“继续”语句(结束本次循环,继续下一次循环);return 语句:“返回”语句。
需要说明的是:
1、一个C语言源程序可以由一个或多个源文件组成。
2、每个源文件可由一个或多个函数组成。
3、一个源程序不论由多少个文件组成,都有一个且只能有一个main函数,即主函数。是整个程序的入口。
4、源程序中可以有预处理命令(包括include 命令,ifdef、ifndef命令、define命令),预处理命令通常应放在源文件或源程序的最前面。
5、每一个说明,每一个语句都必须以分号结尾。但预处理命令,函数头和花括号“}”之后不能加分号。(结构体、联合体、枚举型的声明的“}”后要加“ ;”。)
6、标识符,关键字之间必须至少加一个空格以示间隔。若已有明显的间隔符,也可不再加空格来间隔。
书写规则
1、一个说明或一个语句占一行。
2、用{} 括起来的部分,通常表示了程序的某一层次结构。{}一般与该结构语句的第一个字母对齐,并单独占一行。
3、低一层次的语句或说明可比高一层次的语句或说明缩进若干格后书写。以便看起来更加清晰,增加程序的可读性。在编程时应力求遵循这些规则,以养成良好的编程风格。
函数
C程序是由一组变量或是函数的外部对象组成的。 函数是一个自我包含的完成一定相关功能的执行代码段。我们可以把函数看成一个“黑盒子”,你只要将数据送进去就能得到结果,而函数内部究竟是如何工作的的,外部程序是不知道的。外部程序所知道的仅限于输入给函数什么以及函数输出什么。函数提供了编制程序的手段,使之容易读、写、理解、排除错误、修改和维护。
C程序中函数的数目实际上是不限的,如果说有什么限制的话,那就是,一个C程序中必须至少有一个函数,而且其中必须有一个并且仅有一个以main为名,这个函数称为主函数,整个程序从这个主函数开始执行。
C 语言程序鼓励和提倡人们把一个大问题划分成一个个子问题,对应于解决一个子问题编制一个函数,因此,C 语言程序一般是由大量的小函数而不是由少量大函数构成的,即所谓“小函数构成大程序”。这样的好处是让各部分相互充分独立,并且任务单一。因而这些充分独立的小模块也可以作为一种固定规格的小“构件”, 用来构成新的大程序。
C语言发展的那么多年来,用C语言开发的系统和程序浩如烟海。在发展的同时也积累了很多能直接使用的库函数。
ANSI C提供了标准C语言库函数。
C语言初学者比较喜欢的Turbo C 2.0提供了400多个运行时函数,每个函数都完成特定的功能,用户可随意调用。这些函数总体分成输入输出函数、数学函数、字符串和内存函数、与BIOS和DOS有关的函数、 字符屏幕和图形功能函数、过程控制函数、目录函数等。
Windows系统所提供的Windows SDK中包含了数千个跟Windows应用程序开发相关的函数。
其他操作系统,如Linux,也同样提供了大量的函数让应用程序开发人员调用。
作为程序员应尽量熟悉目标平台库函数其功能。这样才能游刃有余地开发特定平台的应用程序。比如作为Windows应用程序的开发者,应尽量熟悉Windows SDK;作为Linux应用程序开发者,应尽量熟悉Linux系统调用和POSIX函数规范。
运算符号
比较特别的是,比特右移(>>)运算符可以是算术(左端补最高有效位)或是逻辑(左端补 0)位移。例如,将 11100011 右移 3 比特,算术右移后成为 11111100,逻辑右移则为 00011100。因算术比特右移较适于处理带负号整数,所以几乎所有的编译器都是算术比特右移。
运算符的优先级从高到低大致是:单目运算符、算术运算符、关系运算符、逻辑运算符、条件运算符、赋值运算符(=)和逗号运算符。
()、 、 -> 、 .、!、 ++、 -- 圆括号、方括号、指针、成员、逻辑非、自加、自减
++ 、 -- 、 * 、 & 、 ~ 、! 单目运算符
+、 - 、 sizeof、(cast)
* 、 / 、% 算术运算符
+ 、 - 算术运算符
<< 、 >> 位运算符
< 、 <= 、 > 、 >= 关系运算符
== 、!= 关系运算符号
& 位与
^ 位异或
| 位或
&& 逻辑与
|| 逻辑或
? 、: 条件运算符
/= 、%= 、 &= 、 |= 、 ^= 赋值运算符
= 、 += 、 -= 、 *= 、
, 顺序运算符
经典错误
void main()的用法并不是任何标准制定的。 C语言标准语法是int main,任何实现都必须支持int main(void) { /* ... */ }和int main(int argc, char* argv) { /* ... */ }。
类似于a+=a++;或者(i++)+(i++)+(i++)属于未定义行为,并不是说c语言中还未定义这种行为,它早有定论,它的结果取决于编译器实现,不要写这样的代码!
参考资料
1. Stephen Prata.C Primer Plus.美国:人民邮电出版社,2005:1-3
2. 苏小红,孙志岗,陈惠鹏.C语言大学实用教程.北京市:电子工业出版社,2013年:8-8
3. C语言的发展过程 .C语言中文网.2012-04-28
4. American National Standards Institute(ANSI——美国国家标准学会) .标准信息网
5. ISO/IEC 9899:1990 - Programming languages -- C .国际标准化组织(ISO - International Organization for Standardization)
6. ISO/IEC 9899:1990/Cor 1:1994 .国际标准化组织(ISO - International Organization for Standardization)
7. ISO/IEC 9899:1990/Amd 1:1995 - C Integrity .国际标准化组织(ISO - International Organization for Standardization)
8. ISO/IEC 9899:1999 - Programming languages -- C .国际标准化组织(ISO - International Organization for Standardization)
9. ISO/IEC 9899:2011 - Information technology -- Programming languages -- C .国际标准化组织(ISO - International Organization for Standardization)
10. C语言程序设计教程相关介绍 .星火教程网.2012-03-22
Last edited by zzz19760225 on 2018-7-31 at 21:29 ]
http://www.shucunwang.com/RunCode/c/
http://codepad.org/TIbKemXJ
http://www.manonggu.com/biancheng/
C Language Resource Collection in Chinese Version
https://github.com/jobbole/awesome-c-cn
【Raw】Compare C Language and Machine Language (English, for reference)
https://www.bilibili.com/video/av11237858
Yingsi Teaching Network (C language content mainly based on Turbo C)
http://www.winyes.com/
Bilibili C Language
https://www.bilibili.com/video/av9430200/?from=search&seid=8131884833781373784
Sogou Turbo C Chinese Version Download (Use the localized version in the run wizard, run the program in virtual machine mode)
http://xiazai.sogou.com/detail/34/16/902784868571182432.html?uID=440DBA3D4F0A900A00000000598FB273
C Language
Locked
Synonym C (computer language) generally refers to C language
This entry is reviewed by the "Science Popularization China" Encyclopedia Science Entry Writing and Application Project.
C language is a general-purpose computer programming language with wide applications. The design goal of C language is to provide a programming language that can be compiled easily, handle low-level memory, generate a small amount of machine code, and can run without any runtime environment support.
Although C language provides many low-level processing functions, it still maintains good cross-platform characteristics. A C language program written according to a standard specification can be compiled on many computer platforms, even including some embedded processors (microcontrollers or MCUs) and supercomputer operating platforms.
In the 1980s, in order to avoid differences in the C language syntax used by various developers, the American National Standards Institute formulated a complete international standard syntax for C language, called ANSI C, as the initial standard of C language.
Chinese Name
C Language
English Name
The C Programming Language
Category
Computer Programming Language
Founder
Dennis MacAlistair Ritchie
Founding Time
1972
Originated From
BCPL Language
Main Compilers
Clang, GCC, MSVC, Turbo C, etc.
Inspired Languages
B Language, Assembly, ALGOL68
Operating System
Multi-platform
Table of Contents
1. Development History
2. Programming and Development
▪ Compiler
▪ Integrated Development Environment (IDE)
▪ Hello World
3. Language Standards
▪ K&R C
▪ ANSI C / C89 Standard
▪ C99 Standard
▪ C11 Standard
4. Language Features
▪ Basic Characteristics
▪ Unique Features
▪ Advantages and Disadvantages
▪ New Features of C11
5. Language Components
▪ Basic Composition
▪ Keywords
▪ Syntax Structure
▪ Program Structure
▪ Function
▪ Operators
6. Classic Errors
Development History
The reason why C language is named C is that C language originated from the B language invented by Ken Thompson, and the B language originated from the BCPL language.
In 1967, Martin Richards from Cambridge University simplified the CPL language, thus producing the BCPL (Basic Combined Programming Language) language.
C Language Promotion Image C Language Promotion Image
In the 1960s, Ken Thompson, a researcher from Bell Laboratories of AT&T (AT&T Bell Laboratory) in the United States, was idle and itchy, wanting to play an electronic game he made himself, Space Travel. He found an idle machine, PDP-7, behind his boss. But this machine had no operating system, and the game had to use some functions of the operating system, so he started to develop an operating system for PDP-7. Later, this operating system was named - UNIX.
In 1970, Ken Thompson from Bell Laboratories in the United States, based on the BCPL language, designed a very simple and hardware-closer B language (taking the first letter of BCPL). And he wrote the first UNIX operating system in B language.
In 1971, Dennis M. Ritchie, who also loved Space Travel, joined Thompson's development project to cooperate in the development of UNIX in order to play the game earlier. His main job was to transform the B language to make it more mature.
In 1972, D.M. Ritchie from Bell Laboratories in the United States finally designed a new language based on the B language. He took the second letter of BCPL as the name of this language, which is the C language.
At the beginning of 1973, the main body of the C language was completed. Thompson and Ritchie couldn't wait to rewrite UNIX completely with it. At this time, the fun of programming made them completely forget that "Space Travel" and devoted themselves wholeheartedly to the development of UNIX and C language. With the development of UNIX, the C language itself is also constantly improving. Until today, various versions of UNIX kernels and surrounding tools still use C language as the most important development language, and many of them still inherit the code from Thompson and Ritchie.
During the development, they also considered porting UNIX to other types of computers. The strong portability (Portability) of the C language is manifested here. Both machine language and assembly language are not portable. A program developed for x86 cannot run on machines such as Alpha, SPARC, and ARM. The C language program can be used on processors of any architecture, as long as the processor of that architecture has a corresponding C language compiler and library, and then the C source code is compiled and linked into a target binary file to run.
In 1977, Dennis M. Ritchie published the C language compilation text "Portable C Language Compiler" that is not dependent on a specific machine system.
The C language continued to develop. In 1982, many knowledgeable people and the American National Standards Institute decided to establish a C standard committee to establish the standard of the C language in order to make this language develop healthily. The committee is composed of hardware manufacturers, compiler and other software tool manufacturers, software designers, consultants, academic people, C language authors, and application programmers. In 1989, ANSI released the first complete C language standard - ANSI X3.159-1989, referred to as "C89", but people are also used to calling it "ANSI C". C89 was adopted unchanged by the International Organization for Standardization (ISO) in 1990. The official name given by ISO is: ISO/IEC 9899, so ISO/IEC9899: 1990 is also usually referred to as "C90" for short. In 1999, after making some necessary corrections and improvements, ISO released a new C language standard, named ISO/IEC 9899: 1999, referred to as "C99". On December 8, 2011, ISO officially released a new standard, called ISO/IEC9899: 2011, referred to as "C11".
Programming and Development
Compiler
GCC, an open-source and free compiler developed by the GNU organization
MinGW, GCC under the Windows operating system
Clang, an open-source BSD-licensed compiler based on LLVM
Visual C++ :: cl.exe, the compiler built into Microsoft VC++
Integrated Development Environment (IDE)
CodeBlocks, an open-source and free C/C++ IDE
CodeLite, an open-source, cross-platform C/C++ integrated development environment
Orwell Dev-C++, a portable C/C++ IDE
C-Free
Light Table
Visual Stdio series
Hello World
The following is a simple program that prints the string "Hello, world!" on the standard output device (stdout). A similar program is usually the first program when learning a programming language:
1
2
3
4
5
6
7
#include <stdio.h>
int main(void)
{
printf("Hello, world!");
return 0;
}
Language Standards
K&R C
At first, there was no official standard for the C language. In 1978, it was officially published by Bell Laboratories of AT&T (AT&T). Brian Kernighan and Dennis Ritchie published a book called "The C Programming Language". This book is called K&R by C language developers and has been regarded as an informal standard description of the C language for many years. People call this version of the C language K&R C.
K&R C mainly introduces the following features:
Struct (struct) type
Long integer (long int) type
Unsigned integer (unsigned int) type
Change the operators =+ and =- to += and -=. Because =+ and =- will make the compiler not know whether the user wants to handle i = -10 or i =- 10, causing confusion in processing.
Even many years after the ANSI C standard was proposed, K&R C is still the most accurate requirement of many compilers, and many old compilers still run the K&R C standard.
ANSI C / C89 Standard
From the 1970s to the 1980s, the C language was widely used, from large mainframes to small microcomputers, and many different versions of the C language also derived.
In 1983, the American National Standards Institute (ANSI) established a committee X3J11 to formulate the C language standard.
In 1989, the American National Standards Institute (ANSI) passed the C language standard, which is called ANSI X3.159-1989 "Programming Language C". Because this standard was passed in 1989, it is generally referred to as the C89 standard. Some people also refer to it as ANSI C because this standard was released by the American National Standards Institute (ANSI).
In 1990, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) set the C89 standard as the international standard of the C language, named ISO/IEC 9899:1990 - Programming languages -- C . Because this standard was released in 1990, some people simply call it the C90 standard. However, most people still call it the C89 standard because this standard is completely equivalent to the ANSI C89 standard.
In 1994, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) released a revised version of the C89 standard, named ISO/IEC 9899:1990/Cor 1:1994 , some people simply call it the C94 standard.
In 1995, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) released another revised version of the C89 standard, named ISO/IEC 9899:1990/Amd 1:1995 - C Integrity , some people simply call it the C95 standard.
C99 Standard
In January 1999, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) released a new standard for the C language, named ISO/IEC 9899:1999 - Programming languages -- C , referred to as the C99 standard. This is the second official standard of the C language.
The features included in C99 are:
Increased restrictions on the compiler, such as each line of the source program requiring at least 4095 bytes of support, and variable names and function names requiring 63 bytes of support (extern requires 31 bytes of support).
Enhanced preprocessing functions. For example:
Macro supports taking variable arguments #define Macro(...) __VA_ARGS__
When using a macro, it is allowed to omit parameters, and the omitted parameters will be expanded into empty strings.
Supports single-line comments starting with // (this feature has actually been supported by many compilers of C89).
Added new keywords restrict, inline, _Complex, _Imaginary, _Bool
Supports types such as long long, long double _Complex, float _Complex, etc.
Supports variable-length arrays, that is, the array length can be determined at runtime, such as using variables as array lengths. Declare in the form of int a. However, considering efficiency and implementation, variable-length arrays cannot be used globally, or in structs and unions.
Variable declarations do not have to be placed at the beginning of the statement block. The for statement is recommended to be written as for(int i=0;i<100;++i), that is, i is only valid within the for statement block.
Allows the use of (type_name){xx,xx,xx} similar to the constructor form of C++ to construct anonymous structs.
Compound literals: When initializing a structure, it is allowed to assign values to specific elements, in the form:
struct test{int a,b;} foo = { .a = {1}, .a = 2 };
struct test{int a, b, c, d;} foo = { .a = 1, .c = 3, 4, .b = 5 }; // 3,4 are assignments to .c,.d
In the format string, \u is used to support unicode characters.
Supports the description of hexadecimal floating-point numbers.
The format strings of printf scanf have added support for the long long int type.
The internal data description of floating-point numbers supports the new standard, and the #pragma compiler directive can be used to specify it.
In addition to the existing __line__ __file__, __func__ is added to get the current function name.
Allows the compiler to simplify non-constant expressions.
Modified the definition of /% processing negative numbers, so that a clear result can be given. For example, in C89, -22 / 7 = -3, -22% 7 = -1, and also -22 / 7= -4, -22% 7 = 6. In C99, it is clearly -22 / 7 = -3, -22% 7 = -1, only one result.
Cancelled the regulation that the function return type is int by default.
Allows the last array in the struct definition to not specify its length, written as (flexible array member).
const const int i will be treated as const int i.
Added and modified some standard header files, such as <stdbool.h> defining bool, <inttypes.h> defining int of some standard lengths, <complex.h> defining complex numbers, <wctype.h> defining wide characters, <tgmath.h> similar to generic mathematical functions, <fenv.h> related to floating-point numbers. va_copy is added in <stdarg.h> for copying ... parameters. struct tmx is added, and struct tm is extended.
Input and output support corresponding to wide characters and long integers, etc.
Most features of C99 are supported by GCC and other commercial compilers.
C11 Standard
On December 8, 2011, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) released a new standard for the C language again, named ISO/IEC 9899:2011 - Information technology -- Programming languages -- C , referred to as the C11 standard, formerly known as C1X. This is the third official standard of the C language and also the latest standard of the C language.
The new standard improves compatibility with C++ and adds some new features. These new features include:
Standardization of alignment processing (including _Alignas identifier, alignof operator, aligned_alloc function, and <stdalign.h> header file.
_Noreturn function mark, similar to gcc's __attribute__((noreturn)).
_Generic keyword.
Multithreading support, including:
_Thread_local storage type identifier, <threads.h> header file, which contains functions for thread creation and management.
_Atomic type modifier and <stdatomic.h> header file.
Enhanced Unicode support. Based on the C Unicode technical report ISO/IEC TR 19769:2004, enhanced support for Unicode. Including adding char16_t and char32_t data types for UTF-16/UTF-32 encoding, and providing the <uchar.h> header file containing Unicode string conversion functions.
The gets() function is deleted, and a new safer function gets_s() is used instead.
Added boundary check function interfaces and defined new safe functions, such as fopen_s(), strcat_s(), etc.
Added more floating-point processing macros.
Anonymous struct/union support. This has long existed in gcc, and C11 introduces it into the standard.
Static assertions (static assertions), _Static_assert(), which are processed after interpreting #if and #error.
New fopen() mode, ("…x"). Similar to O_CREAT|O_EXCL in POSIX, it is commonly used in file locks.
Added quick_exit() function as a third way to terminate the program. When exit() fails, the least cleaning work can be done.
Language Features
Basic Characteristics
C++ Language Code C++ Language Code
1. High-level language: It is a working unit that combines the basic structures and statements of high-level languages with the practicality of low-level languages.
2. Structured language: The prominent feature of structured language is the separation of code and data, that is, each part of the program is independent except for necessary information exchange. This structured method can make the program hierarchical, easy to use, maintain, and debug. The C language is provided to users in the form of functions, which can be easily called, and has various loops and conditional statements to control the program flow, so that the program is completely structured.
4. Code-level cross-platform: Due to the existence of the standard, almost the same C code can be used for multiple operating systems, such as Windows, DOS, UNIX, etc.; it is also suitable for multiple machine types. The C language is superior to other high-level languages for occasions that need to perform hardware operations.
5. Using pointers: You can directly perform operations close to the hardware, but the pointer operation of C is not protected, which also brings many unsafe factors. C++ has made improvements in this regard. While retaining pointer operations, it has enhanced security, which is supported by some users. However, because these improvements increase the complexity of the language, it is also criticized by another part. Java has learned from the lessons of C++, canceled pointer operations, and also canceled some controversial places in C++ improvements, achieving good results in security and suitability, but its own interpretation runs in the virtual machine, and the running efficiency is lower than C++/C. Generally speaking, C, C++, and java are regarded as languages of the same series, and they have long occupied the top three in the program usage list.
Unique Features
The C language is a procedural language with structured program design, variable scope (variable scope), and recursion function.
The C language passes parameters by value (pass by value), and also can pass pointers (a pointer passed by value).
Different variable types can be combined with structs.
There are only 32 reserved words (reserved keywords), which makes variable and function naming more flexible.
Some variable types can be converted, such as integer and character type variables.
Through pointers, the C language can easily perform low-level control of memory.
The preprocessor makes the compilation of the C language more flexible.
Advantages and Disadvantages
Advantages
1. Concise, compact, flexible and convenient
The C language has only 32 keywords and 9 control statements. The program writing form is free and case-sensitive. Combine the basic structures and statements of high-level languages with the practicality of low-level languages. The C language can operate on bits, bytes, and addresses like assembly language, and these three are the most basic working units of the computer.
C Language's Hello World Program C Language's Hello World Program
2. Rich operators
The operators of the C language cover a wide range, with a total of 34 operators. The C language treats parentheses, assignment, forced type conversion, etc. as operators. Thereby making the operation types of the C language extremely rich and the expression types diversified. Flexibly using various operators can realize operations that are difficult to implement in other high-level languages.
3. Rich data types
The data types of the C language include: integer type, real type, character type, array type, pointer type, structure type, union type, etc. It can be used to implement operations of various complex data structures. And the pointer concept is introduced, which makes the program more efficient.
4. Flexible and practical expression methods
The C language provides a variety of operators and methods for the value of expressions. The expression of the problem can be obtained through various ways, and its program design is more active and flexible. Its syntax restrictions are not too strict, and the program design freedom is large. For example, integer types, character types, and logical types can be used universally.
5. Allowing direct access to physical addresses and operating hardware
Because the C language allows direct access to physical addresses and can directly operate on hardware, it has both the functions of high-level languages and many functions of low-level languages. It can operate on bits (bit), bytes, and addresses like assembly language, and these three are the most basic working units of the computer, which can be used to write system software.
6. High quality of generated object code and high efficiency of program execution
The C language describes the problem more quickly than assembly language, with less workload and better readability, easy to debug, modify and port, and the code quality is equivalent to that of assembly language. The C language is generally only 10% to 20% less efficient than the object code generated by the assembly program.
7. Good portability
The C language compilation programs on different machines have 86% of the code in common, so the C language compilation program is easy to port. A program written in C language in one environment can be ported to run in a completely different environment with little or no modification.
8. Strong expressive power
The C language has rich data structures and operators. It contains various data structures, such as integer types, array types, pointer types, and union types, to implement operations of various data structures. The C language has 34 operators, with a wide range. Flexibly using various operators can implement extremely difficult operations.
The C language can directly access the physical address of hardware and can perform bit (bit) operations. It has many advantages of both high-level languages and low-level languages.
It can be used to write both system software and application software, and has become a general-purpose programming language.
In addition, the C language has powerful graphics functions and supports multiple displays and drivers. And it has powerful calculation functions and logical judgment functions.
Disadvantages
1. The main disadvantage of the C language is reflected in the encapsulation of data. This makes the C language have great defects in data security, which is also a big difference between C and C++.
2. The syntax restrictions of the C language are not very strict, and the type constraints on variables are not strict, which affects the security of the program, and does not check for array subscript out of bounds, etc. From an application perspective, the C language is more difficult to master than other high-level languages. That is to say, for people using the C language, more proficient programming is required.
New Features of C11
1. Standardization of alignment processing (including _Alignas identifier, alignof operator, aligned_alloc function, and <stdalign.h> header file).
2. _Noreturn function mark, similar to gcc's __attribute__(noreturn).
3. _Generic keyword.
4. Multithreading support, including: _Thread_local storage type identifier, <threads.h>; header file, which contains functions for thread creation and management.
5. Enhanced Unicode support, based on the C Unicode technical report ISO/IEC TR 19769:2004, enhanced support for Unicode. Including adding char16_t and char32_t data types for UTF-16/UTF-32 encoding, and providing the <uchar.h> header file containing Unicode string conversion functions.
6. The gets() function is deleted, and a new safer function gets_s() is used instead.
7. Added boundary check function interfaces and defined new safe functions, such as fopen_s(), strcat_s(), etc.
8. Added more floating-point processing macros.
9. Anonymous struct/union support, which has long existed in gcc, and C11 introduces it into the standard.
10. Static assertions (Static assertions), _Static_assert(), which are processed after interpreting #if and #error.
11. New fopen() mode, ("…x"), similar to O_CREAT|O_EXCL in POSIX, which is commonly used in file locks.
12. Added quick_exit() function as a third way to terminate the program. When exit() fails, the least cleaning work can be done.
13. _Atomic type modifier and <stdatomic.h> header file.
Language Components
Basic Composition
Data Types
The data types of C include: integer type, character type, real type or floating type (single-precision and double-precision), enumeration type, array type, structure type, union type, pointer type, and void type.
Constants and Variables
The value of a constant cannot be changed, and the symbolic constant name is usually in uppercase.
A variable is a quantity whose name is an identifier and whose value can be changed. The identifier is a sequence composed of letters or underscores followed by a string of letters, numbers, or underscores. Please note that the first character must be a letter or underscore, otherwise it is an illegal variable name. Variables are allocated corresponding storage units at compile time.
Array
If a variable name is followed by a bracket with a number, this declaration is an array declaration. A string is also an array. They end with the ASCII NULL. It should be particularly noted that the index value in the square brackets starts from 0.
Pointer
If a * is used in front of a variable declaration, it indicates that this is a pointer variable. In other words, the variable stores an address, and * (specifically referring to the unary operator * here, the same below. There is also a binary operator * in the C language) is the content fetch operator, which means fetching the content stored in this memory address. Pointers are one of the main features of the C language that distinguish it from other contemporary high-level languages.
Pointers can not only be the address of a variable, but also the address of an array, array elements, and functions. Through pointers as formal parameters, more than one return value can be obtained during the function call process, which is different from return (z) which can only get one return value.
Pointers are a double-edged sword. Many operations can be naturally expressed through pointers, but incorrect or excessive use of pointers will bring a large number of potential errors to the program.
String
The string of the C language is actually a char array ending with the '\0' character. Using a character type does not require referencing a library, but using a string requires some functions in the C standard library to operate on the string. They are different from character arrays. Using these functions requires referencing the header file <string.h>.
File Input/Output
In the C language, input and output are implemented through a set of functions in the standard library. In ANSI C, these functions are defined in the header file <stdio.h>;
Standard Input/Output
There are three standard input/outputs that are pre-defined by the standard I/O library:
stdin standard input
stdout standard output
stderr input and output error
Operation
The operation of the C language is very flexible and has very rich functions. The number of operation types is far more than that of other programming languages. In terms of expressions, it is more concise than other programming languages. For example, self-increment, self-decrement, comma operation, and ternary operation make the expression simpler, but beginners often find this expression difficult to read. The key reason is that they do not fully understand the operator and the operation order. When a variety of different operations form an operation expression, that is, when multiple operators appear in an operation expression, the priority order and associative rules of the operations are very important. In learning, it is reasonable to classify them, find the differences from the operations learned in mathematics, and then it is not difficult to remember these operations. Some operators will be firmly remembered after understanding, and will be handy in the future, while some can be temporarily forgotten and remembered when used.
First, it is necessary to clarify that the operators are classified according to different priorities. The operators in "C Programming" can be divided into 15 levels of priorities, from high to low, with priorities 1 ~ 15. Except for levels 2.13 and 14, which are combined from right to left, the others are combined from left to right, which determines the operation order of operators at the same level.
Keywords
Keywords are also called reserved words, that is, words that have been used by the C language itself and cannot be used for other purposes. For example, keywords cannot be used as identifiers such as variable names and function names
There are a total of 32 keywords defined by the ISO standard for the C language:
auto double int struct break else long switch
case enum register typedef char extern return union
const float short unsigned continue for signed void
default goto sizeof volatile do if while static inline
restrict _Bool _Complex _Imaginary _Generic
Basic Data Types
void: Declare that the function has no return value or no parameters, declare a pointer of no type, and explicitly discard the operation result. (Added in C89 standard)
char: Character type data, which belongs to a kind of integer data. (Introduced during K&R period)
int: Integer data, indicating the range usually specified by the compiler's memory bytes. (Introduced during K&R period)
float: Single-precision floating-point data, which belongs to a kind of floating-point data. (Introduced during K&R period)
double: Double-precision floating-point data, which belongs to a kind of floating-point data. (Introduced during K&R period)
_Bool: Boolean type (added in C99 standard)
_Complex: Basic type of complex number (added in C99 standard)
_Imaginary: Imaginary number, similar to the basic type of complex number, a pure imaginary number without a real part (added in C99 standard)
_Generic: Provide an interface entry for overloading (added in C11 standard)
Type Modifier Keywords
short: Modify int, short integer data, and the modified int can be omitted. (Introduced during K&R period)
long: Modify int, long integer data, and the modified int can be omitted. (Introduced during K&R period)
long long: Modify int, super long integer data, and the modified int can be omitted. (Added in C99 standard)
signed: Modify integer data, signed data type. (Added in C89 standard)
unsigned: Modify integer data, unsigned data type. (Introduced during K&R period)
restrict: Used to limit and restrict pointers, and indicate that the pointer is the only and initial way to access a data object. (Added in C99 standard)
Complex Type Keywords
struct: Structure declaration. (Introduced during K&R period)
union: Union declaration. (Introduced during K&R period)
enum: Enumeration declaration. (Added in C89 standard)
typedef: Declare type alias. (Introduced during K&R period)
sizeof: Get the size of a specific type or specific type variable. (Introduced during K&R period)
inline: Inline function is used to replace macro definition and will be expanded in any place where it is called. (Added in C99 standard)
Storage Level Keywords
auto: Specify as an automatic variable, which is automatically allocated and released by the compiler. Usually allocated on the stack. Opposite to static. When the variable is not specified, it is automatically auto by default. (Introduced during K&R period)
static: Specify as a static variable, allocated in the static variable area. When modifying a function, specify that the function scope is internal to the file. (Introduced during K&R period)
register: Specify as a register variable, and suggest that the compiler store the variable in the register for use. It can also modify function parameters and suggest that the compiler pass parameters through the register instead of the stack. (Introduced during K&R period)
extern: Specify the corresponding variable as an external variable, that is, indicate that the definition of the variable or function is in another file, and prompt the compiler to find its definition in other modules when encountering this variable and function. (Introduced during K&R period)
const: Specify that the variable cannot be changed by the current thread (but may be changed by the system or other threads). (Added in C89 standard)
volatile: Specify that the value of the variable may be changed by the system or other threads, and force the compiler to always obtain the value of the variable from the memory, preventing the compiler from optimizing the variable into a register variable. (Added in C89 standard)
Flow Control Keywords
Jump Structure
return: Used in the function body to return a specific value (if it is of void type, it does not return a function value). (Introduced during K&R period)
continue: End the current loop and start the next loop. (Introduced during K&R period)
break: Jump out of the current loop or switch structure. (Introduced during K&R period)
goto: Unconditional jump statement. (Introduced during K&R period)
Branch Structure
if: Conditional statement, no semicolon needs to be placed later. (Introduced during K&R period)
else: Conditional statement negative branch (used with if). (Introduced during K&R period)
switch: Switch statement (multiple branch statement). (Introduced during K&R period)
case: Branch mark in the switch statement, used with switch. (Introduced during K&R period)
default: "Other" branch in the switch statement, optional. (Introduced during K&R period)
Compilation
#define precompilation macro
#if expression #else if expression #else #endif conditional compilation
#ifdef macro #else #endif conditional compilation
#ifndef macro #else #endif conditional compilation and conditional compilation
Syntax Structure
Sequential Structure
The sequential structure program design is the simplest. As long as the corresponding statements are written in the order of solving the problem, its execution order is from top to bottom, and it is executed in sequence.
For example: a = 3, b = 5, now exchange the values of a and b. This problem is like exchanging water in two cups. Of course, a third cup is needed. Suppose the third cup is c, then the correct program is: c = a; a = b; b = c; the execution result is a = 5, b = c = 3. If the order is changed, written as: a = b; c = a; b = c; then the execution result becomes a = b = c = 5, which cannot achieve the expected purpose. Beginners are most likely to make this kind of mistake. The sequential structure can be used independently to form a simple complete program. The common three-step program of input, calculation, and output is a sequential structure. For example, calculate the area of a circle. The statement order of its program is to input the radius r of the circle, calculate s = 3.14159*r*r, and output the area s of the circle. However, in most cases, the sequential structure is part of the program, and forms a complex program with other structures. For example, the compound statement in the branch structure, the loop body in the loop structure, etc.
Selection Structure
The sequential structure program can solve problems such as calculation and output, but cannot make judgments and selections. For problems that need to make judgments and selections first, the selection structure should be used. The execution of the selection structure is based on certain conditions to select the execution path, rather than strictly following the physical order of the statements. The program design method of the selection structure is to construct a suitable branch condition and analyze the program flow. Select the appropriate selection statement according to different program flows. The selection structure is suitable for calculations with logical or relational comparison and other condition judgments. When designing such a program, it is often necessary to draw its program flow chart first, and then write the source program according to the program flow, which separates the program design analysis from the language, making the problem simple and easy to understand. The program flow chart is the program execution flow chart drawn according to the problem analysis.
Loop Structure
The loop structure can reduce the workload of repeatedly writing source programs, and is used to describe the problem of repeatedly executing a certain algorithm. This is the program structure that can best exert the characteristics of the computer. The C language provides four loops, namely goto loop, while loop, do while loop, and for loop. The four loops can be used to handle the same problem. Generally, they can be replaced with each other, but generally, the goto loop is not advocated, because forcibly changing the order of the program often brings unpredictable errors to the operation of the program.
Special attention should be paid to including statements that tend to end in the loop body (that is, the change of the loop variable value), otherwise it may become an infinite loop, which is a common mistake of beginners.
The similarities and differences of the three loops: When using the while and do...while loops, the initialization operation of the loop variable should be before the loop body, while the for loop is generally carried out in statement 1; the while loop and the for loop both judge the expression first, and then execute the loop body, while the do...while loop executes the loop body first and then judges the expression, that is to say, the loop body of do...while is executed at least once, while the while loop and for may not be executed even once. In addition, it should also be noted that these three loops can all use the break statement to jump out of the loop, and use the continue statement to end this loop, while the loop composed of the goto statement and if cannot be controlled by the break and continue statements.
The sequential structure, branch structure, and loop structure are not isolated from each other. There can be branches and sequential structures in the loop, and there can be loops and sequential structures in the branch. In fact, no matter which structure, they can be generally regarded as a statement. In the actual programming process, these three structures are often combined with each other to implement various algorithms and design corresponding programs. However, if the problem to be programmed is large, the written program is often very long and has repeated structures, resulting in poor readability and difficult understanding. The method to solve this problem is to design the C program into a modular structure.
Specific content:
for loop
The for loop structure is the most characteristic loop statement in the C language, and it is the most flexible and convenient to use. Its general form is:
for (expression 1; expression 2; expression 3) loop body statement. (Where; cannot be omitted)
Expression
Expression 1 is the initial value expression, used to assign an initial value to the loop variable before the loop starts.
Expression 2 is the loop control logic expression, which controls the condition for loop execution and determines the number of loops.
Expression 3 is the loop control variable modification expression, which makes the for loop tend to end.
The loop body statement is the statement that is repeatedly executed when the loop control condition is established.
However, in the entire for loop process, expression 1 is calculated only once, and expressions 2 and 3 may be calculated multiple times or not at all. The loop body may be executed multiple times or not at all.
First execute expression 2, then execute the loop structure, and finally expression 3, and this cycle continues.
The for loop statement is the most powerful statement in the C language, and can even replace other loop statements to a certain extent.
do
do loop structure, the execution order of do 1 while⑵; is 1->2->1... loop, and 2 is the loop condition.
while
while loop structure, the execution order of while(1) 2; is 1->2->1... loop, and 1 is the loop condition
The above loop statements continue the loop when the loop condition expression is true, and jump out of the loop when it is false.
Program Structure
The modular program structure of the C language is implemented by functions, that is, divide a large problem into several modules, each module is written as a C function, and then the main function calls the function and the function calls the function to implement the C program writing of a large problem. Therefore, it is often said: C program = main function + sub-function. Therefore, special attention should be paid to understanding and application of the definition, call, and value return of functions, and consolidated through debugging on the computer.
Judgment Statement (Selection Structure):
if statement: "If" statement; if-else statement: "If... (then)... else..." statement; switch statement: "Switch" statement; switch-case: "Switch-case" statement.
Loop Statement (Loop Structure):
while statement: "When..." statement; do-while statement: "Do... when... (time)" statement; for statement: conditional statement (that is, "(do)... for... " statement).
Jump Statement (Loop Structure: Whether to Loop):
goto statement: "Steering" statement, also called "jump" statement; break statement: "Interrupt" (loop) statement, that is, end the entire loop; continue statement: "Continue" statement (end this loop, continue the next loop); return statement: "Return" statement.
It needs to be explained that:
1. A C language source program can be composed of one or more source files.
2. Each source file can be composed of one or more functions.
3. A source program, no matter how many files it is composed of, has one and only one main function, that is, the main function. It is the entry of the entire program.
4. There can be preprocessing commands (including include commands, ifdef, ifndef commands, define commands) in the source program, and the preprocessing commands should usually be placed at the front of the source file or source program.
5. Each statement and each statement must end with a semicolon. But preprocessing commands, function headers, and curly braces "}" should not be followed by semicolons. (The "}" after the declaration of struct, union, and enumeration type should be followed by ";".)
6. There must be at least one space between identifiers and keywords to show the interval. If there are obvious interval symbols, no more spaces need to be added to separate.
Writing Rules
1. One statement or one statement occupies one line.
2. The part enclosed in {} usually represents a certain level of structure of the program. {} is generally aligned with the first letter of this structure statement and occupies a line alone.
3. The statements or instructions of the lower level can be written with several more spaces than the statements or instructions of the higher level. In order to look more clear and increase the readability of the program. When programming, you should try to follow these rules to develop a good programming style.
Function
A C program is composed of a set of external objects of variables or functions. A function is a self-contained execution code segment that completes certain related functions. We can regard a function as a "black box". As long as you send data in, you can get the result, and the external program does not know how the function works internally. All the external program knows is what is input to the function and what is output by the function. Functions provide a means of programming, making it easy to read, write, understand, debug, modify, and maintain.
The number of functions in a C program is actually unlimited. If there is any restriction, it is that there must be at least one function in a C program, and there must be one and only one function named main, which is called the main function, and the entire program starts from this main function.
The C language encourages and advocates that people divide a big problem into sub-problems, and compile a function for each sub-problem. Therefore, a C language program is generally composed of a large number of small functions rather than a small number of large functions, that is, "small functions constitute a large program". The advantage of this is that each part is fully independent and has a single task. Therefore, these fully independent small modules can also be used as a fixed specification of small "components" to form a new large program.
Over the years of development of the C language, a huge number of systems and programs developed with the C language have been accumulated. At the same time, a lot of directly usable library functions have also been accumulated.
ANSI C provides standard C language library functions.
Beginners of the C language prefer Turbo C 2.0, which provides more than 400 runtime functions, each of which completes a specific function, and users can call them freely. These functions are generally divided into input and output functions, mathematical functions, string and memory functions, functions related to BIOS and DOS, character screen and graphics functions, process control functions, directory functions, etc.
The Windows SDK provided by the Windows system contains thousands of functions related to Windows application development.
Other operating systems, such as Linux, also provide a large number of functions for application program developers to call.
As a programmer, you should try to be familiar with the functions of the target platform library. In this way, you can develop application programs for a specific platform with ease. For example, as a developer of Windows applications, you should try to be familiar with the Windows SDK; as a developer of Linux applications, you should try to be familiar with the Linux system calls and POSIX function specifications.
Operators
It is particularly special that the bit right shift (>>) operator can be arithmetic (the highest significant bit is filled on the left end) or logical (0 is filled on the left end) shift. For example, shifting 11100011 right by 3 bits, the arithmetic right shift becomes 11111100, and the logical right shift becomes 00011100. Because arithmetic bit right shift is more suitable for handling negative integers, almost all compilers are arithmetic bit right shift.
The priority of operators is roughly from high to low: unary operators, arithmetic operators, relational operators, logical operators, conditional operators, assignment operators (=), and comma operators.
()、 、 -> 、 .、!、 ++、 -- Parentheses, square brackets, pointer, member, logical not, self-increment, self-decrement
++ 、 -- 、 * 、 & 、 ~ 、! Unary operators
+、 - 、 sizeof、(cast)
* 、 / 、% Arithmetic operators
+ 、 - Arithmetic operators
<< 、 >> Bit operators
< 、 <= 、 > 、 >= Relational operators
== 、!= Relational operators
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
&& Logical AND
|| Logical OR
? 、: Conditional operator
/= 、%= 、 &= 、 |= 、 ^= Assignment operator
= 、 += 、 -= 、 *= 、
, Sequence operator
Classic Errors
The usage of void main() is not formulated by any standard. The C language standard syntax is int main. Any implementation must support int main(void) { /* ... */ } and int main(int argc, char* argv) { /* ... */ }.
Operations like a+=a++ or (i++)+(i++)+(i++) belong to undefined behavior. It is not that this behavior has not been defined in the C language, it has long been concluded. Its result depends on the compiler implementation. Do not write such code!
References
1. Stephen Prata.C Primer Plus.United States: People's Post and Telecommunications Press, 2005: 1-3
2. Su Xiaohong, Sun Zhigang, Chen Huipeng.Practical C Language Tutorial.Beijing: Electronic Industry Press, 2013: 8-8
3. Development Process of C Language .C Language Chinese Network.2012-04-28
4. American National Standards Institute (ANSI - American National Standards Institute) .Standard Information Network
5. ISO/IEC 9899:1990 - Programming languages -- C .International Organization for Standardization (ISO - International Organization for Standardization)
6. ISO/IEC 9899:1990/Cor 1:1994 .International Organization for Standardization (ISO - International Organization for Standardization)
7. ISO/IEC 9899:1990/Amd 1:1995 - C Integrity .International Organization for Standardization (ISO - International Organization for Standardization)
8. ISO/IEC 9899:1999 - Programming languages -- C .International Organization for Standardization (ISO - International Organization for Standardization)
9. ISO/IEC 9899:2011 - Information technology -- Programming languages -- C .International Organization for Standardization (ISO - International Organization for Standardization)
10. Related Introduction to C Language Programming Tutorial .Spark Tutorial Network.2012-03-22
Last edited by zzz19760225 on 2018-7-31 at 21:29 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-25 20:09 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
1显示帮助文本,txt,chm,
main()
{
paintf("眼下你需要什么?/n")
paintf("需要一本c语言帮助说明书。/n")
paintf("本书内容关于c语言总体综合部分和分部。综合部分包括硬件与c语言以及c语言编辑器内容,分部包括命令文字,命令语法,简单问答类算法,一般完成作业经常需要类算法,综合算法年代可知内容年列表,不包括本年。/n")
paintf("现在开始阅读本书,具体内容如下:。。。。。。/n")
}
C语言和grub是否可以类似,直接在自己电脑上操作帮助文件,集中在几个常用,重要,方便,字数少的命令。
如何在电脑里存储这些帮助书籍信息,在一切命令行和字符模式下显示这些内容?
1如何在命令行下显示,尤其是grub,以及编辑程序。
2将一本书或一篇文章内容转化为c语言信息体的效率做法,命令,还是软件,或者编辑器?
3合适的信息量和需求,分别针对菜鸟,中鸟,老鸟(老鸟部分是针对一些改编阅读帮助,寻找一些新瓶装老酒的经典综合体系的书籍文章群)。
Last edited by zzz19760225 on 2016-8-6 at 17:16 ]
1 Display help text, txt, chm,
main()
{
paintf("What do you need now?/n")
paintf("Need a C language help manual./n")
paintf("The content of this book is about the overall comprehensive part and the divided part of C language. The comprehensive part includes hardware and C language as well as C language editor content. The divided part includes command text, command grammar, simple Q&A - type algorithms, general algorithms often needed for completing homework, a content year list of comprehensive algorithms that can be known, and this year is not included./n")
paintf("Now start reading this book, and the specific content is as follows: ....../n")
}
Can C language and grub be similar, directly operating help files on your own computer, concentrating on several common, important, convenient, and short - word - count commands.
How to store these help book information in the computer and display these contents in all command lines and character modes?
1 How to display in the command line, especially grub, as well as editing programs.
2 The efficient methods, commands, or software, or editors for converting the content of a book or an article into C language information bodies.
3 Appropriate amount of information and requirements, respectively for beginners, intermediate - level users, and veterans (the veteran part is for some adapted reading help, finding some classic comprehensive system book and article groups with new wine in old bottles).
Last edited by zzz19760225 on 2016 - 8 - 6 at 17:16 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:29 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
帮助问答部分
针对帮助信息的搜索问答。
属于一加一等于二的计算。
提问+问题=答案。
初级类书籍的集中,中级类书籍的集中,高级类的书籍集中。
小白和新手学习用的案例,可以不用hello word,而是用坦克对战的简陋模式,代表己方坦克的点或圆,八方运动和步数速度,发射的子弹或炮弹,边界,战斗部分。其次是指挥战斗部分,复制己方内容再添加随机运动。
如果用火柴人的打斗模式也不错。
初级书籍应该加上函数部分,将高中数学的函数对应部分加在其中。
Last edited by zzz19760225 on 2016-9-29 at 21:55 ]
Help and Q&A section
For the search Q&A of help information.
It belongs to the calculation of one plus one equals two.
Question + question = answer.
Concentration of primary books, concentration of intermediate books, concentration of advanced books.
Cases for novices and beginners to learn. Instead of using Hello Word, you can use the simple mode of tank battles, representing the points or circles of your own tank, eight-direction movement and step speed, fired bullets or shells, boundaries, and combat parts. Secondly, the part of commanding the battle, copying your own content and then adding random movement.
It is also good to use the fighting mode of stick figures.
Primary books should add the function part, and add the corresponding part of high school mathematics functions in it.
Last edited by zzz19760225 on 2016-9-29 at 21:55 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:30 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
硬件和c编辑器联系
不同的硬件就如酒瓶,装c语言这个酒,对硬件的检索应该加入到编辑器的功能中,硬件信息的载入作为基础。你熟悉其,就可以把酒装进入,假设语言模式实践检验。
Last edited by zzz19760225 on 2016-7-6 at 03:52 ]
Hardware and C editor connection. Different hardware is like a wine bottle, holding the wine of the C language. The retrieval of hardware should be incorporated into the editor's functions, and the loading of hardware information as a basis. If you are familiar with it, you can pour the wine in. Assume that the language mode is tested and verified.
Last edited by zzz19760225 on 2016-7-6 at 03:52 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:30 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
假设具有针对c语言的行业信息集中协会,中国人的自由模式,同样针对的也是处理汉字数码信息的中层软硬可靠语言。
汉字类汇编,
汉字类全自由结构的语法和所有权语言。
在特定概念范围,针对可能性的自由范围,实践所生成的相对合适的限制语言,被选择为普及内容,这个普及内容就是标准。
在一个个目的与行为之路的互相转换中,很容易失去开始所向的方向。
道,变化,可能,不确定,可行。自由。
技术的自由这个抽象的概念,在不同的事物上会有不同的范围概念圆的集合,主要用已知和未知可知来分方向。
已有硬件的范围,已有硬件的可用范围,已有硬件可用范围里的使用内容和使用的标准化稳定范围。
完全用人工,就如农业群体与工农群体之间的质量比较。机器人的作用是效率,而不是代替,是作为一个工具而不是人的情感代表来取代人自身,就如宠物与人的关系(一位极端喜好自己宠物的人可能在将自己宠物与他人比较时,忽略他人与自身相同的人概念,但是当自身与宠物发生生死取舍的,一般会选择舍去宠物这个身外之物。)。
编程语言与硬件可用范围的关系,以及与已有编程语言标准的关系,这个需要很熟悉已有内容,就如学习钻出了知识的概念群。
知识惯性,外行互动,服务要求,极端渐变,寻找更新。
Last edited by zzz19760225 on 2016-9-29 at 17:54 ]
Suppose there is an industry information concentration association for the C language, the free mode of Chinese people, which is also for the middle-level software and hardware reliable language that handles Chinese character digital information.
Chinese character - type assembly,
the grammar and ownership language of the fully free - structure of Chinese characters.
In a specific concept range, for the free range of possibility, the relatively appropriate restrictive language generated by practice is selected as the popularized content, and this popularized content is the standard.
In the mutual conversion between one purpose and behavior path, it is easy to lose the direction originally aimed at.
Tao, change, possibility, uncertainty, feasibility. Freedom.
The abstract concept of technical freedom has different range concept circle sets on different things, mainly divided into directions by known and unknown knowable.
The range of existing hardware, the available range of existing hardware, the use content in the available range of existing hardware and the standardized stable range of use.
Completely using manual work is just like the quality comparison between agricultural groups and industrial - agricultural groups. The role of robots is efficiency, not replacement, and they are used as a tool, not as a representative of human emotions to replace human beings themselves, just like the relationship between pets and people (a person with an extreme preference for his own pet may ignore the concept of the same person between others and himself when comparing his pet with others, but when there is a life - death choice between himself and the pet, he will generally choose to give up the pet, which is an external thing).
The relationship between programming languages and the available range of hardware, as well as the relationship with existing programming language standards, this needs to be very familiar with existing content, just like learning to drill out the concept group of knowledge.
Knowledge inertia, layman interaction, service requirements, extreme gradual change, seeking renewal.
Last edited by zzz19760225 on 2016-9-29 at 17:54 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:31 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
汉字DOS的基础文字信息,
语言编辑器工具,启动引导系统的基本环境或已有linux veket,FREEDOS,windows cmd,
结构,权限,范围,内容,公平
算法,效率,
界面,功能,功能应用获取的整体综合使用,
优化的自动和手工,单机,单用户,机器范围安全和信息安全的问题,网路中机器用户信息的安全问题,
更新,反馈,网路帮助,网络社群,个体网络交际门路类服务器,
生活编辑类软件,
工作编辑类软件,
学习编辑类软件。
生活为先,对应生活运用的用字需求,从无知进入有知的家庭教育,衣食住行乐的需求不足部分。
学习其次,对应成长中学生时代和自学结构,终身学习精神,追求更好而努力出更好。
工作最后,进入社会以自我生存生活学习综合内容为对象的基础工作,并且综合其他内容为职业的工作生活,包括从为别人工作转化为自我工作的终身职业工作和兴趣工作。
编码的无知,有知,可知,未知,不知的部分,集中在有知的长期和十年时代层级的稳定可靠自由效率内容,稳定而能愿意接受,可靠而能托付事情,自由而能适应时代变化,效率而实现更多时间于生活学习工作。编码方阵?
Last edited by zzz19760225 on 2016-7-6 at 20:40 ]
Basic character information of Chinese DOS,
Language editor tools, basic environment for boot systems or existing Linux Veket, FREEDOS, Windows cmd,
Structure, permissions, scope, content, fairness
Algorithm, efficiency,
Interface, function, overall comprehensive use of function application acquisition,
Optimized automatic and manual, stand-alone, single-user, machine-wide security and information security issues, security issues of machine user information in the network,
Update, feedback, network help, network community, individual network communication gateway servers,
Life editing software,
Work editing software,
Study editing software.
Life first, corresponding to the word usage needs of life application, from ignorance to knowledge in family education, and the insufficient parts of food, clothing, housing, transportation and entertainment needs.
Study second, corresponding to the growth middle school era and self-study structure, the spirit of lifelong learning, and striving for better to produce better.
Work finally, entering society to take the basic work with self-survival, life and study comprehensive content as the object, and the work life that integrates other contents as the profession, including the lifelong professional work and interest work that transforms from working for others to self-employment.
The parts of coding ignorance, knowledge, knowable, unknown, and unknowable, concentrated in the stable, reliable, free, and efficient content at the long-term and ten-year era levels of knowledge, stable and willing to accept, reliable and able to entrust things, free and able to adapt to the changes of the times, and efficient to realize more time for life, study, and work. Coding square?
Last edited by zzz19760225 on 2016-7-6 at 20:40 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:32 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
1veket下的gcc,emacs,vim(这个需要尝试实现),
虚拟机或实体机下的freedos,msdos,tc编辑器,
实体机的硬件和分区表,bios,三个变动环境中的构建可能探索,变动的硬件和环境,与相对不变的信息知识技术结构。
Last edited by zzz19760225 on 2016-7-7 at 04:16 ]
GCC, Emacs, Vim under 1veket (this needs to be tried to implement),
FreeDOS, MS-DOS, TC editor under virtual machine or physical machine,
Hardware and partition table, BIOS of physical machine, exploration of construction in three changing environments, changing hardware and environment, and relatively unchanged information knowledge and technical structure.
Last edited by zzz19760225 on 2016-7-7 at 04:16 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:33 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
1
开发shell 和和sell编程
打造工具和资源材料开发未知领域与用工具制作产品服务消费用户。
用编程语言去画出需要的内容,每一笔都是一个指令,得出一个内容,这些内容添补到受体上,形成追求个人需求画面的绘画过程。
目前的编程语言无法直接运行,需要达到的使用效果是操作系统,软件,硬件接口,如一个中间话筒,用户输入的内容需要同步或近乎同步的反应到指令对象,并形成一个整体状态缩小图形或地图。多层信息统计组成不同的信息地图,通过地图进行相对修改和查看差异,探索可能极限。
在linux优先使用vim,相对方便,可以不做任何调整。
电脑主板硬件信息地址(指针?),计算地址,内存地址,硬盘地址,优盘地址,用户界面硬件地址(显示屏,显卡,声卡,音响,网卡,路由器)。
操作系统的状态,静态的,动态。算盘式操作系统,静水式操作系统,流水式操作系统,石头式操作系统,动物式操作系统。机械电器类电脑,输入计算类电脑,主动类人电脑。
随时中断信息运输的路程,任何时候返回开始的出发点,停止正在运输的路程转到指定的出发点,临时暂时的停留再继续,结束所有路程。
编程语言表格,格子表格的层重叠,数据信息格子转向的跳线指令(从一个格子跑到另一个表格上的格子)。
类似sed,ex和vi的单句输入,这个输入相对一个整体,这个整体可以是处于类似调试的动态循环状态,或者类似格子表格的静态填格子的行为。
格子表格的层面限制和不限制层面的自由格子关系。
以自由信息为基础,向可行可用可靠走。
用3D软件构建格子表格,在格子表格中放置概念圆和原点信息。
小白新手学习的动静互换,首先是一个可以通过可见部分数字修改实现变化的编程游戏,其次是已经存在的3D格子表格打开信息知识技术帮助书籍学习,累了就去修改那个动态循环编程游戏玩,两者相同的基础是同一个编程语言范围内,而长期的硬件接口,应用软件,操作系统都是沿着这条路走的,自由可能无限的内容,使这条路只是一个方向可以确定,其余的无法预知,只有做出来的现在和总结出的过去。在龙芯熟悉和能用的延伸余力之外,从相同的命令集向其他计算机熟悉。
存储图形块的格子圆组成的方块图,有点类似硬盘咯。方块组图是针对信息层的逐层延伸需要。一个名字需要存储,例如文件这个两个汉字,通过18030和十六进数,转换为二进制,这二进制数组成一个数群,这些数群以自身影子照射的模式投影到硬盘的电路存储上。这时有屏幕上显示的文件这个名,同样有硬盘里文件这个二进制影子,还有围绕这个名与影的过程信息路或信息流。外接硬件自带驱动与三体操作系统自身硬件驱动各自起到作用,不需要另外寻找和安装硬件驱动(驱动更新可以闲置硬件本身附带的驱动)。五分之一防范心和五分之一信任心的中间群范围,这样分成人与人信任和怀疑两端中的三个状态,极端信任,极端怀疑,大概主次的中间变化范围。
物态的自由状态,中间常态自由状态,人需的自由状态。自由的可能概念和选择行为概念,力量的有概念,意识在和意识到。自由的反向负自由概念和直接延伸极端的反自由概念。自由的合理状态就是自由。定义自由与合理的另一种自由和相对定义前的自由的无自由。文字定义比较产生的不自由,不自由的可用性质。行为自由无自由。
三层概念的自由极限,常用道路,人需底限。编程需要的极限之处人是无法看全看清的,但是这种极限的不确定无限概念空间是可以存在的,这可以算假设,如果能用最好。在目前已有的内容上,总有比较好的当时,时代,过去的相对好的内容(比较能发挥效率的状态)。当遇到灾难和思考比较极限的时候,会有人生于此世的死这个一线的生存综合内容,没有空气,没有水,没有食物,没有内脏功能,等等人生存的底限。编程语言的生存,常用,极限。
增减延伸管道符号,等于号的变异。等于号,不等于号,约等于号,增减号,
~
~用约等于号会与约等于号的概念冲突,约等于上下两边加上个加和减号。约等于的定义误差归纳,增减号的增加减少随需参与加入的内容,一个增减号与另一个增减号之间的内容是一个回合,每个增减号后的第一个内容前面内容的综合总和。肯定确定与不确定随机内容的不断更新过程。
用ex模式,格子表格的半边操作,输入格子名,输入需要的内容,设置路上内容,类似增减号计算。
另半边是3D图形的直观,而这个直观过程可以通过另半边天的类ex操作模式,建立树形结构的分支,并行运行部分,修改部分。这个3D格子表格功能集成在操作系统或功能软件,硬件接口中,需要简化运行内容和体积大小。
二进制的表达与十进制和其他进制区分开来,有无,无为零有为一,无无为有,有无为有,有有为无。将不同进制计算,数字与字符区别的内容如何很好的行驶于字符为主的自然语言交流中?大道混沌趋向分路,路上极限上下分层类批量加工,特殊和个体空间及转变。
数形,函数集,数字概念的点,线段,射线,直线,方形,圆线形,规律曲线形,非规律曲线形。规律立体,非规律立体。规律多维体,非规律多维体。
数形内规律层面分类,数形内非规律层面分类。
规律数字,非规律数字。
规律数和非规律数的互相准确计算和非准确计算,可得结果和非得结果,定义数字和结果,约等于结果。
||||||
---------------------------------------------------
| | | | | | | | | |
---------------------------------------------------
|( )| ( )|()| ()| ()|()|()|()|( )|
---------------------------------------------------
| / | / | / | / | / | \ | \ | \ | \ |
+----+-----+-----+----+----+----+---+----+-----+
| > | > | < | < | > | > | > | > | < |
---------------------------------------------------
有些内容明显是有人走过,直接使用就可以了,但是要在合适的时候发现需要的内容,需要一个分享,标准名义和搜索的部分。
名,地址,起名时间,信息大小,统计标准,
修改时间1,结果,地址路,开始,备注信息;
修改时间2,,,,;
修改信息用于数据恢复。
名,起点仓,运输车,运输路,终点仓。
名字当中包括所有信息,
命令名/命令内容(名,起点仓,运输车,运输路,终点仓)/时间/
时间,过去时间,现在时间,未来时间,
过去的记录修改恢复时间,现在的使用时间,校准时间,错误时间,未来的预算计划类需使用时间。
用光感角度提取线条比较,统计出以天为基础的近似时间值,用于时间缺失。石英钟时间,无线电波时间,网络中国时间,网络外国时间。
不定义空间大小,最小十倍百倍千倍万倍空间,最小一到五倍空间。
顺序存储节约空间,增大内存硬盘空间,压缩式存储空间。
这些内容在论坛里应该有。
Last edited by zzz19760225 on 2016-9-30 at 02:16 ]
1
Developing shells and sell programming
Creating tools and resource materials, exploring unknown areas, and using tools to produce products and serve users.
Using programming languages to draw the desired content, each stroke is an instruction, resulting in a content that is added to the receiver to form the painting process of pursuing personal needs.
The current programming languages cannot run directly. The desired use effect is to reach the operating system, software, and hardware interface, like an intermediate microphone. The content input by the user needs to be synchronized or nearly synchronized to the instruction object and form an overall state reduced graph or map. Multiple layers of information statistics form different information maps, and relative modifications and viewing of differences are carried out through the maps to explore possible limits.
In Linux, Vim is preferred, which is relatively convenient and can be used without any adjustments.
Computer motherboard hardware information addresses (pointers?), calculation addresses, memory addresses, hard disk addresses, USB flash drive addresses, user interface hardware addresses (displays, graphics cards, sound cards, speakers, network cards, routers).
The state of the operating system, static and dynamic. Abacus-style operating system, still water-style operating system, flowing water-style operating system, stone-style operating system, animal-style operating system. Mechanical electrical computers, input calculation computers, active human-like computers.
Interrupt the information transportation route at any time, return to the starting point at any time, stop the ongoing transportation route and transfer to the designated starting point, temporarily stop and then continue, and end all routes.
Programming language table, overlapping layers of grid tables, data information grid steering jumper instructions (running from one grid to a grid on another table).
Similar to sed, ex, and vi single-sentence input. This input is relatively a whole, which can be in a dynamic loop state similar to debugging or a static grid filling behavior similar to grid tables.
Layer restrictions and non-restricted layer free grid relationships of grid tables.
Based on free information, move towards feasible, usable, and reliable.
Build grid tables with 3D software, and place conceptual circles and origin information in the grid tables.
The dynamic and static exchange for novice learners. First, it is a programming game that can change through visible part number modification. Second, open existing 3D grid table information knowledge technology help books for learning. When tired, go to modify that dynamic loop programming game. The common basis of the two is within the same programming language range, and the long-term hardware interface, application software, and operating system all follow this path. The content with potentially infinite freedom makes this path only a direction that can be determined, and the rest cannot be predicted, only the present made and the past summarized. Beyond the extended surplus of being familiar with and able to use Loongson, get familiar with other computers from the same instruction set.
A block diagram composed of grid circles storing graphics blocks, somewhat similar to a hard disk. The block group diagram is for the layer-by-layer extension needs of information layers. A name needs to be stored, for example, the two Chinese characters "file". Convert it to binary through 18030 and hexadecimal numbers. These binary numbers form a number group, and these number groups are projected onto the circuit storage of the hard disk in the mode of their own shadow projection. At this time, there is the name "file" displayed on the screen, and there is also the binary shadow of "file" in the hard disk, as well as the process information path or information flow around this name and shadow. The external hardware comes with its own driver and the three-body operating system's own hardware driver play their roles respectively, and there is no need to find and install hardware drivers separately (driver updates can idle the hardware's own attached driver). The middle group range of one-fifth of precaution and one-fifth of trust, thus dividing into three states between the two ends of trust and suspicion between people: extreme trust, extreme suspicion, and the approximate intermediate change range between the main and secondary.
The free state of material state, the intermediate normal free state, and the free state of human needs. The concept of possible freedom and the concept of choice behavior, the concept of having power, consciousness being and being aware. The reverse negative freedom concept of freedom and the anti-free concept directly extending to the extreme. The reasonable state of freedom is freedom. Define another freedom of freedom and relative definition before freedom as no freedom. The non-freedom caused by text definition comparison, and the usable nature of non-freedom. Behavioral freedom and non-freedom.
The free limit of the three-layer concept, common roads, and human needs bottom line. The programming needs limit is something that humans cannot see or understand completely, but this uncertain infinite concept space of limit can exist, which can be considered as an assumption, and it is best if it can be used. In the existing content, there is always a relatively good time, era, and past content (a state that can play efficiency relatively). When encountering disasters and thinking about the limit, there will be the comprehensive content of the survival of life in this world at the line of death, without air, without water, without food, without internal organ functions, etc., the bottom line of human survival. The survival, common use, and limit of programming languages.
Adding, subtracting, and extending pipe symbols, and the variation of the equal sign. Equal sign, not equal sign, approximately equal sign, plus-minus sign,
~
~Using the approximately equal sign will conflict with the concept of the approximately equal sign. Add a plus and minus sign above and below the approximately equal sign. The definition error summary of the approximately equal sign, and the addition and subtraction of the plus-minus sign follow the content to be added as needed. The content between one plus-minus sign and another plus-minus sign is a round, and the sum of the comprehensive content of the first content after each plus-minus sign and the preceding content. The continuous updating process of certain and uncertain random content.
Using ex mode, half-side operation of grid tables, input grid name, input needed content, set content on the road, similar to plus-minus sign calculation.
The other half is the intuitiveness of 3D graphics, and this intuitive process can establish a tree structure branch, parallel running part, and modification part through the ex-like operation mode of the other half. This 3D grid table function is integrated in the operating system or functional software, hardware interface, and needs to simplify the running content and volume size.
Distinguish the expression of binary from decimal and other number systems. None, nothing is zero, something is one, nothing and nothing is something, nothing and something is something, something and something is nothing. How to make the content of different number system calculations, numbers and characters distinction travel well in natural language communication dominated by characters? The great way is chaotic and tends to branch, with the upper and lower layers of the limit on the road similar to batch processing, special and individual spaces and transformations.
Number form, function set, points, line segments, rays, straight lines, squares, circular lines, regular curves, irregular curves of digital concepts. Regular solids, irregular solids. Regular multi-dimensional bodies, irregular multi-dimensional bodies.
Classification of regular layers within number forms, classification of irregular layers within number forms.
Regular numbers, irregular numbers.
Accurate calculation and inaccurate calculation between regular numbers and irregular numbers, obtainable results and non-obtainable results, definition of numbers and results, approximately equal results.
||||||
---------------------------------------------------
| | | | | | | | | |
---------------------------------------------------
|( )| ( )|()| ()| ()|()|()|()|( )|
---------------------------------------------------
| / | / | / | / | / | \ | \ | \ | \ |
+----+-----+-----+----+----+----+---+----+-----+
| > | > | < | < | > | > | > | > | < |
---------------------------------------------------
Some content is obviously walked by someone, and it can be used directly, but it is necessary to find the needed content at the appropriate time, and a part of sharing, standard name, and search is needed.
Name, address, name creation time, information size, statistics standard,
Modification time 1, result, address path, start, remarks;
Modification time 2, , , , ;
Modification information is used for data recovery.
Name, starting warehouse, transport vehicle, transport path, ending warehouse.
The name includes all information,
Command name / command content (name, starting warehouse, transport vehicle, transport path, ending warehouse) / time /
Time, past time, present time, future time,
Past record modification recovery time, present use time, calibration time, error time, future budget plan class need use time.
Extract lines for comparison by light sensing angle, count approximate time values based on days for time missing. Quartz clock time, radio wave time, network China time, network foreign time.
Do not define the space size, minimum ten times, hundred times, thousand times, ten thousand times space, minimum one to five times space.
Sequential storage saves space, increases memory and hard disk space, compressed storage space.
These contents should be in the forum.
Last edited by zzz19760225 on 2016-9-30 at 02:16 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:34 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
1C -> C++ -> go -> vala->gtk..................qml qt..........
Last edited by zzz19760225 on 2016-7-28 at 15:18 ]
1C -> C++ -> go -> vala->gtk..................qml qt..........
Last edited by zzz19760225 on 2016-7-28 at 15:18 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:36 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
4个函数实现的C编译器:C4
C4 2014-11-13 12:57:30 发布
您的评价:
0.0
收藏 0收藏
4个函数实现的c编译器,大约500行。基本上已经比较完备了,可以自己编译自己。
使用方法:
gcc -o c4 c4.c (you may need the -m32 option on 64bit machines)
./c4 hello.c
./c4 -s hello.c
./c4 c4.c hello.c
./c4 c4.c c4.c hello.c
项目主页: http://www.open-open.com/lib/view/home/1415851490758
// c4.c - C in four functions
// char, int, and pointer types
// if, while, return, and expression statements
// just enough features to allow self-compilation and a bit more
// Written by Robert Swierczek
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <unistd.h>
#include <fcntl.h>
char *p, *lp, // current position in source code
*data; // data/bss pointer
int *e, *le, // current position in emitted code
*id, // currently parsed identifier
*sym, // symbol table (simple list of identifiers)
tk, // current token
ival, // current token value
ty, // current expression type
loc, // local variable offset
line, // current line number
src, // print source and assembly flag
debug; // print executed instructions
// tokens and classes (operators last and in precedence order)
enum {
Num = 128, Fun, Sys, Glo, Loc, Id,
Char, Else, Enum, If, Int, Return, Sizeof, While,
Assign, Cond, Lor, Lan, Or, Xor, And, Eq, Ne, Lt, Gt, Le, Ge, Shl, Shr, Add, Sub, Mul, Div, Mod, Inc, Dec, Brak
};
// opcodes
enum { LEA ,IMM ,JMP ,JSR ,BZ ,BNZ ,ENT ,ADJ ,LEV ,LI ,LC ,SI ,SC ,PSH ,
OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,
OPEN,READ,CLOS,PRTF,MALC,MSET,MCMP,EXIT };
// types
enum { CHAR, INT, PTR };
// identifier offsets (since we can't create an ident struct)
enum { Tk, Hash, Name, Class, Type, Val, HClass, HType, HVal, Idsz };
void next()
{
char *pp;
while (tk = *p) {
++p;
if (tk == '\n') {
if (src) {
printf("%d: %.*s", line, p - lp, lp);
lp = p;
while (le < e) {
printf("%8.4s", &"LEA ,IMM ,JMP ,JSR ,BZ ,BNZ ,ENT ,ADJ ,LEV ,LI ,LC ,SI ,SC ,PSH ,"
"OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,"
"OPEN,READ,CLOS,PRTF,MALC,MSET,MCMP,EXIT,");
if (*le <= ADJ) printf(" %d\n", *++le); else printf("\n");
}
}
++line;
}
else if (tk == '#') {
while (*p != 0 && *p != '\n') ++p;
}
else if ((tk >= 'a' && tk <= 'z') || (tk >= 'A' && tk <= 'Z') || tk == '_') {
pp = p - 1;
while ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '_')
tk = tk * 147 + *p++;
tk = (tk << 6) + (p - pp);
id = sym;
while (id) {
if (tk == id && !memcmp((char *)id, pp, p - pp)) { tk = id; return; }
id = id + Idsz;
}
id = (int)pp;
id = tk;
tk = id = Id;
return;
}
else if (tk >= '0' && tk <= '9') {
if (ival = tk - '0') { while (*p >= '0' && *p <= '9') ival = ival * 10 + *p++ - '0'; }
else if (*p == 'x' || *p == 'X') {
while ((tk = *++p) && ((tk >= '0' && tk <= '9') || (tk >= 'a' && tk <= 'f') || (tk >= 'A' && tk <= 'F')))
ival = ival * 16 + (tk & 15) + (tk >= 'A' ? 9 : 0);
}
else { while (*p >= '0' && *p <= '7') ival = ival * 8 + *p++ - '0'; }
tk = Num;
return;
}
else if (tk == '/') {
if (*p == '/') {
++p;
while (*p != 0 && *p != '\n') ++p;
}
else {
tk = Div;
return;
}
}
else if (tk == '\'' || tk == '"') {
pp = data;
while (*p != 0 && *p != tk) {
if ((ival = *p++) == '\\') {
if ((ival = *p++) == 'n') ival = '\n';
}
if (tk == '"') *data++ = ival;
}
++p;
if (tk == '"') ival = (int)pp; else tk = Num;
return;
}
else if (tk == '=') { if (*p == '=') { ++p; tk = Eq; } else tk = Assign; return; }
else if (tk == '+') { if (*p == '+') { ++p; tk = Inc; } else tk = Add; return; }
else if (tk == '-') { if (*p == '-') { ++p; tk = Dec; } else tk = Sub; return; }
else if (tk == '!') { if (*p == '=') { ++p; tk = Ne; } return; }
else if (tk == '<') { if (*p == '=') { ++p; tk = Le; } else if (*p == '<') { ++p; tk = Shl; } else tk = Lt; return; }
else if (tk == '>') { if (*p == '=') { ++p; tk = Ge; } else if (*p == '>') { ++p; tk = Shr; } else tk = Gt; return; }
else if (tk == '|') { if (*p == '|') { ++p; tk = Lor; } else tk = Or; return; }
else if (tk == '&') { if (*p == '&') { ++p; tk = Lan; } else tk = And; return; }
else if (tk == '^') { tk = Xor; return; }
else if (tk == '%') { tk = Mod; return; }
else if (tk == '*') { tk = Mul; return; }
else if (tk == ' ' || tk == ',' || tk == ':') return;
}
}
void expr(int lev)
{
int t, *d;
if (!tk) { printf("%d: unexpected eof in expression\n", line); exit(-1); }
else if (tk == Num) { *++e = IMM; *++e = ival; next(); ty = INT; }
else if (tk == '"') {
*++e = IMM; *++e = ival; next();
while (tk == '"') next();
data = (char *)((int)data + sizeof(int) & -sizeof(int)); ty = PTR;
}
else if (tk == Sizeof) {
next(); if (tk == '(') next(); else { printf("%d: open paren expected in sizeof\n", line); exit(-1); }
ty = INT; if (tk == Int) next(); else if (tk == Char) { next(); ty = CHAR; }
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk == ')') next(); else { printf("%d: close paren expected in sizeof\n", line); exit(-1); }
*++e = IMM; *++e = (ty == CHAR) ? sizeof(char) : sizeof(int);
ty = INT;
}
else if (tk == Id) {
d = id; next();
if (tk == '(') {
next();
t = 0;
while (tk != ')') { expr(Assign); *++e = PSH; ++t; if (tk == ',') next(); }
next();
if (d == Sys) *++e = d;
else if (d == Fun) { *++e = JSR; *++e = d; }
else { printf("%d: bad function call\n", line); exit(-1); }
if (t) { *++e = ADJ; *++e = t; }
ty = d;
}
else if (d == Num) { *++e = IMM; *++e = d; ty = INT; }
else {
if (d == Loc) { *++e = LEA; *++e = loc - d; }
else if (d == Glo) { *++e = IMM; *++e = d; }
else { printf("%d: undefined variable\n", line); exit(-1); }
*++e = ((ty = d) == CHAR) ? LC : LI;
}
}
else if (tk == '(') {
next();
if (tk == Int || tk == Char) {
t = (tk == Int) ? INT : CHAR; next();
while (tk == Mul) { next(); t = t + PTR; }
if (tk == ')') next(); else { printf("%d: bad cast\n", line); exit(-1); }
expr(Inc);
ty = t;
}
else {
expr(Assign);
if (tk == ')') next(); else { printf("%d: close paren expected\n", line); exit(-1); }
}
}
else if (tk == Mul) {
next(); expr(Inc);
if (ty > INT) ty = ty - PTR; else { printf("%d: bad dereference\n", line); exit(-1); }
*++e = (ty == CHAR) ? LC : LI;
}
else if (tk == And) {
next(); expr(Inc);
if (*e == LC || *e == LI) --e; else { printf("%d: bad address-of\n", line); exit(-1); }
ty = ty + PTR;
}
else if (tk == '!') { next(); expr(Inc); *++e = PSH; *++e = IMM; *++e = 0; *++e = EQ; ty = INT; }
else if (tk == '~') { next(); expr(Inc); *++e = PSH; *++e = IMM; *++e = -1; *++e = XOR; ty = INT; }
else if (tk == Add) { next(); expr(Inc); ty = INT; }
else if (tk == Sub) {
next(); *++e = IMM;
if (tk == Num) { *++e = -ival; next(); } else { *++e = -1; *++e = PSH; expr(Inc); *++e = MUL; }
ty = INT;
}
else if (tk == Inc || tk == Dec) {
t = tk; next(); expr(Inc);
if (*e == LC) { *e = PSH; *++e = LC; }
else if (*e == LI) { *e = PSH; *++e = LI; }
else { printf("%d: bad lvalue in pre-increment\n", line); exit(-1); }
*++e = PSH;
*++e = IMM; *++e = (ty > PTR) ? sizeof(int) : sizeof(char);
*++e = (t == Inc) ? ADD : SUB;
*++e = (ty == CHAR) ? SC : SI;
}
else { printf("%d: bad expression\n", line); exit(-1); }
while (tk >= lev) { // "precedence climbing" or "Top Down Operator Precedence" method
t = ty;
if (tk == Assign) {
next();
if (*e == LC || *e == LI) *e = PSH; else { printf("%d: bad lvalue in assignment\n", line); exit(-1); }
expr(Assign); *++e = ((ty = t) == CHAR) ? SC : SI;
}
else if (tk == Cond) {
next();
*++e = BZ; d = ++e;
expr(Assign);
if (tk == ':') next(); else { printf("%d: conditional missing colon\n", line); exit(-1); }
*d = (int)(e + 3); *++e = JMP; d = ++e;
expr(Cond);
*d = (int)(e + 1);
}
else if (tk == Lor) { next(); *++e = BNZ; d = ++e; expr(Lan); *d = (int)(e + 1); ty = INT; }
else if (tk == Lan) { next(); *++e = BZ; d = ++e; expr(Or); *d = (int)(e + 1); ty = INT; }
else if (tk == Or) { next(); *++e = PSH; expr(Xor); *++e = OR; ty = INT; }
else if (tk == Xor) { next(); *++e = PSH; expr(And); *++e = XOR; ty = INT; }
else if (tk == And) { next(); *++e = PSH; expr(Eq); *++e = AND; ty = INT; }
else if (tk == Eq) { next(); *++e = PSH; expr(Lt); *++e = EQ; ty = INT; }
else if (tk == Ne) { next(); *++e = PSH; expr(Lt); *++e = NE; ty = INT; }
else if (tk == Lt) { next(); *++e = PSH; expr(Shl); *++e = LT; ty = INT; }
else if (tk == Gt) { next(); *++e = PSH; expr(Shl); *++e = GT; ty = INT; }
else if (tk == Le) { next(); *++e = PSH; expr(Shl); *++e = LE; ty = INT; }
else if (tk == Ge) { next(); *++e = PSH; expr(Shl); *++e = GE; ty = INT; }
else if (tk == Shl) { next(); *++e = PSH; expr(Add); *++e = SHL; ty = INT; }
else if (tk == Shr) { next(); *++e = PSH; expr(Add); *++e = SHR; ty = INT; }
else if (tk == Add) {
next(); *++e = PSH; expr(Mul);
if ((ty = t) > PTR) { *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = MUL; }
*++e = ADD;
}
else if (tk == Sub) {
next(); *++e = PSH; expr(Mul);
if (t > PTR && t == ty) { *++e = SUB; *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = DIV; ty = INT; }
else if ((ty = t) > PTR) { *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = MUL; *++e = SUB; }
else *++e = SUB;
}
else if (tk == Mul) { next(); *++e = PSH; expr(Inc); *++e = MUL; ty = INT; }
else if (tk == Div) { next(); *++e = PSH; expr(Inc); *++e = DIV; ty = INT; }
else if (tk == Mod) { next(); *++e = PSH; expr(Inc); *++e = MOD; ty = INT; }
else if (tk == Inc || tk == Dec) {
if (*e == LC) { *e = PSH; *++e = LC; }
else if (*e == LI) { *e = PSH; *++e = LI; }
else { printf("%d: bad lvalue in post-increment\n", line); exit(-1); }
*++e = PSH; *++e = IMM; *++e = (ty > PTR) ? sizeof(int) : sizeof(char);
*++e = (tk == Inc) ? ADD : SUB;
*++e = (ty == CHAR) ? SC : SI;
*++e = PSH; *++e = IMM; *++e = (ty > PTR) ? sizeof(int) : sizeof(char);
*++e = (tk == Inc) ? SUB : ADD;
next();
}
else if (tk == Brak) {
next(); *++e = PSH; expr(Assign);
if (tk == ']') next(); else { printf("%d: close bracket expected\n", line); exit(-1); }
if (t > PTR) { *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = MUL; }
else if (t < PTR) { printf("%d: pointer type expected\n", line); exit(-1); }
*++e = ADD;
*++e = ((ty = t - PTR) == CHAR) ? LC : LI;
}
else { printf("%d: compiler error tk=%d\n", line, tk); exit(-1); }
}
}
void stmt()
{
int *a, *b;
if (tk == If) {
next();
if (tk == '(') next(); else { printf("%d: open paren expected\n", line); exit(-1); }
expr(Assign);
if (tk == ')') next(); else { printf("%d: close paren expected\n", line); exit(-1); }
*++e = BZ; b = ++e;
stmt();
if (tk == Else) {
*b = (int)(e + 3); *++e = JMP; b = ++e;
next();
stmt();
}
*b = (int)(e + 1);
}
else if (tk == While) {
next();
a = e + 1;
if (tk == '(') next(); else { printf("%d: open paren expected\n", line); exit(-1); }
expr(Assign);
if (tk == ')') next(); else { printf("%d: close paren expected\n", line); exit(-1); }
*++e = BZ; b = ++e;
stmt();
*++e = JMP; *++e = (int)a;
*b = (int)(e + 1);
}
else if (tk == Return) {
next();
if (tk != ';') expr(Assign);
*++e = LEV;
if (tk == ';') next(); else { printf("%d: semicolon expected\n", line); exit(-1); }
}
else if (tk == '{') {
next();
while (tk != '}') stmt();
next();
}
else if (tk == ';') {
next();
}
else {
expr(Assign);
if (tk == ';') next(); else { printf("%d: semicolon expected\n", line); exit(-1); }
}
}
int main(int argc, char **argv)
{
int fd, bt, ty, poolsz, *idmain;
int *pc, *sp, *bp, a, cycle; // vm registers
int i, *t; // temps
--argc; ++argv;
if (argc > 0 && **argv == '-' && (*argv) == 's') { src = 1; --argc; ++argv; }
if (argc > 0 && **argv == '-' && (*argv) == 'd') { debug = 1; --argc; ++argv; }
if (argc < 1) { printf("usage: c4 file ...\n"); return -1; }
if ((fd = open(*argv, 0)) < 0) { printf("could not open(%s)\n", *argv); return -1; }
poolsz = 256*1024; // arbitrary size
if (!(sym = malloc(poolsz))) { printf("could not malloc(%d) symbol area\n", poolsz); return -1; }
if (!(le = e = malloc(poolsz))) { printf("could not malloc(%d) text area\n", poolsz); return -1; }
if (!(data = malloc(poolsz))) { printf("could not malloc(%d) data area\n", poolsz); return -1; }
if (!(sp = malloc(poolsz))) { printf("could not malloc(%d) stack area\n", poolsz); return -1; }
memset(sym, 0, poolsz);
memset(e, 0, poolsz);
memset(data, 0, poolsz);
p = "char else enum if int return sizeof while "
"open read close printf malloc memset memcmp exit void main";
i = Char; while (i <= While) { next(); id = i++; } // add keywords to symbol table
i = OPEN; while (i <= EXIT) { next(); id = Sys; id = INT; id = i++; } // add library to symbol table
next(); id = Char; // handle void type
next(); idmain = id; // keep track of main
if (!(lp = p = malloc(poolsz))) { printf("could not malloc(%d) source area\n", poolsz); return -1; }
if ((i = read(fd, p, poolsz-1)) <= 0) { printf("read() returned %d\n", i); return -1; }
p = 0;
close(fd);
// parse declarations
line = 1;
next();
while (tk) {
bt = INT; // basetype
if (tk == Int) next();
else if (tk == Char) { next(); bt = CHAR; }
else if (tk == Enum) {
next();
if (tk != '{') next();
if (tk == '{') {
next();
i = 0;
while (tk != '}') {
if (tk != Id) { printf("%d: bad enum identifier %d\n", line, tk); return -1; }
next();
if (tk == Assign) {
next();
if (tk != Num) { printf("%d: bad enum initializer\n", line); return -1; }
i = ival;
next();
}
id = Num; id = INT; id = i++;
if (tk == ',') next();
}
next();
}
}
while (tk != ';' && tk != '}') {
ty = bt;
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad global declaration\n", line); return -1; }
if (id) { printf("%d: duplicate global definition\n", line); return -1; }
next();
id = ty;
if (tk == '(') { // function
id = Fun;
id = (int)(e + 1);
next(); i = 0;
while (tk != ')') {
ty = INT;
if (tk == Int) next();
else if (tk == Char) { next(); ty = CHAR; }
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad parameter declaration\n", line); return -1; }
if (id == Loc) { printf("%d: duplicate parameter definition\n", line); return -1; }
id = id; id = Loc;
id = id; id = ty;
id = id; id = i++;
next();
if (tk == ',') next();
}
next();
if (tk != '{') { printf("%d: bad function definition\n", line); return -1; }
loc = ++i;
next();
while (tk == Int || tk == Char) {
bt = (tk == Int) ? INT : CHAR;
next();
while (tk != ';') {
ty = bt;
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad local declaration\n", line); return -1; }
if (id == Loc) { printf("%d: duplicate local definition\n", line); return -1; }
id = id; id = Loc;
id = id; id = ty;
id = id; id = ++i;
next();
if (tk == ',') next();
}
next();
}
*++e = ENT; *++e = i - loc;
while (tk != '}') stmt();
*++e = LEV;
id = sym; // unwind symbol table locals
while (id) {
if (id == Loc) {
id = id;
id = id;
id = id;
}
id = id + Idsz;
}
}
else {
id = Glo;
id = (int)data;
data = data + sizeof(int);
}
if (tk == ',') next();
}
next();
}
if (!(pc = (int *)idmain)) { printf("main() not defined\n"); return -1; }
if (src) return 0;
// setup stack
sp = (int *)((int)sp + poolsz);
*--sp = EXIT; // call exit if main returns
*--sp = PSH; t = sp;
*--sp = argc;
*--sp = (int)argv;
*--sp = (int)t;
// run...
cycle = 0;
while (1) {
i = *pc++; ++cycle;
if (debug) {
printf("%d> %.4s", cycle,
&"LEA ,IMM ,JMP ,JSR ,BZ ,BNZ ,ENT ,ADJ ,LEV ,LI ,LC ,SI ,SC ,PSH ,"
"OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,"
"OPEN,READ,CLOS,PRTF,MALC,MSET,MCMP,EXIT,");
if (i <= ADJ) printf(" %d\n", *pc); else printf("\n");
}
if (i == LEA) a = (int)(bp + *pc++); // load local address
else if (i == IMM) a = *pc++; // load global address or immediate
else if (i == JMP) pc = (int *)*pc; // jump
else if (i == JSR) { *--sp = (int)(pc + 1); pc = (int *)*pc; } // jump to subroutine
else if (i == BZ) pc = a ? pc + 1 : (int *)*pc; // branch if zero
else if (i == BNZ) pc = a ? (int *)*pc : pc + 1; // branch if not zero
else if (i == ENT) { *--sp = (int)bp; bp = sp; sp = sp - *pc++; } // enter subroutine
else if (i == ADJ) sp = sp + *pc++; // stack adjust
else if (i == LEV) { sp = bp; bp = (int *)*sp++; pc = (int *)*sp++; } // leave subroutine
else if (i == LI) a = *(int *)a; // load int
else if (i == LC) a = *(char *)a; // load char
else if (i == SI) *(int *)*sp++ = a; // store int
else if (i == SC) a = *(char *)*sp++ = a; // store char
else if (i == PSH) *--sp = a; // push
else if (i == OR) a = *sp++ | a;
else if (i == XOR) a = *sp++ ^ a;
else if (i == AND) a = *sp++ & a;
else if (i == EQ) a = *sp++ == a;
else if (i == NE) a = *sp++ != a;
else if (i == LT) a = *sp++ < a;
else if (i == GT) a = *sp++ > a;
else if (i == LE) a = *sp++ <= a;
else if (i == GE) a = *sp++ >= a;
else if (i == SHL) a = *sp++ << a;
else if (i == SHR) a = *sp++ >> a;
else if (i == ADD) a = *sp++ + a;
else if (i == SUB) a = *sp++ - a;
else if (i == MUL) a = *sp++ * a;
else if (i == DIV) a = *sp++ / a;
else if (i == MOD) a = *sp++ % a;
else if (i == OPEN) a = open((char *)sp, *sp);
else if (i == READ) a = read(sp, (char *)sp, *sp);
else if (i == CLOS) a = close(*sp);
else if (i == PRTF) { t = sp + pc; a = printf((char *)t, t, t, t, t, t); }
else if (i == MALC) a = (int)malloc(*sp);
else if (i == MSET) a = (int)memset((char *)sp, sp, *sp);
else if (i == MCMP) a = memcmp((char *)sp, (char *)sp, *sp);
else if (i == EXIT) { printf("exit(%d) cycle = %d\n", *sp, cycle); return *sp; }
else { printf("unknown instruction = %d! cycle = %d\n", i, cycle); return -1; }
}
}
Last edited by zzz19760225 on 2016-12-4 at 00:33 ]
4 Functions Implementing a C Compiler: C4
C4 2014-11-13 12:57:30 Published
Your rating:
0.0
Collect 0 Collections
A C compiler implemented with 4 functions, approximately 500 lines. Basically quite complete and can compile itself.
Usage method:
gcc -o c4 c4.c (you may need the -m32 option on 64-bit machines)
./c4 hello.c
./c4 -s hello.c
./c4 c4.c hello.c
./c4 c4.c c4.c hello.c
Project homepage: http://www.open-open.com/lib/view/home/1415851490758
// c4.c - C in four functions
// char, int, and pointer types
// if, while, return, and expression statements
// just enough features to allow self-compilation and a bit more
// Written by Robert Swierczek
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <unistd.h>
#include <fcntl.h>
char *p, *lp, // Current position in the source code
*data; // Data/bss pointer
int *e, *le, // Current position in the emitted code
*id, // Currently parsed identifier
*sym, // Symbol table (simple list of identifiers)
tk, // Current token
ival, // Current token value
ty, // Current expression type
loc, // Local variable offset
line, // Current line number
src, // Print source and assembly flag
debug; // Print executed instructions
// Tokens and classes (operators last and in precedence order)
enum {
Num = 128, Fun, Sys, Glo, Loc, Id,
Char, Else, Enum, If, Int, Return, Sizeof, While,
Assign, Cond, Lor, Lan, Or, Xor, And, Eq, Ne, Lt, Gt, Le, Ge, Shl, Shr, Add, Sub, Mul, Div, Mod, Inc, Dec, Brak
};
// Opcodes
enum { LEA ,IMM ,JMP ,JSR ,BZ ,BNZ ,ENT ,ADJ ,LEV ,LI ,LC ,SI ,SC ,PSH ,
OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,
OPEN,READ,CLOS,PRTF,MALC,MSET,MCMP,EXIT };
// Types
enum { CHAR, INT, PTR };
// Identifier offsets (since we can't create an ident struct)
enum { Tk, Hash, Name, Class, Type, Val, HClass, HType, HVal, Idsz };
void next()
{
char *pp;
while (tk = *p) {
++p;
if (tk == '\n') {
if (src) {
printf("%d: %.*s", line, p - lp, lp);
lp = p;
while (le < e) {
printf("%8.4s", &"LEA ,IMM ,JMP ,JSR ,BZ ,BNZ ,ENT ,ADJ ,LEV ,LI ,LC ,SI ,SC ,PSH ,"
"OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,"
"OPEN,READ,CLOS,PRTF,MALC,MSET,MCMP,EXIT,");
if (*le <= ADJ) printf(" %d\n", *++le); else printf("\n");
}
}
++line;
}
else if (tk == '#') {
while (*p != 0 && *p != '\n') ++p;
}
else if ((tk >= 'a' && tk <= 'z') || (tk >= 'A' && tk <= 'Z') || tk == '_') {
pp = p - 1;
while ((*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z') || (*p >= '0' && *p <= '9') || *p == '_')
tk = tk * 147 + *p++;
tk = (tk << 6) + (p - pp);
id = sym;
while (id) {
if (tk == id && !memcmp((char *)id, pp, p - pp)) { tk = id; return; }
id = id + Idsz;
}
id = (int)pp;
id = tk;
tk = id = Id;
return;
}
else if (tk >= '0' && tk <= '9') {
if (ival = tk - '0') { while (*p >= '0' && *p <= '9') ival = ival * 10 + *p++ - '0'; }
else if (*p == 'x' || *p == 'X') {
while ((tk = *++p) && ((tk >= '0' && tk <= '9') || (tk >= 'a' && tk <= 'f') || (tk >= 'A' && tk <= 'F')))
ival = ival * 16 + (tk & 15) + (tk >= 'A' ? 9 : 0);
}
else { while (*p >= '0' && *p <= '7') ival = ival * 8 + *p++ - '0'; }
tk = Num;
return;
}
else if (tk == '/') {
if (*p == '//') {
++p;
while (*p != 0 && *p != '\n') ++p;
}
else {
tk = Div;
return;
}
}
else if (tk == '\'' || tk == '"') {
pp = data;
while (*p != 0 && *p != tk) {
if ((ival = *p++) == '\\') {
if ((ival = *p++) == 'n') ival = '\n';
}
if (tk == '"') *data++ = ival;
}
++p;
if (tk == '"') ival = (int)pp; else tk = Num;
return;
}
else if (tk == '=') { if (*p == '=') { ++p; tk = Eq; } else tk = Assign; return; }
else if (tk == '+') { if (*p == '+') { ++p; tk = Inc; } else tk = Add; return; }
else if (tk == '-') { if (*p == '-') { ++p; tk = Dec; } else tk = Sub; return; }
else if (tk == '!') { if (*p == '=') { ++p; tk = Ne; } return; }
else if (tk == '<') { if (*p == '=') { ++p; tk = Le; } else if (*p == '<') { ++p; tk = Shl; } else tk = Lt; return; }
else if (tk == '>') { if (*p == '=') { ++p; tk = Ge; } else if (*p == '>') { ++p; tk = Shr; } else tk = Gt; return; }
else if (tk == '|') { if (*p == '|') { ++p; tk = Lor; } else tk = Or; return; }
else if (tk == '&') { if (*p == '&') { ++p; tk = Lan; } else tk = And; return; }
else if (tk == '^') { tk = Xor; return; }
else if (tk == '%') { tk = Mod; return; }
else if (tk == '*') { tk = Mul; return; }
else if (tk == ' ' || tk == ',' || tk == ':') return;
}
}
void expr(int lev)
{
int t, *d;
if (!tk) { printf("%d: unexpected eof in expression\n", line); exit(-1); }
else if (tk == Num) { *++e = IMM; *++e = ival; next(); ty = INT; }
else if (tk == '"') {
*++e = IMM; *++e = ival; next();
while (tk == '"') next();
data = (char *)((int)data + sizeof(int) & -sizeof(int)); ty = PTR;
}
else if (tk == Sizeof) {
next(); if (tk == '(') next(); else { printf("%d: open paren expected in sizeof\n", line); exit(-1); }
ty = INT; if (tk == Int) next(); else if (tk == Char) { next(); ty = CHAR; }
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk == ')') next(); else { printf("%d: close paren expected in sizeof\n", line); exit(-1); }
*++e = IMM; *++e = (ty == CHAR) ? sizeof(char) : sizeof(int);
ty = INT;
}
else if (tk == Id) {
d = id; next();
if (tk == '(') {
next();
t = 0;
while (tk != ')') { expr(Assign); *++e = PSH; ++t; if (tk == ',') next(); }
next();
if (d == Sys) *++e = d;
else if (d == Fun) { *++e = JSR; *++e = d; }
else { printf("%d: bad function call\n", line); exit(-1); }
if (t) { *++e = ADJ; *++e = t; }
ty = d;
}
else if (d == Num) { *++e = IMM; *++e = d; ty = INT; }
else {
if (d == Loc) { *++e = LEA; *++e = loc - d; }
else if (d == Glo) { *++e = IMM; *++e = d; }
else { printf("%d: undefined variable\n", line); exit(-1); }
*++e = ((ty = d) == CHAR) ? LC : LI;
}
}
else if (tk == '(') {
next();
if (tk == Int || tk == Char) {
t = (tk == Int) ? INT : CHAR; next();
while (tk == Mul) { next(); t = t + PTR; }
if (tk == ')') next(); else { printf("%d: bad cast\n", line); exit(-1); }
expr(Inc);
ty = t;
}
else {
expr(Assign);
if (tk == ')') next(); else { printf("%d: close paren expected\n", line); exit(-1); }
}
}
else if (tk == Mul) {
next(); expr(Inc);
if (ty > INT) ty = ty - PTR; else { printf("%d: bad dereference\n", line); exit(-1); }
*++e = (ty == CHAR) ? LC : LI;
}
else if (tk == And) {
next(); expr(Inc);
if (*e == LC || *e == LI) --e; else { printf("%d: bad address-of\n", line); exit(-1); }
ty = ty + PTR;
}
else if (tk == '!') { next(); expr(Inc); *++e = PSH; *++e = IMM; *++e = 0; *++e = EQ; ty = INT; }
else if (tk == '~') { next(); expr(Inc); *++e = PSH; *++e = IMM; *++e = -1; *++e = XOR; ty = INT; }
else if (tk == Add) { next(); expr(Inc); ty = INT; }
else if (tk == Sub) {
next(); *++e = IMM;
if (tk == Num) { *++e = -ival; next(); } else { *++e = -1; *++e = PSH; expr(Inc); *++e = MUL; }
ty = INT;
}
else if (tk == Inc || tk == Dec) {
t = tk; next(); expr(Inc);
if (*e == LC) { *e = PSH; *++e = LC; }
else if (*e == LI) { *e = PSH; *++e = LI; }
else { printf("%d: bad lvalue in pre-increment\n", line); exit(-1); }
*++e = PSH;
*++e = IMM; *++e = (ty > PTR) ? sizeof(int) : sizeof(char);
*++e = (t == Inc) ? ADD : SUB;
*++e = (ty == CHAR) ? SC : SI;
}
else { printf("%d: bad expression\n", line); exit(-1); }
while (tk >= lev) { // "precedence climbing" or "Top Down Operator Precedence" method
t = ty;
if (tk == Assign) {
next();
if (*e == LC || *e == LI) *e = PSH; else { printf("%d: bad lvalue in assignment\n", line); exit(-1); }
expr(Assign); *++e = ((ty = t) == CHAR) ? SC : SI;
}
else if (tk == Cond) {
next();
*++e = BZ; d = ++e;
expr(Assign);
if (tk == ':') next(); else { printf("%d: conditional missing colon\n", line); exit(-1); }
*d = (int)(e + 3); *++e = JMP; d = ++e;
expr(Cond);
*d = (int)(e + 1);
}
else if (tk == Lor) { next(); *++e = BNZ; d = ++e; expr(Lan); *d = (int)(e + 1); ty = INT; }
else if (tk == Lan) { next(); *++e = BZ; d = ++e; expr(Or); *d = (int)(e + 1); ty = INT; }
else if (tk == Or) { next(); *++e = PSH; expr(Xor); *++e = OR; ty = INT; }
else if (tk == Xor) { next(); *++e = PSH; expr(And); *++e = XOR; ty = INT; }
else if (tk == And) { next(); *++e = PSH; expr(Eq); *++e = AND; ty = INT; }
else if (tk == Eq) { next(); *++e = PSH; expr(Lt); *++e = EQ; ty = INT; }
else if (tk == Ne) { next(); *++e = PSH; expr(Lt); *++e = NE; ty = INT; }
else if (tk == Lt) { next(); *++e = PSH; expr(Shl); *++e = LT; ty = INT; }
else if (tk == Gt) { next(); *++e = PSH; expr(Shl); *++e = GT; ty = INT; }
else if (tk == Le) { next(); *++e = PSH; expr(Shl); *++e = LE; ty = INT; }
else if (tk == Ge) { next(); *++e = PSH; expr(Shl); *++e = GE; ty = INT; }
else if (tk == Shl) { next(); *++e = PSH; expr(Add); *++e = SHL; ty = INT; }
else if (tk == Shr) { next(); *++e = PSH; expr(Add); *++e = SHR; ty = INT; }
else if (tk == Add) {
next(); *++e = PSH; expr(Mul);
if ((ty = t) > PTR) { *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = MUL; }
*++e = ADD;
}
else if (tk == Sub) {
next(); *++e = PSH; expr(Mul);
if (t > PTR && t == ty) { *++e = SUB; *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = DIV; ty = INT; }
else if ((ty = t) > PTR) { *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = MUL; *++e = SUB; }
else *++e = SUB;
}
else if (tk == Mul) { next(); *++e = PSH; expr(Inc); *++e = MUL; ty = INT; }
else if (tk == Div) { next(); *++e = PSH; expr(Inc); *++e = DIV; ty = INT; }
else if (tk == Mod) { next(); *++e = PSH; expr(Inc); *++e = MOD; ty = INT; }
else if (tk == Inc || tk == Dec) {
if (*e == LC) { *e = PSH; *++e = LC; }
else if (*e == LI) { *e = PSH; *++e = LI; }
else { printf("%d: bad lvalue in post-increment\n", line); exit(-1); }
*++e = PSH; *++e = IMM; *++e = (ty > PTR) ? sizeof(int) : sizeof(char);
*++e = (tk == Inc) ? ADD : SUB;
*++e = (ty == CHAR) ? SC : SI;
*++e = PSH; *++e = IMM; *++e = (ty > PTR) ? sizeof(int) : sizeof(char);
*++e = (tk == Inc) ? SUB : ADD;
next();
}
else if (tk == Brak) {
next(); *++e = PSH; expr(Assign);
if (tk == ']') next(); else { printf("%d: close bracket expected\n", line); exit(-1); }
if (t > PTR) { *++e = PSH; *++e = IMM; *++e = sizeof(int); *++e = MUL; }
else if (t < PTR) { printf("%d: pointer type expected\n", line); exit(-1); }
*++e = ADD;
*++e = ((ty = t - PTR) == CHAR) ? LC : LI;
}
else { printf("%d: compiler error tk=%d\n", line, tk); exit(-1); }
}
}
void stmt()
{
int *a, *b;
if (tk == If) {
next();
if (tk == '(') next(); else { printf("%d: open paren expected\n", line); exit(-1); }
expr(Assign);
if (tk == ')') next(); else { printf("%d: close paren expected\n", line); exit(-1); }
*++e = BZ; b = ++e;
stmt();
if (tk == Else) {
*b = (int)(e + 3); *++e = JMP; b = ++e;
next();
stmt();
}
*b = (int)(e + 1);
}
else if (tk == While) {
next();
a = e + 1;
if (tk == '(') next(); else { printf("%d: open paren expected\n", line); exit(-1); }
expr(Assign);
if (tk == ')') next(); else { printf("%d: close paren expected\n", line); exit(-1); }
*++e = BZ; b = ++e;
stmt();
*++e = JMP; *++e = (int)a;
*b = (int)(e + 1);
}
else if (tk == Return) {
next();
if (tk != ';') expr(Assign);
*++e = LEV;
if (tk == ';') next(); else { printf("%d: semicolon expected\n", line); exit(-1); }
}
else if (tk == '{') {
next();
while (tk != '}') stmt();
next();
}
else if (tk == ';') {
next();
}
else {
expr(Assign);
if (tk == ';') next(); else { printf("%d: semicolon expected\n", line); exit(-1); }
}
}
int main(int argc, char **argv)
{
int fd, bt, ty, poolsz, *idmain;
int *pc, *sp, *bp, a, cycle; // VM registers
int i, *t; // Temps
--argc; ++argv;
if (argc > 0 && **argv == '-' && (*argv) == 's') { src = 1; --argc; ++argv; }
if (argc > 0 && **argv == '-' && (*argv) == 'd') { debug = 1; --argc; ++argv; }
if (argc < 1) { printf("usage: c4 file ...\n"); return -1; }
if ((fd = open(*argv, 0)) < 0) { printf("could not open(%s)\n", *argv); return -1; }
poolsz = 256 * 1024; // Arbitrary size
if (!(sym = malloc(poolsz))) { printf("could not malloc(%d) symbol area\n", poolsz); return -1; }
if (!(le = e = malloc(poolsz))) { printf("could not malloc(%d) text area\n", poolsz); return -1; }
if (!(data = malloc(poolsz))) { printf("could not malloc(%d) data area\n", poolsz); return -1; }
if (!(sp = malloc(poolsz))) { printf("could not malloc(%d) stack area\n", poolsz); return -1; }
memset(sym, 0, poolsz);
memset(e, 0, poolsz);
memset(data, 0, poolsz);
p = "char else enum if int return sizeof while "
"open read close printf malloc memset memcmp exit void main";
i = Char; while (i <= While) { next(); id = i++; } // Add keywords to symbol table
i = OPEN; while (i <= EXIT) { next(); id = Sys; id = INT; id = i++; } // Add library to symbol table
next(); id = Char; // Handle void type
next(); idmain = id; // Keep track of main
if (!(lp = p = malloc(poolsz))) { printf("could not malloc(%d) source area\n", poolsz); return -1; }
if ((i = read(fd, p, poolsz - 1)) <= 0) { printf("read() returned %d\n", i); return -1; }
p = 0;
close(fd);
// Parse declarations
line = 1;
next();
while (tk) {
bt = INT; // Basetype
if (tk == Int) next();
else if (tk == Char) { next(); bt = CHAR; }
else if (tk == Enum) {
next();
if (tk != '{') next();
if (tk == '{') {
next();
i = 0;
while (tk != '}') {
if (tk != Id) { printf("%d: bad enum identifier %d\n", line, tk); return -1; }
next();
if (tk == Assign) {
next();
if (tk != Num) { printf("%d: bad enum initializer\n", line); return -1; }
i = ival;
next();
}
id = Num; id = INT; id = i++;
if (tk == ',') next();
}
next();
}
}
while (tk != ';' && tk != '}') {
ty = bt;
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad global declaration\n", line); return -1; }
if (id) { printf("%d: duplicate global definition\n", line); return -1; }
next();
id = ty;
if (tk == '(') { // Function
id = Fun;
id = (int)(e + 1);
next(); i = 0;
while (tk != ')') {
ty = INT;
if (tk == Int) next();
else if (tk == Char) { next(); ty = CHAR; }
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad parameter declaration\n", line); return -1; }
if (id == Loc) { printf("%d: duplicate parameter definition\n", line); return -1; }
id = id; id = Loc;
id = id; id = ty;
id = id; id = i++;
next();
if (tk == ',') next();
}
next();
if (tk != '{') { printf("%d: bad function definition\n", line); return -1; }
loc = ++i;
next();
while (tk == Int || tk == Char) {
bt = (tk == Int) ? INT : CHAR;
next();
while (tk != ';') {
ty = bt;
while (tk == Mul) { next(); ty = ty + PTR; }
if (tk != Id) { printf("%d: bad local declaration\n", line); return -1; }
if (id == Loc) { printf("%d: duplicate local definition\n", line); return -1; }
id = id; id = Loc;
id = id; id = ty;
id = id; id = ++i;
next();
if (tk == ',') next();
}
next();
}
*++e = ENT; *++e = i - loc;
while (tk != '}') stmt();
*++e = LEV;
id = sym; // Unwind symbol table locals
while (id) {
if (id == Loc) {
id = id;
id = id;
id = id;
}
id = id + Idsz;
}
}
else {
id = Glo;
id = (int)data;
data = data + sizeof(int);
}
if (tk == ',') next();
}
next();
}
if (!(pc = (int *)idmain)) { printf("main() not defined\n"); return -1; }
if (src) return 0;
// Setup stack
sp = (int *)((int)sp + poolsz);
*--sp = EXIT; // Call exit if main returns
*--sp = PSH; t = sp;
*--sp = argc;
*--sp = (int)argv;
*--sp = (int)t;
// Run...
cycle = 0;
while (1) {
i = *pc++; ++cycle;
if (debug) {
printf("%d> %.4s", cycle,
&"LEA ,IMM ,JMP ,JSR ,BZ ,BNZ ,ENT ,ADJ ,LEV ,LI ,LC ,SI ,SC ,PSH ,"
"OR ,XOR ,AND ,EQ ,NE ,LT ,GT ,LE ,GE ,SHL ,SHR ,ADD ,SUB ,MUL ,DIV ,MOD ,"
"OPEN,READ,CLOS,PRTF,MALC,MSET,MCMP,EXIT,");
if (i <= ADJ) printf(" %d\n", *pc); else printf("\n");
}
if (i == LEA) a = (int)(bp + *pc++); // Load local address
else if (i == IMM) a = *pc++; // Load global address or immediate
else if (i == JMP) pc = (int *)*pc; // Jump
else if (i == JSR) { *--sp = (int)(pc + 1); pc = (int *)*pc; } // Jump to subroutine
else if (i == BZ) pc = a ? pc + 1 : (int *)*pc; // Branch if zero
else if (i == BNZ) pc = a ? (int *)*pc : pc + 1; // Branch if not zero
else if (i == ENT) { *--sp = (int)bp; bp = sp; sp = sp - *pc++; } // Enter subroutine
else if (i == ADJ) sp = sp + *pc++; // Stack adjust
else if (i == LEV) { sp = bp; bp = (int *)*sp++; pc = (int *)*sp++; } // Leave subroutine
else if (i == LI) a = *(int *)a; // Load int
else if (i == LC) a = *(char *)a; // Load char
else if (i == SI) *(int *)*sp++ = a; // Store int
else if (i == SC) a = *(char *)*sp++ = a; // Store char
else if (i == PSH) *--sp = a; // Push
else if (i == OR) a = *sp++ | a;
else if (i == XOR) a = *sp++ ^ a;
else if (i == AND) a = *sp++ & a;
else if (i == EQ) a = *sp++ == a;
else if (i == NE) a = *sp++ != a;
else if (i == LT) a = *sp++ < a;
else if (i == GT) a = *sp++ > a;
else if (i == LE) a = *sp++ <= a;
else if (i == GE) a = *sp++ >= a;
else if (i == SHL) a = *sp++ << a;
else if (i == SHR) a = *sp++ >> a;
else if (i == ADD) a = *sp++ + a;
else if (i == SUB) a = *sp++ - a;
else if (i == MUL) a = *sp++ * a;
else if (i == DIV) a = *sp++ / a;
else if (i == MOD) a = *sp++ % a;
else if (i == OPEN) a = open((char *)sp, *sp);
else if (i == READ) a = read(sp, (char *)sp, *sp);
else if (i == CLOS) a = close(*sp);
else if (i == PRTF) { t = sp + pc; a = printf((char *)t, t, t, t, t, t); }
else if (i == MALC) a = (int)malloc(*sp);
else if (i == MSET) a = (int)memset((char *)sp, sp, *sp);
else if (i == MCMP) a = memcmp((char *)sp, (char *)sp, *sp);
else if (i == EXIT) { printf("exit(%d) cycle = %d\n", *sp, cycle); return *sp; }
else { printf("unknown instruction = %d! cycle = %d\n", i, cycle); return -1; }
}
}
Last edited by zzz19760225 on 2016-12-4 at 00:33 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:37 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
|
2016-6-26 18:38 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
习语言 编辑
习语言即中文版的C语言,确切的说是支持中文代码的C语言的超集,由一套完备的编程语法和相配套的工具组成。
中文名 习语言 外文名 The Learn Programming Language 文件扩展名 习、接口
目录
1 简介
2 简单例子
3 各版本
4 获取途径
5 系列作品
简介编辑
习语言即中文版的C语言,由一套完备的编程语法和相配套的工具组成,旨在将编程大众化,普及化,中文化。适合作为初学者的入门学习工具。
作为一种中文编程语言,习语言中所有的关键字和函数都为中文。习语言已经完全支持汇编和C语言,并向windows图形处理发展。
历史经验证明,英文写的代码时间久了大部分都会遗忘的。而习语言则避免了这一点,中文浏览下就可以回忆起来,真正符合汉语特色。而且支持全角标点符号,编程时输入符号不用频繁切换。
中文C(习)语言中文编程系统(简称:习语言):是一款主要用于教育和学习的中文编程软件系统。基于现有C语言系统实现并有扩充。其特点如下:
1、完全支持全中文编程,代码全中文,文件名全中文。
2、综合了PASCAL和C的优点实现,支持 “开始”“结束”扩起语句块。支持更多注释方法,方便程序组织。
3、支持多字节字直观表示。如 '我', 'abcd'都可以作为字(符).
4、支持中文标点符号,中文标点符号和英文标点符号混合使用等。
5、支持文章式的程序组织,在中文文章中嵌入程序代码,直接编译。
6、支持中文文字运算符,支持全角,半角混合使用。
7、体积小巧,很少的接口文件,使用理解容易。
用途:使用中文编写 C语言程序及基于C语言的操作系统
简单例子编辑
下面是一个简单的视窗例子,让大家体会习语言的魅力:
#包含 “习语言系统.接口”
#包含 “习语言视窗.接口”
【 主程序 】
整数类型主函数( 整数类型 参数个数, 字符类型 *参数表)
{
图形初始化显示器( 空指针,320, 240,空指针, 0, 空指针);
图形打开显示器();
图形输出文字(10, 30 ,“春眠不觉晓,处处闻啼鸟!”);
图形输出文字(10, 200 ,“按任意键退出”);
获取按键();
图形关闭显示器();
返回 0;
}
效果图:
各版本编辑
简介
习语言4715-3.6版
习语言4714版
习语言2014版
历史修订:
习语言3.6 修订
1、优化习库,改进对多窗口绘图的支持。
2、优化习语言编辑器,支持快捷键CTRL+F8,CTRL+F9对项目或无项目时当前文件进行编译和运行。
3、支持F8,F9快捷键前后翻看输出内容。
4、增加和习姐的协作,可以在习语言编辑器里编写习姐语句,直接发送给习姐运行。
5、习库中增加对简繁体数字的识别和处理及苏州码子等数字的识别和处理函数。
习语言3.5 修订
1、支持 如果...就...;或者...就...;否则... 这样的逻辑表达方式。
2、支持 重复...直到...; 这样的逻辑表达方式。
3、支持 重复...当...; 这样的逻辑表达方式。
4、支持 当...重复...; 这样的逻辑表达方式。
5、支持 检查...{若等于…}; 这样的分支语句表达方式。
6、改进习语言编辑器,支持动态增加自定义词汇和语句(选中文本,右键菜单中:追加->添加到词汇表中; 追加->添加到快捷词语表中)。
7、修复编译器对 无类型 甲; 无类型 *猫; 甲=*猫; 类似这样的程序语句的处理异常。
8、在习语言编辑器环境中支持文件编译选项设置。
9、支持项目编译设置和整个项目编译。
10、支持编译时直接编译文件相关的素材文件。
11、完善 简易习 支持。
习语言3.4 修订
1、调整习语言编辑器工具栏,修正菜单中发现的问题。
2、变量、字母、类型、运算符工具栏可以配置关闭(体验版不支持关闭)。
3、增加对语法:“如果...就...”的支持。
习语言3.3 修订
1、完善编译设置的支持,进“项目”菜单选“设置...”选项可以设置文件的编译选项。
2、习语言编辑器格式对话框修改扩充,增加常用词语输入。
3、根据习语言2016版反馈,完善侧边栏内容。
4、修正函数无需参数,实际传入1个参数不报错的问题。
5、完善图形编程相关函数。
习语言3.2 修订
1、简易习代码支持完善。
2、习语言编辑器完善
3、侧边栏词汇表整理完善,目前分类更清晰易懂。
习语言3.1 修订
1、修复数组指针编译出错问题:
整数 (*数);
整数 符 = {1,2,3,4,5 }, 小明;
数 = &符;
小明 = (*数);
2、完善 串口函数,更方便串口编程。
3、改进 别名 处理,修复结构类型中指针成员定义使用别名时的编译报错问题。
4、改进 数组 处理,修复数组用区间定义时初始化不正确的问题。 如:
整数类型 月份天数 = {31,28,31,30};
5、整理改进侧边栏词汇表中视窗函数的组织,归类更清晰。
6、重新编译生成整个编译器,解决360误报问题。
7、支持二进制常数表示,其表示方法为: 0b101101 、0B101101 、0二101101、 101101b、 101101B、101101二。 这六种表示方法都可以,效果相同。
习语言3.0 修订
1、增加串口操作函数,支持简易的串口通讯编程。
2、其他已知问题完善。
习语言2.9 修订
1、修改 输入字符串 函数的实现代码,修正WIN10平台使用时的异常问题。
2、编辑区选定词汇后,在右键菜单中增加快捷搜索功能。
习语言2.8 修订
1、完善词汇提示。
2、修正格式输出对 %词 的处理。
3、完善习语言编辑器,缺省打开侧边栏。
习语言2.71 修订
1、增加 图形模式文件打开 函数。
2、完善程序退出处理。
3、完善习语言编辑器,缺省打开侧边栏。
习语言2.7 修订
1、增加完善图形处理函数。
2、修正编译器处理复杂乘除运算式时的一个错误。
3、增加几个时间函数,归类整理侧边栏函数。
习语言2.61 修订
1、增加对话框控件操作函数。
2、优化视窗函数列表。
3、增加新对话框程序支持。
4、新增程序模板。
习语言2.6 修订
1、修正商业版发布不完整的问题.
2、完善习语言编辑器,增加输出窗口行数限制。
3、完善环境配置和示例程序。
4、商业版更好的支持VC头文件和库。
5、增加预处理指令。
习语言2.5 修订
1、整理完善图形函数,优化图形驱动.
2、增加控制台打开关闭、图形暂停、三角形绘图、漫水填充等函数。
3、整理优化函数分类和提示信息。
4、整理实现更多程序模板。
5、增加消息处理宏,实现消息处理框架。
习语言2.4 修订
1、改进习语言编辑器多文件搜索处理,输出信息前后浏览,编辑位置回退浏览和前进。
2、完善图形刷新显示函数,刷新的同时,刷新界面显示,处理所有待处理事件消息。
3、完善部分函数的注释信息,更易懂清晰。
4、增加 控制台设置文本颜色 函数。
5、增加对 windows.h 接口文件的支持,可以编译运行原始 WIN32代码,也可以中英混编。
6、优化习语言编译器,出错信息更方便定位。
习语言2.3 修订
1、更改函数名 文件结束 为 文件已结束, 文件出错 为 文件已出错。
2、完善部分函数的解释。
3、完善动态库导出函数的处理,实现全中文支持。
4、完善习语言编辑器,支持版本信息中显示启动路径,方便多版本并存时区分运行的哪个版本。
习语言2.2 修订
1、修正2.1版本发现的视窗程序用控制台编译链接后运行出错的问题。
习语言2.1 修订
1、完善 习语言编辑器,在帮助-版本信息窗口中,按关联右键之后,习语言编辑器自动和.习文件关联,可以双击打开。
2、完善 系统函数、接口文件,函数提示内容。
习语言2.02 修订
1、完善 指针表函数。
2、完善 内存操作函数,变分配为申请,因从程序角度看,是申请内存,从内存管理角度看,才是分配。
3、完善 习语言编辑器的前后定位功能(前一位置,后一位置 的功能)。
习语言2.01 修订
1、完善 习语言.exe ,增强对编译汇编代码时,各种不同命令行参数的容错处理能力。
2、修改richedit的处理,支持richedit。
习语言2.0 修订
1、完善绘图功能。
2、完善习语言编辑器,支持函数全称显示,支持中文符号,汉字多行列输入。
3、完善系统函数、类型、宏。
4、集成了习语言使用教程
5、集成VC6连接器
6、增加“俄罗斯方块和贪食蛇源代码”
7、增加花心萝卜的可视化IDE及其视频教程
习语言1.86.1 修订
1、完善国标字符串函数对字符的容错处理。
2、修改习语言编译器对宽字符的支持方法。
3、美化系统图标
习语言1.86 修订
1、完善视窗函数列表。
2、完善习语言编辑器,运行命令支持快捷键。
习语言1.85.9 修订
1、完善系统函数列表。
2、完善习语言编辑器。
习语言1.85.8 修订
1、完善系统函数。废弃1.85.6之前的所有1.85分支版本。
2、完善侧边栏词汇提示
3、更新"习语言.exe",支持“编译.设置”文件。
4、优化对资源的支持,增加对菜单的支持。
5、优化习语言编辑器,支持新文件保存路径记忆。
6、完善控件式样风格。
习语言1.85.6 修订
1、修复1.85版在系统库函数中引入的一个内存访问异常问题。废弃1.85.6之前的最近几个1.85分支版本。
2、整理完善习语言图形、视窗函数,对函数列表进行分类整理。 更改部分函数名。
3、完善图形处理接口函数,支持绘制无背景的图片,支持保存内容为图片。
4、完善习语言编辑器。
习语言1.85.5 修订
1、完善习语言编译器,支持 #编译指令 对齐(入栈 , 2)
2、完善习语言编辑器。
3、整理完善习语言图形视窗词库及接口。
习语言1.85 修订
1、整理完善国标字符串函数。
2、完善图形格式输入函数。
3、优化提示词库
4、优化习语言编辑器侧边栏词汇自动输入功能,提供是否带提示的可选项。
5、优化习语言编译器,增加对关键词:检查、加载 的支持。
6、优化整理时间相关函数。
7、修正完善链表函数、扩充图形输入串的功能。
习语言1.82 修订
1、完善习语言编辑器词汇提示功能。
2、完善提示词库。
3、优化系统库函数
4、支持一种更简单的图形编程。
习语言1.80 修订
1、去除侧边栏自动输入词汇中的注释。
2、完善快捷输入功能。
3、优化习标准库,缩小可执行程序大小
习语言1.78 修订
1、支持首拼快捷输入
2、增加少量函数
3、完善侧边栏词汇
习语言1.76 修订
1、支持PASCAL赋值运算符
2、支持从1开始的数组表示语法
3、完善系统函数
习语言1.75 修订
1、增加多输出窗口。
2、改善函数帮助显示。
3、变量名 支持GB18030字符(早期版本支持 GB2312)。
4、支持DLL隐式调用(商业版才支持)。
习语言1.72版 修订
1、扩充部分实用函数。
2、支持图片直接显示和声音播放等多媒体接口。
习语言1.71版 修订
1、增加动态库函数声明调用宏,简化动态库访问。
2、解决上一版本发现的小数类型在输入时的错误问题。
3、增加图形格式输出和图形输入功能,方便将所有控制台程序迁移为图形程序。
4、优化视窗函数,新增大量视窗函数,更方便绘制各种控件,方便视窗程序的编写。
5、在编辑器环境中增加资源的支持。
习语言1.70版 修订
1、完善编译环境,用习语言写的工具代替原来的批处理。
2、支持动态指针数组,链表,完善文件名处理。
3、优化编辑器,适应中文状态下输入英文符号。
4、完善词汇函数表,点击可实现多行代码输入。
5、支持函数别名,支持中文句号作为语句结束。
6、完善习语言程序设计文档。
习语言1.69版 修订
1、完善编译器,增加纯汇编代码生成功能, 应xl-os开发需求增加。
2、在编辑器中增加习语言词汇树,实现快速添加词汇到编辑区。
习语言1.68版 修订
1、完善编译器,优化代码生成
2、完善条目有点多,省略...。
习语言1.66版 修订
1、微调运算符优先级 更符合思维习惯。
2、修正浮点初始化为负数时处理错误。
3、根据最新版本的更改更正视窗示例。
习语言1.65版 修订
1、继续完善浮点处理问题。
2、严格函数调用,不再允许未声明直接调用函数。
习语言1.62版 修订
1、修正浮点处理问题。
2、增加main函数名支持
3、完善中文提示。
4、支持C代码直接编译
习语言1.6版 修订
1、完善 标准调用 和 C调用的处理
2、修正浮点运算错误
3、增加中文命令
4、增加C和习语言相互转换的命令。
习语言 1.5版 修订
1、更新习语言编辑器, 增加在开始运行时提示打开或新建。
2、整理系统函数接口定义,完善函数注释。
统一将文件读写函数的文件句柄放为第一个参数,
统一读字符为读取单字节英文字符,读字为读单字节英文字符或汉字。
3、支持文件打开和保存函数、支持对话框创建, 控件创建等图形编程。
4、修正中汇几个错误。
总结下阶段成果:
1、完成支持全中文的习语言, 生成全中文编写汇编代码(X86)。
2、完成支持全中文汇编(X86)的汇编器。生成兼容微软格式的目标代码。用微软的连接工具连接可生成WINDOWS上的控制台程序和视窗程序。
3、完成全中文标准习语言函数库。可以支持基础的控制台和图形编程。
4、完成支持全中文构建指导书(等效makefile )的构建工具(等效make )
5、完成支持中文语法高亮的编辑器,可以支持习语言源程序和构建指导书的语法高亮和编辑。及习语言源程序的集成编译。
6、完成习语言基础教程。
正在进行的工作:
1、开发习语言相关配套工具。
1.4版在易用性上有很大提高, 解决了一些发现的问题。
已经有1.5版,支持windows图形设计。
截止 2012年5月 最新版是 1.76
可以通过 添加函数库的方式 兼容c/c++
不过 在使用上需要 注意几点就是 先进行 编译 然后运行 并且 控制台程序 和 图形模式的 编译方式不同 需要 分别点 两个不同的 编译按钮 左侧的是控制台按钮 右侧的是 图形模式编译按钮 通行模式编译按钮 是 运行 然后是 带参数的运行再就是 运行捕获 (会在下方的输出面板上面显示 程序运行的时候输出的文字内容)
正在开发 直接点运行 自动进行 编译并且运行的 功能
获取途径编辑
习语言1.82版可以在各大下载网站下载,百度搜索“习语言 下载”即可获取下载链接,也可通过论坛、微群、做相关的任务获取。
系列作品编辑
习语言——C语言中文扩展库
习佳佳——中文C++开发伴侣
习丽妞——linux系统下编程的中文扩展库
习51——51单片机中文开发伴侣
中汇——中文X86汇编
中文构建工具(汉化版的make工具)
Last edited by zzz19760225 on 2017-6-12 at 01:37 ]
Learn Programming Language Editor
Learn Programming Language is a Chinese version of the C language, specifically a superset of C language that supports Chinese code. It consists of a complete set of programming syntax and supporting tools.
Chinese Name: 习语言 (Xi Yu Yan)
English Name: The Learn Programming Language
File Extensions: 习, 接口 (Xi, Jie Kou)
Table of Contents
1. Introduction
2. Simple Examples
3. Versions
4. Acquisition Methods
5. Series Works
Introduction Editing
Learn Programming Language is a Chinese version of the C language, consisting of a complete set of programming syntax and supporting tools. It aims to popularize programming, make it more accessible, and localize it in Chinese. It is suitable as an entry-level learning tool for beginners.
As a Chinese programming language, all keywords and functions in Learn Programming Language are in Chinese. Learn Programming Language has fully supported assembly and C language and is developing towards Windows graphics processing.
Historical experience has shown that most code written in English will be forgotten over time. However, Learn Programming Language avoids this problem. Code can be recalled by browsing in Chinese, which truly fits the characteristics of the Chinese language. It also supports full-width punctuation marks, so there is no need to frequently switch when entering symbols during programming.
Chinese C (Learn) Language Chinese Programming System (referred to as: Learn Programming Language): is a Chinese programming software system mainly used for education and learning. It is implemented based on the existing C language system with expansions. The characteristics are as follows:
1. Fully supports all-Chinese programming, with all code in Chinese and all filenames in Chinese.
2. Integrated the advantages of PASCAL and C, supporting statement blocks enclosed by "开始" ("Start") and "结束" ("End"). Supports more comment methods, facilitating program organization.
3. Supports intuitive representation of multi-byte characters. For example, '我' ('I'), 'abcd' can both be used as characters.
4. Supports Chinese punctuation marks, and mixed use of Chinese and English punctuation marks, etc.
5. Supports program organization in an article-like manner, embedding program code directly in a Chinese article for compilation.
6. Supports Chinese character operators and mixed use of full-width and half-width characters.
7. Small in size, with very few interface files, easy to understand and use.
Purpose: Use Chinese to write C language programs and C language-based operating systems.
Simple Examples Editing
The following is a simple window example to experience the charm of Learn Programming Language:
#Include "习语言系统.接口" ("Xi Yu Yan System. Interface")
#Include "习语言视窗.接口" ("Xi Yu Yan Window. Interface")
【 主程序 】 ("Main Program")
Integer Type Main Function (Integer Type Parameter Count, Character Type *Parameter List)
{
Graphics Initialize Display (Null Pointer, 320, 240, Null Pointer, 0, Null Pointer);
Graphics Open Display();
Graphics Output Text (10, 30, "春眠不觉晓,处处闻啼鸟!" ("Spring sleep, I don't wake up, everywhere I hear birds singing!"));
Graphics Output Text (10, 200, "按任意键退出" ("Press any key to exit"));
Get Key();
Graphics Close Display();
Return 0;
}
Effect Picture:
Versions Editing
Introduction
Learn Programming Language Version 4715-3.6
Learn Programming Language Version 4714
Learn Programming Language Version 2014
Historical Revisions:
Learn Programming Language 3.6 Revision
1. Optimize the Learn library and improve support for multi-window drawing.
2. Optimize the Learn Programming Language editor, supporting shortcuts CTRL+F8, CTRL+F9 to compile and run the current file with or without a project.
3. Support F8, F9 shortcuts to view the output content back and forth.
4. Increase collaboration with Xi Jie, allowing writing Xi Jie statements in the Learn Programming Language editor and directly sending them to Xi Jie for running.
5. Add functions in the Learn library to recognize and process simplified and traditional Chinese numbers, as well as Suzhou numerals, etc.
Learn Programming Language 3.5 Revision
1. Support logical expressions such as "如果...就..." ("If... then..."), "或者...就..." ("Or... then..."), "否则..." ("Else...").
2. Support logical expressions such as "重复...直到..." ("Repeat... until...").
3. Support logical expressions such as "重复...当..." ("Repeat... while...").
4. Support logical expressions such as "当...重复..." ("While... repeat...").
5. Support branch statement expressions such as "检查...{若等于…}" ("Check... {If equal to...}").
6. Improve the Learn Programming Language editor, supporting dynamically adding custom vocabulary and statements (select text, right-click menu: Append -> Add to Vocabulary; Append -> Add to Quick Phrase List).
7. Fix the abnormal processing of the compiler for program statements like "无类型 甲;" ("No type Jia;"), "无类型 *猫;" ("No type *Mao;"), "甲=*猫;" ("Jia=*Mao;").
8. Support file compilation option settings in the Learn Programming Language editor environment.
9. Support project compilation settings and compile the entire project.
10. Support compiling the material files related to the file directly during compilation.
11. Improve support for Simple Learn.
Learn Programming Language 3.4 Revision
1. Adjust the toolbar of the Learn Programming Language editor and fix the problems found in the menu.
2. The variable, letter, type, and operator toolbars can be configured to be closed (not supported in the trial version).
3. Add support for the syntax "如果...就..." ("If... then...").
Learn Programming Language 3.3 Revision
1. Improve support for compilation settings. Select "Settings..." in the "Project" menu to set the compilation options of the file.
2. Modify and expand the format dialog of the Learn Programming Language editor, adding common word input.
3. Improve the sidebar content according to the feedback of Learn Programming Language 2016 version.
4. Fix the problem that no error is reported when a function has no parameters but 1 parameter is actually passed.
5. Improve the graphics programming-related functions.
Learn Programming Language 3.2 Revision
1. Improve the support for Simple Learn code.
2. Improve the Learn Programming Language editor.
3. Organize and improve the vocabulary list in the sidebar, and the classification is currently clearer and easier to understand.
Learn Programming Language 3.1 Revision
1. Fix the array pointer compilation error problem:
Integer (*数);
Integer 符 = {1,2,3,4,5 }, 小明;
数 = &符;
小明 = (*数);
2. Improve the serial port function, making serial port programming more convenient.
3. Improve the alias processing, and fix the compilation error problem when using an alias in the definition of a pointer member in a structure type.
4. Improve the array processing, and fix the problem that the initialization is incorrect when the array is defined using an interval. For example:
Integer Type 月份天数 = {31,28,31,30};
5. Organize and improve the organization of window functions in the sidebar vocabulary list, and the classification is clearer.
6. Recompile and generate the entire compiler to solve the 360 false positive problem.
7. Support binary constant representation, and its representation methods are: 0b101101, 0B101101, 0二101101, 101101b, 101101B, 101101二. All six representation methods are acceptable and have the same effect.
Learn Programming Language 3.0 Revision
1. Add serial port operation functions to support simple serial port communication programming.
2. Improve other known problems.
Learn Programming Language 2.9 Revision
1. Modify the implementation code of the input string function and fix the abnormal problem when using it on the WIN10 platform.
2. After selecting a vocabulary in the editing area, add a quick search function in the right-click menu.
Learn Programming Language 2.8 Revision
1. Improve vocabulary hints.
2. Fix the processing of %词 in the format output.
3. Improve the Learn Programming Language editor, and the sidebar is opened by default.
Learn Programming Language 2.71 Revision
1. Add the graphic mode file opening function.
2. Improve the program exit processing.
3. Improve the Learn Programming Language editor, and the sidebar is opened by default.
Learn Programming Language 2.7 Revision
1. Add and improve graphic processing functions.
2. Fix an error when the compiler processes complex multiplication and division expressions.
3. Add several time functions and classify and organize the functions in the sidebar.
Learn Programming Language 2.61 Revision
1. Add dialog box control operation functions.
2. Optimize the window function list.
3. Add support for new dialog box programs.
4. Add new program templates.
Learn Programming Language 2.6 Revision
1. Fix the problem of incomplete commercial version release.
2. Improve the Learn Programming Language editor and add the line limit for the output window.
3. Improve the environment configuration and sample programs.
4. The commercial version better supports VC header files and libraries.
5. Add preprocessing instructions.
Learn Programming Language 2.5 Revision
1. Organize and improve graphic functions and optimize the graphic driver.
2. Add functions such as console opening and closing, graphic pause, triangle drawing, flood fill, etc.
3. Organize and optimize function classification and prompt information.
4. Organize and implement more program templates.
5. Add message processing macros to implement a message processing framework.
Learn Programming Language 2.4 Revision
1. Improve the multi-file search processing in the Learn Programming Language editor, browse the output information back and forth, and backtrack and forward the edit position.
2. Improve the graphic refresh display function. While refreshing, refresh the interface display and process all pending event messages.
3. Improve the comment information of some functions, making it more understandable and clear.
4. Add the function "控制台设置文本颜色" ("Console Set Text Color").
5. Support the interface file of windows.h, allowing compilation and running of original WIN32 code, as well as mixed Chinese and English compilation.
6. Optimize the Learn Programming Language compiler, and the error information is more convenient to locate.
Learn Programming Language 2.3 Revision
1. Change the function name "文件结束" ("File End") to "文件已结束" ("File Has Ended"), and "文件出错" ("File Error") to "文件已出错" ("File Has Errored").
2. Improve the explanation of some functions.
3. Improve the processing of dynamic library export functions to achieve full Chinese support.
4. Improve the Learn Programming Language editor, support displaying the startup path in the version information, facilitating distinguishing which version is running when multiple versions coexist.
Learn Programming Language 2.2 Revision
1. Fix the problem that the window program compiled and linked with the console in version 2.1 runs incorrectly.
Learn Programming Language 2.1 Revision
1. Improve the Learn Programming Language editor. After right-clicking in the Help - Version Information window, the Learn Programming Language editor is automatically associated with.习 files and can be double-clicked to open.
2. Improve the system functions and interface files, and the function prompt content.
Learn Programming Language 2.02 Revision
1. Improve the pointer table function.
2. Improve the memory operation function, change allocation to application, because from the program perspective, it is applying for memory, and from the memory management perspective, it is allocation.
3. Improve the back and forth positioning function of the Learn Programming Language editor (the functions of previous position and next position).
Learn Programming Language 2.01 Revision
1. Improve 习语言.exe, enhancing the fault tolerance for various different command line parameters when compiling assembly code.
2. Modify the processing of richedit to support richedit.
Learn Programming Language 2.0 Revision
1. Improve the drawing function.
2. Improve the Learn Programming Language editor, support full function name display, support Chinese symbols, and multi-line input of Chinese characters.
3. Improve system functions, types, and macros.
4. Integrate the Learn Programming Language usage tutorial.
5. Integrate the VC6 linker.
6. Add "Tetris and Snake source code".
7. Add the visual IDE of Hua Xin Luo Bo and its video tutorial.
Learn Programming Language 1.86.1 Revision
1. Improve the fault tolerance of the national standard string function for characters.
2. Modify the method of the Learn Programming Language compiler to support wide characters.
3. Beautify the system icon.
Learn Programming Language 1.86 Revision
1. Improve the window function list.
2. Improve the Learn Programming Language editor, and the run command supports shortcuts.
Learn Programming Language 1.85.9 Revision
1. Improve the system function list.
2. Improve the Learn Programming Language editor.
Learn Programming Language 1.85.8 Revision
1. Improve the system function. Discard all 1.85 branch versions before 1.85.6.
2. Improve the sidebar vocabulary hint.
3. Update "习语言.exe" to support the "编译.设置" ("Compile.Settings") file.
4. Optimize support for resources and add support for menus.
5. Optimize the Learn Programming Language editor to support the memory of the new file save path.
6. Improve the control style.
Learn Programming Language 1.85.6 Revision
1. Fix a memory access exception problem introduced in the system library function in version 1.85. Discard the last few 1.85 branch versions before 1.85.6.
2. Organize and improve the graphics and window functions of Learn Programming Language, and classify and organize the function list. Change some function names.
3. Improve the graphic processing interface function, support drawing pictures without a background, and support saving the content as a picture.
4. Improve the Learn Programming Language editor.
Learn Programming Language 1.85.5 Revision
1. Improve the Learn Programming Language compiler to support #编译指令 对齐(入栈, 2) ("#Compile Directive Align(Enter Stack, 2)").
2. Improve the Learn Programming Language editor.
3. Organize and improve the graphics and window word library and interface of Learn Programming Language.
Learn Programming Language 1.85 Revision
1. Organize and improve the national standard string function.
2. Improve the graphic format input function.
3. Optimize the hint word library.
4. Optimize the sidebar vocabulary automatic input function of the Learn Programming Language editor, providing an optional option of whether to have hints.
5. Optimize the Learn Programming Language compiler and add support for keywords: 检查 ("Check"), 加载 ("Load").
6. Optimize and organize time-related functions.
7. Correct and improve the linked list function and expand the function of graphic input string.
Learn Programming Language 1.82 Revision
1. Improve the vocabulary hint function of the Learn Programming Language editor.
2. Improve the hint word library.
3. Optimize the system library function.
4. Support a simpler graphic programming.
Learn Programming Language 1.80 Revision
1. Remove the comments in the automatically input vocabulary in the sidebar.
2. Improve the quick input function.
3. Optimize the Learn standard library and reduce the size of the executable program.
Learn Programming Language 1.78 Revision
1. Support first letter abbreviation quick input.
2. Add a small number of functions.
3. Improve the sidebar vocabulary.
Learn Programming Language 1.76 Revision
1. Support PASCAL assignment operator.
2. Support array representation syntax starting from 1.
3. Improve the system function.
Learn Programming Language 1.75 Revision
1. Add multiple output windows.
2. Improve the function help display.
3. Variable names support GB18030 characters (early versions supported GB2312).
4. Support DLL implicit call (only supported in the commercial version).
Learn Programming Language Version 1.72 Revision
1. Expand some practical functions.
2. Support multimedia interfaces such as direct picture display and sound playback.
Learn Programming Language Version 1.71 Revision
1. Add dynamic library function declaration call macros to simplify dynamic library access.
2. Solve the decimal type input error problem found in the previous version.
3. Add graphic format output and graphic input functions, facilitating migrating all console programs to graphic programs.
4. Optimize the window function, add a large number of window functions, making it more convenient to draw various controls and facilitating the writing of window programs.
5. Add support for resources in the editor environment.
Learn Programming Language Version 1.70 Revision
1. Improve the compilation environment, using tools written in Learn Programming Language to replace the original batch processing.
2. Support dynamic pointer arrays and linked lists, and improve filename processing.
3. Optimize the editor to adapt to entering English symbols in Chinese state.
4. Improve the vocabulary function list, and clicking can realize multi-line code input.
5. Support function aliases and support Chinese periods as statement endings.
6. Improve the Learn Programming Language program design document.
Learn Programming Language Version 1.69 Revision
1. Improve the compiler and add the pure assembly code generation function, added in response to the development needs of xl-os.
2. Add a Learn Programming Language vocabulary tree in the editor to realize quickly adding vocabulary to the editing area.
Learn Programming Language Version 1.68 Revision
1. Improve the compiler and optimize code generation.
2. The entries are a bit many, omitted...
Learn Programming Language Version 1.66 Revision
1. Fine-tune the operator precedence to be more in line with thinking habits.
2. Fix the error in handling when the floating point is initialized as a negative number.
3. Correct the window example according to the changes of the latest version.
Learn Programming Language Version 1.65 Revision
1. Continue to improve the floating point processing problem.
2. Strictly function calls, no longer allowing direct call of functions without declaration.
Learn Programming Language Version 1.62 Revision
1. Fix the floating point processing problem.
2. Add support for the main function name.
3. Improve Chinese prompts.
4. Support direct compilation of C code.
Learn Programming Language Version 1.6 Revision
1. Improve the processing of standard call and C call.
2. Fix the floating point operation error.
3. Add Chinese commands.
4. Add commands for mutual conversion between C and Learn Programming Language.
Learn Programming Language Version 1.5 Revision
1. Update the Learn Programming Language editor, adding a prompt to open or create a new one when starting to run.
2. Organize the system function interface definition and improve the function comments.
Uniformly place the file handle of the file reading and writing function as the first parameter.
Uniformly read character as reading a single-byte English character, and read word as reading a single-byte English character or Chinese character.
3. Support file opening and saving functions, support dialog box creation, control creation, etc., for graphic programming.
4. Correct a few errors in Zhonghui.
Summary of the results of the next stage:
1. Complete Learn Programming Language that supports all Chinese, generating all-Chinese written assembly code (X86).
2. Complete an assembler that supports all-Chinese assembly (X86). Generate object code compatible with Microsoft format. Connecting with Microsoft's linker can generate console programs and window programs on WINDOWS.
3. Complete the all-Chinese standard Learn Programming Language function library. Can support basic console and graphic programming.
4. Complete a build tool (equivalent to make) that supports all-Chinese construction instructions (equivalent to makefile).
5. Complete an editor that supports Chinese syntax highlighting, can support syntax highlighting and editing of Learn Programming Language source programs and construction instructions, and integrated compilation of Learn Programming Language source programs.
6. Complete the basic tutorial of Learn Programming Language.
Ongoing work:
1. Develop supporting tools related to Learn Programming Language.
Version 1.4 has greatly improved in ease of use and solved some discovered problems.
There is already version 1.5, which supports Windows graphic design.
As of May 2012, the latest version is 1.76.
It can be compatible with c/c++ by adding the function library.
However, there are a few points to note when using it: first compile and then run, and the compilation methods of console programs and graphic modes are different. You need to click two different compile buttons respectively. The left one is the console button, and the right one is the graphic mode compile button. The general mode compile button is Run, then Run with parameters, and then Run Capture (the text output when the program runs will be displayed above the output panel below).
Currently developing the function of automatically compiling and running directly by clicking Run.
Acquisition Methods Editing
Learn Programming Language Version 1.82 can be downloaded on major download websites. Search "习语言 下载" ("Learn Programming Language Download") on Baidu to obtain the download link, and it can also be obtained through forums, WeChat groups, and doing related tasks.
Series Works Editing
Learn Programming Language - Chinese Extension Library for C Language
Xi Jiajia - Chinese C++ Development Companion
Xi Lini - Chinese Extension Library for Programming under the Linux System
Xi 51 - Chinese Development Companion for 51 Single-Chip Microcomputer
Zhonghui - Chinese X86 Assembly
Chinese Build Tool (Chinese Version of the make Tool)
Last edited by zzz19760225 on 2017-6-12 at 01:37 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:38 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
linux gcc
dos Turbo C
工具只是装备一件武器,使用武器和寻找武器实现方向的人,是一体的。
计算机术语
同义词
收藏
分享
tc
编辑词条
外文名 Turbo C
属于 计算机术语
目
录
1基本内容
2功能介绍
3其他术语
1 基本内容 编辑
Turbo C 集成开发环境是由Borland 公司开发的一套C 语言开发工具,它集成了程序编辑、调试、链接等多种功能。在DOS 系统时代,Turbo C 是被最广泛使用的一种PC 机应用程序开发工具,很多应用软件均是由Turbo C 开发完成。随着计算机及其软件的发展,操作系统已经从DOS 发展到Windows。Windows 系统下的大部分应用软件已经不再使用Turbo C来开发,但是作为一种非常优秀 C 程序开发工具,其依然是一种学习 C 程序设计的理想工具。下面主要介绍广泛使用的2.0 版本。
2 功能介绍 编辑
Turbo C 集成开发环境主要提供如下功能:
1. 文件管理功能
Turbo C 提供了源程序文件的建立、保存、关闭和打开等基本功能。利用这些功能,可以完成C 程序文件从建立到保存,以及打开的一些系列操作。
2. 编辑功能
Turbo C 主要提供了文本的选定、插入、删除和查找等基本编辑功能。
3. 编译/链接功能
所有的C 语言源程序以文本(ASCII )形式存放,必须经过语法分析、检查,并翻译后才可以形成计算机可以识别的二进制指令,一般将编译后的程序称为目标代码。在程序设计过程经常用到函数库,因此一般是在将目标代码和函数库中目标代码链接之后才真正形成计算机可以识别的二进制指令程序。
4. 运行/调试功能
在程序设计过程中,难免会出现一些错误,因此必须经过运行验证后,才可以交付使用。在编译阶段主要是语法分析并检查错误,而运行阶段主要检查程序逻辑上的错误。为了方便检查程序上的逻辑错误,一般的编译器均提供了调试功能从而跟踪程序的运行过程和状态。Turbo C 主要提供了单步执行、跟踪、断点管理和表达式计算等功能。
5. 项目管理功能
在软件开发的过程,一个软件可能需要多人编辑成百上千的程序文件,形成几十万行以上的代码。管理如此大规模的软件开发,必须通过项目管理来实现。Turbo C 提供的项目管理功能,主要是代码的编译和链接控制。
6. 系统设置与帮助
为了保证系统正常的运行,设置编译链接等参数的,Turbo C 提供了相关的系统参数设置功能。另外,为了帮助初学者掌握Turbo C 的使用,系统提供了丰富的帮助信息。获得帮助信息的主要方法是在需要帮助的时候,按下功能键F1。
3 其他术语 编辑
TC(Transmission Convergence)传输会聚子层。提供与ATM层的统一接口。
TC,TurboCache的简写nVidia的TurboCache(简称TC)技术在构建新一代产品的性价比上,具有非常的意义,在兼顾成本的前提下,提供了最新的GPU架构和各项前瞻性应用。TurboCache是专利型硬件和软件技术,TurboCache抓住了新、旧总线换代的时机,将PCI-Express带宽优势进行了淋漓尽致的发挥。
TC, Traffic Control的简写是linux进行流量控制的工具, 通过tc, 可以控制网络接口收发数据的速率。
TC,Total Commander的缩写Total Commander,简称TC,原名Windows Commander,功能强大的全能文件管理器。
TC, TopCoder 的缩写TopCoder这个网站可以说是一个程序设计比赛的网站,但是在题型,比赛形式跟ACM/ICPC极不相同。该网站把中国纳入其赛区,大家可以上去那里跟来自全世界的程序员(事实上大多数也是大学生)进行更直接的交流,可能也是ACM/ICPC练兵的好地方吧。
Thin Client的缩写瘦客户机(Thin Client)是使用专业嵌入式处理器、小型本地闪存、精简版操作系统的基于PC工业标准设计的小型行业专用商用PC。 配置包含专业的低功耗、高运算功能的嵌入式处理器。不可移除地用于存储操作系统的本地闪存、以及本地系统内存、网络适配器、显卡和其它外设的标配输入/输出选件。瘦客户机没有可移除的部件,可以提供比普通PC更加安全可靠的使用环境,以及更低的功耗,更高的安全性。
-------------------------------------------------------------------------------------------------------------------------------------------------
当Turbo C开始执行时,首先它会等待你敲入任何一个键。当你敲入任何一个键后,Turbo C就会把光标移到主菜单上的File这一项上,此时你如果想要使用编辑器,可以把光标移动到Edit上,然后敲入回车键,或者直接敲入E或e就可以了。当你执行完以上的动作之后,屏幕就看起来如图所示的完全一样。在编辑窗口最上面有一行反白的编辑器状态栏,这一行的文字是用来告诉你编辑器的状态,以及当前你正在编辑的文件名称。其中前两项Line和Col是用来显示当前光标所在的行号和列号。Insert则用来告诉你,当前编辑器正在插入文字的状态。也就是说,当你输入文字时,Turbo C就会把你输入的文字放到原来就已经存在的文字中间。和Inser模式相反的模式是overwrite,在这种操作模式下,新敲入的文字会取代原来光标所在的位置的文字。你可以使用INS这个键,在这两种模式下变换,在大部分情况下,你都会使用原来就已经设置好的INSERT模式,因为这种模式最常用。INDENT这个信息是提示你当前编辑器是在自动编排模式下工作。等一会儿,你就可以看到自动编排的模式是如何进行的,当你不想使用自动编排模式的时候,只要输入CRTL+O+I就可以了。梢后,如果你又想使用自动编排模式时,只要再输入CTRL+O+I就可以了。Tab这项信息是用来告诉你,你可以使用TAB键执行跳位。你可以使用CTRL+O+T来开关这个功能。在编辑器状态栏上的最后一项信息是当前你正在编辑的程序的名称,当我们开始执行TURBO C时,可以在命令中就设置好自己将要编辑的程序文件名称,这点梢后就会介绍。因为到目前为止,你并没有设置要编辑程序的文件名称,所以TRUBO C就使用预先设置好的名字NONAME.C。
---------------------------------------------------------------------------------------------------------------------------------------------------
一旦你进入编辑窗口后,它就准备接收文字。所以你可以输入以下的文字:
Roses are red
violets are blue
and so will you.
当你输入最后一行文字后,不要忘了键入回车。如果你敲错了任何字符时,你可以使用退位键(backspace)去休整错误的字符。现在你的屏幕看起来就像图3.2一样,在图3.2中,请注意光标的位置和LINE和COL旁的数字。
你可以使用光标来移动光标。现在你使用光标键把光标移动到 and so will you这一行的最左边。接下来你就输入I like Turbo C并回车,当你键图时,请仔细观察Turbo C如何把原来输入的那一行文字向右移动,这就是编辑器在插入状态时所做的事情。如果你把编辑器变成Overwrite状态时,Turbo C就会把原先那一行文字覆盖掉。现在屏幕看起来就像图3.3那样。
Last edited by zzz19760225 on 2016-12-11 at 16:40 ]
linux gcc
dos Turbo C
Tools are just an equipment. The one who uses the tool and finds the direction to use the tool is one and the same.
Computer Terms
Synonyms
Favorites
Share
tc
Edit Entry
外文名 Turbo C
Belongs to Computer Term
Contents
1 Basic Content
2 Function Introduction
3 Other Terms
1 Basic Content Editing
Turbo C integrated development environment is a set of C language development tools developed by Borland. It integrates multiple functions such as program editing, debugging, and linking. In the DOS system era, Turbo C was the most widely used PC application development tool, and many application software were developed with Turbo C. With the development of computers and their software, the operating system has developed from DOS to Windows. Most application software under the Windows system no longer uses Turbo C for development. However, as an excellent C program development tool, it is still an ideal tool for learning C programming. The following mainly introduces the widely used version 2.0.
2 Function Introduction Editing
The Turbo C integrated development environment mainly provides the following functions:
1. File Management Function
Turbo C provides basic functions such as creating, saving, closing, and opening source program files. With these functions, you can complete a series of operations from creating to saving and opening C program files.
2. Editing Function
Turbo C mainly provides basic editing functions such as text selection, insertion, deletion, and search.
3. Compilation/Linking Function
All C language source programs are stored in text (ASCII) form. They must go through syntax analysis, checking, and translation before they can form binary instructions that the computer can recognize. The compiled program is generally called object code. In the program design process, function libraries are often used. Therefore, it is generally after linking the object code and the object code in the function library that the binary instruction program that the computer can recognize is truly formed.
4. Running/Debugging Function
In the program design process, some errors are inevitable. Therefore, they must be verified by running before they can be delivered for use. The compilation stage mainly performs syntax analysis and checks for errors, while the running stage mainly checks for logical errors in the program. In order to facilitate checking logical errors in the program, most compilers generally provide debugging functions to track the running process and state of the program. Turbo C mainly provides functions such as single-step execution, tracing, breakpoint management, and expression calculation.
5. Project Management Function
In the process of software development, a software may require multiple people to edit hundreds or thousands of program files, forming code of hundreds of thousands of lines or more. To manage such a large-scale software development, project management must be used. The project management function provided by Turbo C mainly controls the compilation and linking of code.
6. System Settings and Help
In order to ensure the normal operation of the system and set parameters such as compilation and linking, Turbo C provides relevant system parameter setting functions. In addition, in order to help beginners master the use of Turbo C, the system provides rich help information. The main way to obtain help information is to press the function key F1 when in need of help.
3 Other Terms Editing
TC (Transmission Convergence) transmission convergence sublayer. Provides a unified interface with the ATM layer.
TC, short for TurboCache. NVIDIA's TurboCache (referred to as TC) technology is of great significance in building the cost-performance ratio of new-generation products. It provides the latest GPU architecture and various forward-looking applications while taking into account cost. TurboCache is a patented hardware and software technology. TurboCache seizes the opportunity of the replacement of new and old buses and gives full play to the advantages of PCI-Express bandwidth.
TC, short for Traffic Control. It is a tool for traffic control in Linux. Through tc, the rate at which network interfaces send and receive data can be controlled.
TC, short for Total Commander. Total Commander, referred to as TC, formerly Windows Commander, is a powerful all-in-one file manager.
TC, short for TopCoder. This website can be said to be a website for programming competitions, but the question types and competition forms are very different from ACM/ICPC. This website includes China in its competition area. Everyone can go there to communicate more directly with programmers from all over the world (in fact, most are also college students). It may also be a good place to train for ACM/ICPC.
Short for Thin Client. A thin client (Thin Client) is a small industry-specific commercial PC designed based on PC industry standards that uses a professional embedded processor, a small local flash memory, and a slim version of the operating system. The configuration includes a professional low-power, high-computing-function embedded processor. The local flash memory that irreversibly stores the operating system, as well as the standard input/output options for local system memory, network adapter, graphics card, and other peripherals. Thin clients have no removable parts and can provide a more secure and reliable use environment than ordinary PCs, as well as lower power consumption and higher security.
-------------------------------------------------------------------------------------------------------------------------------------------------
When Turbo C starts to execute, it first waits for you to press any key. When you press any key, Turbo C will move the cursor to the File item in the main menu. At this time, if you want to use the editor, you can move the cursor to Edit, then press the Enter key, or directly press E or e. After you perform the above actions, the screen will look exactly the same as shown in the figure. There is a highlighted editor status bar at the top of the editing window. The text in this line is used to tell you the status of the editor and the name of the file you are currently editing. The first two items, Line and Col, are used to display the current line number and column number where the cursor is located. Insert is used to tell you that the current editor is in the text insertion state. That is, when you enter text, Turbo C will insert the text you entered into the original existing text. The mode opposite to the Insert mode is overwrite. In this operation mode, the newly entered text will replace the text at the position where the cursor is located. You can use the INS key to switch between these two modes. In most cases, you will use the original set INSERT mode because this mode is the most commonly used. The INDENT information prompts you that the current editor is working in the automatic formatting mode. Wait a while, and you will see how the automatic formatting mode works. When you don't want to use the automatic formatting mode, just enter CTRL+O+I. Later, if you want to use the automatic formatting mode again, just enter CTRL+O+I again. The Tab information is used to tell you that you can use the TAB key to perform tabbing. You can use CTRL+O+T to turn this function on and off. The last item of information on the editor status bar is the name of the program you are currently editing. When we start executing TURBO C, we can set the name of the program file we are going to edit in the command. This will be introduced later. Because so far, you have not set the file name of the program to be edited, so TRUBO C uses the pre-set name NONAME.C.
---------------------------------------------------------------------------------------------------------------------------------------------------
Once you enter the editing window, it is ready to receive text. So you can enter the following text:
Roses are red
violets are blue
and so will you.
After you enter the last line of text, don't forget to press Enter. If you type any wrong characters, you can use the backspace key to correct the wrong characters. Now your screen looks like Figure 3.2. In Figure 3.2, please pay attention to the position of the cursor and the numbers next to LINE and COL.
You can use the cursor keys to move the cursor. Now use the cursor keys to move the cursor to the far left of the line "and so will you". Then you enter "I like Turbo C" and press Enter. When you type, please carefully observe how Turbo C moves the original entered line of text to the right. This is what the editor does in the insertion state. If you change the editor to the Overwrite state, Turbo C will overwrite the original line of text. Now the screen looks like Figure 3.3.
Last edited by zzz19760225 on 2016-12-11 at 16:40 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:39 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
C语言是否可以分解位解释语言和编译两类合并随意选择模式。
nim vala
Last edited by zzz19760225 on 2017-7-13 at 05:47 ]
Can the C language decompose into a mode where bit-interpretation language and compilation are combined and can be freely selected?
nim vala
Last edited by zzz19760225 on 2017-7-13 at 05:47 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:40 |
|
|
zzz19760225
超级版主
        
积分 3673
发帖 2020
注册 2016-2-1
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
练习:
1通过linux终端的 gcc显示一段话:
集中在这一段熟悉其字,结构,背后的延伸,编辑器的运算,机器码的内容,变换不同的显示内容,小文大文等等。
#include <stdio.h>
int main(void)
{
printf("")
return 0;
}
假设编码正确,终端下输入gcc 文件名和后缀,确认会生成./a.out文件,直接输入这个./a.out显示文件内容。
2下次试试写错了,变形的程序写法,直接查看的./a.out机器码在不同的文本内容下会有那些差异。
#include <stdio.h>
int main(void)
{
printf("");
}
ugg:
函数大全好找比如《C~C++程序员实用大全——C~C++最佳编程指南》
函数源代码那就不好找了,只能仿真实现,或者反汇编查看。
Last edited by zzz19760225 on 2017-11-1 at 14:19 ]
Practice:
1. Display a paragraph through the gcc in the linux terminal:
Concentrate on this paragraph to familiarize yourself with its words, structure, extensions behind it, editor operations, machine code content, change different display contents, small articles and large articles, etc.
#include <stdio.h>
int main(void)
{
printf("")
return 0;
}
Assuming the encoding is correct, enter gcc filename and suffix in the terminal, confirm that the./a.out file will be generated, and directly enter this./a.out to display the file content.
2. Try writing wrong next time, the program writing in deformation, directly view the differences in the machine code of./a.out under different text contents.
#include <stdio.h>
int main(void)
{
printf("");
}
ugg:
It is easy to find the function list, such as "C~C++ Programmer's Practical Collection - Best Programming Guide for C~C++"
It is not easy to find the function source code. It can only be simulated and implemented, or viewed by disassembling.
Last edited by zzz19760225 on 2017-11-1 at 14:19 ]
|

1<词>,2,3/段\,4{节},5(章)。 |
|
2016-6-26 18:41 |
|
|