c之父的英文著作

前言的闲话以及第一章的入门(一)


        随便拿起一本关于编程语言的书,你都会发现其少则三四百页,多则上千页,唯独此本只有两三百页,可见其作者语言功底之深厚。闲话不表,先来看看第一章的新手教程吧!

Chapter 1 - A Tutorial Introduction

1.1 Getting Started

1.2 Variables and Arithmetic Expressions

1.3 The for statement

1.4 Symbolic Constants

1.5 Character Input and Output

        1.5.1 File Copying

        1.5.2 Character Counting

        1.5.3 Line Counting

        1.5.4 Word Counting

        1.6 Arrays

1.7 Functions

1.8 Arguments - Call by Value

1.9 Character Arrays

1.10 External Variables and Scope

        当然,第一章作者的意图很明显,那就是show the essential elements of the language in real programs, but without getting bogged down(陷入) in details, rules, and exceptions.总之,就是不要在乎细节!

        1.1 Getting Started

        凡是编程的书籍,作者都会举个例子Print the words “”hello, world“,本书也不例外,简单粗暴,上来问候下全世界先。


#include

main()

{

printf("hello, world\n");

}


        作者举得unix操作系统下的编译过程,无非是

cc hello.c(gcc hello.c

a.out(/a.out)

然后打印(括号内为linux下的编译过程)

hello, world

        接着,作者对上述程序作了解释,其中有句话很有意思:A C program, whatever its size, consists of functions and variables. A function contains statements that specify the computing operations to be done, and variables store values used during the computation. C functions are like the subroutines and functions in Fortran or the procedures and functions of Pascal.刚开始很奇怪怎么会有A函数和C函数呢?读几遍之后发现讲的就那么一个函数。

        作者说,一定要有main函数,缺谁都不能缺他,不然程序都不知道自己该从哪开始,总之,他就是入口。



        这里讲到了#include ,这个头文件告诉编译器要包含我这个standard input/output library,不然你那个printf函数也别想用了。

        当然也提到了函数之间的交流靠的就是参数,可以理解为A函数给B函数扔了个苹果,并且鄙视了B。在这里,main不想与其他人交流,原文的话就是The parentheses after the function name surround the argument list. In this example, main is defined to be a function that expects no arguments, which is indicated by the empty list ( ).本来每个函数都自带框子收发苹果,可main他不带框子了。

        最后,大括号里的函数语句printf("hello, world\n")告诉我们printf函数的参数就是双引号里的hello, world\n字符串,\n是个换行符,告诉我们输出打印从下一行的左端开始(The sequence \n in the string is C notation for the newline character, which when printed advances the output to the left margin on the next line.

        Among the others that C provides are \t for tab, \b for backspace, \" for the double quote and \\ for the backslash itself.C 语言提供的转义字符序列还包括:\t 表

示制表符;\b 表示回退符;\"表示双引号;\\表示反斜杠符本身。

        END!


        这里讲到了#include ,这个头文件告诉编译器要包含我这个standard input/output library,不然你那个printf函数也别想用了。

        当然也提到了函数之间的交流靠的就是参数,可以理解为A函数给B函数扔了个苹果,并且鄙视了B。在这里,main不想与其他人交流,原文的话就是The parentheses after the function name surround the argument list. In this example, main is defined to be a function that expects no arguments, which is indicated by the empty list ( ).本来每个函数都自带框子收发苹果,可main他不带框子了。

        最后,大括号里的函数语句printf("hello, world\n")告诉我们printf函数的参数就是双引号里的hello, world\n字符串,\n是个换行符,告诉我们输出打印从下一行的左端开始(The sequence \n in the string is C notation for the newline character, which when printed advances the output to the left margin on the next line.

        Among the others that C provides are \t for tab, \b for backspace, \" for the double quote and \\ for the backslash itself.C 语言提供的转义字符序列还包括:\t 表

示制表符;\b 表示回退符;\"表示双引号;\\表示反斜杠符本身。

        END!

你可能感兴趣的:(C语言,英文原版,Hall.-.)