c语言规范标准中英文,C语言中英文翻译资料.doc
C語言中英文翻譯資料.doc
The C Programming LanguageC is a high-level programming language developed by Dennis Ritchie and Brian Kernighan at Bell Labs in the mid-1970s. Although originally designed as a systems programming language, C has proved to be a powerful and flexible language that can be used for a variety of applications, from business programs to engineering. C is a particularly popular language for personal computer programmers because it is relatively small-it requires less memory than other languages.The first major program written in C was the UNIX operating system; and for many years, C was considered to be inextricably linked with UNIX. Now, however, C is am important language independent of UNIX. Although it is a high-level languages, C is much closer to assembly language than are most other high-level languages. This closeness to the underlying machine language allows C programmers to write very efficient code. The how-level nature of C, however, can make the language difficult to use for some types of applications.Now lets take an overview of the C programming language, both historically and technically and technically.As a general-purpose programming language, C has been closely associated with UNIX system where it was developed, since both the system and most of the applications that run on it are written in C. The language , however, is not tied to any one operating system or machine; and although it has been called a “system programming language” because it is useful for writing compilers and operating systems, it has been used equally well to write major programs in various fields.Many of the important ideas stem from the language BCPL, developed by Martin Richards. The influence of BCPL on C proceeded indirectly through the language B, which was written by Ken Tompson in 1970 for the first UNIX system on the DEC-PDP-7.BCPL and B are “typeless” languages. By contrast, C provides a variety of data types. The fundamental types are characters, and integers and floating point numbers of several sizes. Additionally, there is a hierarchy of derived data types created with pointers, arrays, structures, and unions. Expressions are ed from operands; any expression, including an assignment or a function call, can be a statement. Pointers provide for machine-independent address arithmetic. C provides the fundamental control-flow constructions required for well-structured programs statement grouping, decision making if-else , selecting one of a set of possible cases switch, looping with the termination test at the top while, for or at the bottom do, and early loop exit break.Functions may return values of basic type, structures, unions, or pointers. Any function may be called recursively. Local variables are typically “automatic”, or created anew with each invocation. Function definitions may not be nested but variables may be declared in a block-structured fashion. The functions of a C program may exist in separate source files that are compiled individually. Variables may be internal to a function, external but known only within a single source files, or visible to the entire program.A preprocessing step pers macro substitution on program text, inclusion of other source file, and conditional compilation. C is a relatively low-level language, meaning that C deals with the same sort of objects that most computers do, namely characters, numbers, and addresses. These may be combined and moved about with the arithmetic and logical operators implemented by real machines.C provides no operations to deal directly with composeite objects such as character strings, sets, lists, or arrays. There are no operations that manipulate an entire any storage allocation facility other than static definition and the stack discipline provided by the local variables of functions; there are no heap or garbage collection . Finally, C itself provides no /output facilities; there are no Read or Write statements, and no built-in file access s. All of these higher-level mechanisms must be provided by explicitly-called functions. Most C implementations have included a reasonably standard collection of such functions.Similarly, C offers only straightforward, single-thread control flow tests, loops, grouping, and subprograms, but not multiprogramming, parallel operations, synchronization, or co-routines.Although the absence of some of these features may seem like a grave deficiency, keeping the language down to modest size has real benefits. Since C is relatively small, it can be described in a small space, and learned quickly. A programmer can reasonably expect to know and understand and indeed regularly use the entire language.In 1983, the American National Standard Institute ANSI established a committee to provide a modern, comprehensive definition of C. The resulting definition, the ANSI standard, or “ANSI C”, was completed late in 1988. Most of the features of the standard are already supported by modern compilers . The standard is based on the original C reference manual. The language is relatively little changed; one of the goals of the standard was to make sure that most existing programs would remain valid, or, failing that, that compilers could produce warning of new behavior.For most programmers, the most important change is a new syntax for declaring and defining functions. A function declaration can now include a description of the arguments of the function; the definition syntax changes to match. This extra ination makes it much easier for compiler to detect errors caused by mismatched arguments. This has proved to be a very useful addition to the language.A second significant contribution of the standard is the definition of a library to accompany C. It specifies functions for accessing the operating system for example, to read and write file, atted and output, memory allocation, string manipulation, and the like. A collection of standard headers provides uni access to declarations of functions and data types. Programs that use this library is closely modeled on the “standard I/O library” of the UNIX system.Although C matches the capability of many computers, it is independent of any particular machine architecture. With a little care it is easy to write portable programs, that is, programs that can be run without change on a variety of hardware.C, however, like any other language, has its blemishes. Some of the operators have the wrong precedence; some parts of the syntax could be better. Nonetheless, C has proved to be an extremely effective and expressive language for a wide variety of programming applications.Having reviewed the history and features of C, lets now study an example C program for a basic understanding of what a C program looks like. The following program finds the factorial of the number 6./* Program to find factorial of 6 */ include stdio.h define3 VALUE 6 int i, j ;main j1;for i1; iVALUE; i jj*I;printf “The factorial of d is dn”, VALUE, j ;As shown in the example, C code starts with include stdio.h , which instructs the compiler to include the standard I/O library into your program so that you can read and write values, handle text files, and so on. C has a large number of standard libraries like stdio, including string, time and math libraries.The define line creates a constant. Two global variables are declared using the int i, j; line, which announces the properties in this case, integer of the two variables. Other common variable types are floatfor real number and char for characters, both of which you can declare in the same way as int.The line main declares the main function. Every C program must have a function named main somewhere in the code, which marks the beginning of your program. In C, the statements of a function are enclosed in braces. In the example the mainfunction contains only three statement, which are an assignment statement, a for statement, and a printf statement.The printf statement in C is easier to use. The portion in double quotes is called the at string and describes how the data is to be atted when printed. The at string contains string literals or string constant such as The factorial of, n also called escape sequence. /n stands for carriage returns, and operators in the of d, which are used as placeholders for variables. The two operatorsalso called conversion specifications in the at string indicate that integer values found later in the parameter list are to be placed into the string at these points. Other operators include f for floating point values, c for characters, and s for strings.In the printf statement, it is extremely important that the number of operators in the at string corresponds exactly with the number and type of the variables following it. For example, if the at string contains three operators and it must be followed by exactly three parameters, and they must have the same types in the same order as those specified by the operators.This program is good, but it would be better if it reads in the value instead of using a constant. Edit the file, remove the VALUE constant, and declare a variable value instead as a global integerchanging all references to lower-case because value is now a variable. Then place the following two lines at the beginning of the programPrintf “Enter the value ”;Scanf“d”, Make the changes, then compile and run the program to make sure it works. Note that scanf uses the same sort of at string as printf. The main j1;for I1;IVALUE;I jj*I;printf“The factorial of d is d n”,VALUE,j;如例中所示,C語言程序(代碼)以“includestdio.h”一句開始,其目的只是編譯程序將C標準函數(shù)庫蘊含到用戶程序中,以便于讀寫數(shù)據(jù)、處理文本文件等等。C語言帶有大量像“stdio.h”這樣的標準函數(shù)庫,包括字符串處理、時間及數(shù)學運算等函數(shù)庫。“define”一行定義了一個常量。“int i,j”一行說明了兩個全局變量,定義了兩個變量的屬性(本例中為整數(shù))。其他常用的變量類型還有浮點型(指實數(shù)型)、字符型(指字符)等,其說明格式同整型類似。“main”一行說明了本程序的主函數(shù)。每一個C語言程序都必須有一個名為“main”的函數(shù),可出現(xiàn)于程序的任意位置,用以標記程序的開始。在C語言中函數(shù)的語句都被括在一對中。在本例中,主函數(shù)包括三行語句,分別是賦值語句、for循環(huán)語句,及printf格式輸出語句。C語言中的“printf”語句很容易使用。雙引號中的部分叫作格式串,用于描述數(shù)據(jù)在輸出時的格式。格式串可以包括字符常量,如“The factorial of”及“n”(又稱作轉義序列,n表示回車);還可以包括形如“d”的操作符,用作待輸出變量的定位符。本例中格式串的兩個操作符(又叫作轉換說明),表示出現(xiàn)于后續(xù)參數(shù)表中的整型數(shù)值將被置于該格式字符串的指定位置。類似的格式操作符還有表示浮點數(shù)值的“f”、表示字符的“c”,及表示字符串的“s”等。必須注意,在“printf”語句中,格式串中操作符的數(shù)目與后續(xù)的變量在類型及數(shù)目上要嚴格對應。例如,如果格式串包含三個操作符,在后面的參數(shù)也必須有三個,并且參數(shù)在類型及出現(xiàn)的順序上要與前面的操作符一致。這個程序還可以,不過,如果能將常量改為由程序讀入數(shù)值,則會更好一些。編輯該程序,刪除VALUE常量,并說明一個全局變量“value”(把所有變更引用都改為小寫,因為“value”現(xiàn)已說明為一個變量),然后將以下兩行加到程序的開始處printf“Enter the value”;scanf“d”,修改程序,進行編譯并運行,以確保程序無誤。值得注意的是,“printf”使用的格式串與“scanf”相同,“value”變量前的“”字符在C語言中稱作地址操作符,用于返回指定變量的內存地址。出現(xiàn)于“scanf”中的字符型、整型、浮點型,以及記錄型(即結構型)的任何變量都必須加上“”操作符。倘若漏掉“”,運行程序時就會出現(xiàn)錯誤。
總結
以上是生活随笔為你收集整理的c语言规范标准中英文,C语言中英文翻译资料.doc的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 没有bug队——加贝——Python 4
- 下一篇: wifidog java_wifidog