[go: nahoru, domu]

删除的内容 添加的内容
标签撤销
InternetArchiveBot留言 | 贡献
Add 7 books for verifiability (20211007)) #IABot (v2.0.8.1) (GreenC bot
第57行:
* C語言是一個有結構化程式設計、具有变量作用域(variable scope)以及遞迴功能的程序式語言。
* C語言傳遞參數均是以值傳遞(pass by value)<ref>{{ Cite book | author = Brian W. Kernighan and Dennis M. Ritchie | title = The C programming Language | publisher = Prentice-Hall | date = 1988 | ISBN = 0-13-110362-8 | language = en | quote = In C, all function arguments are passed ``by value.'' }}</ref>,另外也可以傳遞指针(a pointer passed by value)。
* 不同的變數類型可以用結構体(struct)組合在一起。<ref> {{Cite book | author = Dennis M. Ritchie,Brian W. Kernighan | title = C程序设计语言 | url = https://archive.org/details/cchengxushejiyuy0000kern | location = 北京 | publisher = 机械工业出版社 | date = 2004年1月 | ISBN = 9787111128069 | accessdate = 2020-06-10 | language = 中文 }} </ref>
* 只有32個保留字(reserved keywords),使变量、函數命名有更多彈性。<ref> {{Cite book | author = Dennis M. Ritchie,Brian W. Kernighan | title = C程序设计语言 | url = https://archive.org/details/cchengxushejiyuy0000kern | location = 北京 | publisher = 机械工业出版社 | date = 2004年1月 | ISBN = 9787111128069 | accessdate = 2020-06-10 | language = 中文 }} </ref>
* 部份的变量類型可以轉換,例如整數型和字符型变量。<ref> {{Cite book | author = Dennis M. Ritchie,Brian W. Kernighan | title = C程序设计语言 | url = https://archive.org/details/cchengxushejiyuy0000kern | location = 北京 | publisher = 机械工业出版社 | date = 2004年1月 | ISBN = 9787111128069 | accessdate = 2020-06-10 | language = 中文 }} </ref>
* 透過[[指標 (電腦科學)|指標]](pointer),C語言可以容易的對記憶體進行低階控制。<ref> {{Cite book | author = Dennis M. Ritchie,Brian W. Kernighan | title = C程序设计语言 | url = https://archive.org/details/cchengxushejiyuy0000kern | location = 北京 | publisher = 机械工业出版社 | date = 2004年1月 | ISBN = 9787111128069 | accessdate = 2020-06-10 | language = 中文 }} </ref>
* 编译预处理(preprocessor)讓C語言的編譯更具有彈性。<ref> {{Cite book | author = Dennis M. Ritchie,Brian W. Kernighan | title = C程序设计语言 | url = https://archive.org/details/cchengxushejiyuy0000kern | location = 北京 | publisher = 机械工业出版社 | date = 2004年1月 | ISBN = 9787111128069 | accessdate = 2020-06-10 | language = 中文 }} </ref>
 
== 歷史 ==
{{main|C语言的历史}}
 
20世纪70年代,肯·汤姆森为了使其设计的Unix系统更加高效,使用B语言的变种(即C语言)重写了Unix。在1978年,[[丹尼斯·里奇]]和[[布萊恩·柯林漢]]合作出版了《[[C程序设计语言 (书)|C程序设计语言]]》第一版,事实上即为K&R C标准<ref> {{Cite book | author = Stephen Prata | title = C Primer Plus(第5版) | url = https://archive.org/details/cprimerplusdiwub0005unse | location = 北京 | publisher = 人民邮电出版社 | date = 2005年2月 | pages = [https://archive.org/details/cprimerplusdiwub0005unse/page/3 3]-4 | ISBN = 9787115130228 | accessdate = 2020-07-15 | language = 中文 }} </ref>。在这之后,制定标准的工作转移到ISO和ANSI。目前最新的C语言标准是[[C18 (C语言标准)|C18]]。
 
== 語法 ==
第96行:
 
=== 进一步了解 ===
C语言由函数和变量组成,C的函数就像是[[Fortran]]中的子程序和函数<ref> {{Cite book | author = Dennis M. Ritchie,Brian W. Kernighan | title = C程序设计语言 | url = https://archive.org/details/cchengxushejiyuy0000kern | location = 北京 | publisher = 机械工业出版社 | date = 2004年1月 | ISBN = 9787111128069 | accessdate = 2020-06-10 | language = 中文 }} </ref><ref>{{Cite web |url =http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf |accessdate =2020-06-10 |title =ISO/IEC 9899:2018 |archive-date =2020-07-22 |archive-url =https://web.archive.org/web/20200722132012/http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf |dead-url =no }}</ref>。
 
在C语言中,程序从 [[主函式#C/C++|<code>main</code>]] 开始执行。<code>main</code> 函数通过调用和控制其他函数进行工作。例如上面的<code>printf</code>。程序员可以自己写函数,或从库中调用函数。在上面的<code>return 0;</code> 使得 <code>main</code> 返回一个值给调用程序的[[壳层]],表明程序是否成功运行。