The C Programming Language

  • H9_448423
  • 180.5KB
  • rar
  • 0
  • VIP专享
  • 0
  • 2022-05-01 01:44
The C Programming Language<br>C语言的经典教程。<br>程序员可以读读。
The C Programming Language.rar
  • About.txt
  • chapter8.txt
  • chapter5.txt
  • preface.txt
  • intro.txt
  • chapter2.txt
  • index.txt
  • preface1.txt
  • appc.txt
  • chapter1.txt
  • chapter4.txt
  • kandr.txt
  • appb.txt
  • chapter6.txt
  • chapter3.txt
  • chapter7.txt
  • appa.txt
Appendix A - Reference Manual Back to Chapter 8 -- Index -- Appendix B Appendix A - Reference Manual A.1 Introduction This manual describes the C language specified by the draft submitted to ANSI on 31 October, 1988, for approval as ``American Standard for Information Systems - programming Language C, X3.159-1989.'' The manual is an interpretation of the proposed standard, not the standard itself, although care has been taken to make it a reliable guide to the language. For the most part, this document follows the broad outline of the standard, which in turn follows that of the first edition of this book, although the organization differs in detail. Except for renaming a few productions, and not formalizing the definitions of the lexical tokens or the preprocessor, the grammar given here for the language proper is equivalent to that of the standard. Throughout this manual, commentary material is indented and written in smaller type, as this is. Most often these comments highlight ways in which ANSI Standard C differs from the language defined by the first edition of this book, or from refinements subsequently introduced in various compilers. A.2 Lexical Conventions A program consists of one or more translation units stored in files. It is translated in several phases, which are described in Par.A.12 . The first phases do low-level lexical transformations, carry out directives introduced by the lines beginning with the # character, and perform macro definition and expansion. When the preprocessing of Par.A.12 is complete, the program has been reduced to a sequence of tokens. A.2.1 Tokens There are six classes of tokens: identifiers, keywords, constants, string literals, operators, and other separators. Blanks, horizontal and vertical tabs, newlines, formfeeds and comments as described below (collectively, ``white space'') are ignored except as they separate tokens. Some white space is required to separate otherwise adjacent identifiers, keywords, and constants. If the input stream has been separated into tokens up to a given character, the next token is the longest string of characters that could constitute a token. A.2.2 Comments The characters /* introduce a comment, which terminates with the characters */ . Comments do not nest, and they do not occur within a string or character literals. A.2.3 Identifiers An identifier is a sequence of letters and digits. The first character must be a letter; the underscore _ counts as a letter. Upper and lower case letters are different. Identifiers may have any length, and for internal identifiers, at least the first 31 characters are significant; some implementations may take more characters significant. Internal identifiers include preprocessor macro names and all other names that do not have external linkage ( Par.A.11.2 ). Identifiers with external linkage are more restricted: implementations may make as few as the first six characters significant, and may ignore case distinctions. A.2.4 Keywords The following identifiers are reserved for the use as keywords, and may not be used otherwise: 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 static while Some implementations also reserve the words fortran and asm . The keywords const , signed , and volatile are new with the ANSI standard; enum and void are new since the first edition, but in common use; entry , formerly reserved but never used, is no longer reserved. A.2.5 Constants There are several kinds of constants. Each has a data type; Par.A.4.2 discusses the basic types: constant: integer-constant character-constant floating-constant enumeration-constant A.2.5.1 Integer Constants An integer constant consisting of a sequence of digits is taken to be octal if it begins with 0 (digit zero), decimal otherwise. Octal constants do not contain the digits 8 or 9 . A sequence of digits preceded by 0x or 0X (digit zero) is taken to be a hexadecimal integer. The hexadecimal digits include a or A through f or F with values 10 through 15 . An integer constant may be suffixed by the letter u or U , to specify that it is unsigned. It may also be suffixed by the letter l or L to specify that it is long. The type of an integer constant depends on its form, value and suffix. (See Par.A.4 for a discussion of types). If it is unsuffixed and decimal, it has the first of these types in which its value can be represented: int , long int , unsigned long int . If it is unsuffixed, octal or hexadecimal, it has the first possible of these types: int , unsigned int , long int , unsigned long int . If it is suffixed by u or U , then unsigned int , unsigned long int . If it is suffixed by l or L , then long int , unsigned long int . If an integer constant is suffixed by UL , it is unsigned long . The elaboration of the types of integer constants goes considerably beyond the first edition, which merely caused large integer constants to be long . The U suffixes are new. A.2.5.2 Character Constants A character constant is a sequence of one or more characters enclosed in single quotes as in 'x' . The value of a character constant with only one character is the numeric value of the character in the machine's character set at execution time. The value of a multi-character constant is implementation-defined. Character constants do not contain the ' character or newlines; in order to represent them, and certain other characters, the following escape sequences may be used: newline NL (LF) \n backslash \ \\ horizontal tab HT \t question mark ? \? vertical tab VT \v single quote ' \' backspace BS \b double quote " \" carriage return CR \r octal number ooo \ooo formfeed FF \f hex number hh \xhh audible alert BEL \a The escape \ooo consists of the backslash followed by 1, 2, or 3 octal digits, which are taken to specify the value of the desired character. A common example of this construction is \0 (not followed by a digit), which specifies the character NUL. The escape \xhh consists of the backslash, followed by x , followed by hexadecimal digits, which are taken to specify the value of the desired character. There is no limit on the number of digits, but the behavior is undefined if the resulting character value exceeds that of the largest character. For either octal or hexadecimal escape characters, if the implementation treats the char type as signed, the value is sign-extended as if cast to char type. If the character following the \ is not one of those specified, the behavior is undefined. In some implementations, there is an extended set of characters that cannot be represented in the char type. A constant in this extended set is written with a preceding L , for example L'x' , and is called a wide character constant. Such a constant has type wchar_t , an integral type defined in the standard header <stddef.h> . As with ordinary character constants, hexadecimal escapes may be used; the effect is undefined if the specified value exceeds that representable with wchar_t . Some of these escape sequences are new, in particular the hexadecimal character representation. Extended characters are also new. The character sets commonly used in the Americas and western Europe can be encoded to fit in the char type; the main intent in adding wchar_t was to accommodate Asian languages. A.2.5.3 Floating Constants A floating constant consists of an integer part, a decimal part, a fraction part, an e or E , an optionally signed integer exponent and an optional type suffix, one of f , F , l , or L . The integer and fraction parts both consist of a
    • 谭浩强C语言
    • 谭浩强c语言
    • Makefile c语言
      Makefile c语言Makefile c语言Makefile c语言Makefile c语言 四本资料!自己学习的时候整理的!
    • c语言教程
    • C语言 实现
      C语言 项目实现 《计算方法》课件 俄罗斯方块游戏 C语言实训 综合案例-学生成绩管理程序 C语言程序设计学习与实践指导(源代码)
    • c语言
    • C语言库函数
    • C语言
    • 谭浩强C语言
      谭浩强C语言word版,学习C语言的,经典教材。 使用的编译工具有些老旧,建议是使用visual stdio 2008。
    • 水滴石穿C语言
      学习C语言的有用文档 水滴石穿C语言C语言的底层操作 水滴石穿C语言之extern声明辨析 水滴石穿C语言之static辨析 水滴石穿C语言之typedef的问题 水滴石穿C语言之编译器引出的问题 水滴石穿C语言之代码检查工具 ...