Skip to Content
C语言核心技术(原书第2版)
book

C语言核心技术(原书第2版)

by Peter Prinz, Tony Crawford
August 2017
Intermediate to advanced
798 pages
17h 44m
Chinese
China Machine Press
Content preview from C语言核心技术(原书第2版)
C
语言基础
|
15
C
语言基础
每个
C
源代码文件,连同被包含在其中的头文件,构成一个翻译单元(
translation unit)
。
编译器按次序处理翻译单元的内容,把源代码转换成标记(
token
)。标记是最小的语义
单元,比如变量名称与运算符(
operator
)。详细说明请参见
1.7.2
节的介绍。
两个连续标记之间可放入任意数量的空格符,这使得可以在较大的自由度范围内进行源
代码的格式安排。
C
语言没有换行或缩排的规则,可以使用空格符、制表符(
tab
)或空
白行,将源代码格式化成“适合阅读”的格式。预处理命令的格式化自由度则要低一
些:一条命令必须独占一行,并且
#
符号前面除了空格符与制表符之外,不可以有别的
字符。
虽然有许多不同习惯与独特风格的源代码格式,但大多数都包括下列通用规则:
•
每个新的声明和语句都新起一行。
•
使用缩进以反映语句块的嵌套(
nested
)结构。
1.4 注释
在编写
C
语言源代码时,应该多使用注释,这样有助于对代码的理解。在
C
语言中有两
种注释方式:一种是以
/*
开始、以
*/
结束的块注释(
block comment)
;另一种是以
//
开
始、以换行符结束的单行注释(
line comment)
。
可以使用
/*
和
*/
分隔符来标注一行内的注释,也可以标注多行的注释。例如,在下列的
函数原型中,省略号的意思是
open()
函数有第三个参数,它是可选参数。注释解释了这
个可选参数的用法:
int open( const char *name, int mode,
…
/* int permissions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

算法精讲视频课程:24篇系列讲座

算法精讲视频课程:24篇系列讲座

罗伯特·塞奇威克, 凯文·韦恩(Kevin Wayne)

Publisher Resources

ISBN: 9787111562207