⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 appa.html

📁 c语言编程-c语言作者的书。英文原版。非常好。
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<html><head><title>Appendix A - Reference Manual</title></head><body><hr><p align="center"><a href="chapter8.html">Back to Chapter 8</a>&nbsp;--&nbsp;<a href="kandr.html">Index</a>&nbsp;--&nbsp;<a href="appb.html">Appendix B</a><p><hr><h1>Appendix A - Reference Manual</h1><h2><a name="sa.1">A.1 Introduction</a></h2>This manual describes the C language specified by the draft submitted to ANSIon 31 October, 1988, for approval as ``American Standard for InformationSystems - programming Language C, X3.159-1989.'' The manual is aninterpretation of the proposed standard, not the standard itself, althoughcare has been taken to make it a reliable guide to the language.<p>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 theorganization differs in detail. Except for renaming a few productions, andnot formalizing the definitions of the lexical tokens or the preprocessor,the grammar given here for the language proper is equivalent to that of thestandard.<p><dl><dd><font size="-1">Throughout this manual, commentary material is indented and written in smallertype, as this is. Most often these comments highlight ways in which ANSIStandard C differs from the language defined by the first edition of thisbook, or from refinements subsequently introduced in various compilers.</font></dl><h2><a name="sa.2">A.2 Lexical Conventions</a></h2>A program consists of one or more <em>translation units</em> stored in files.It is translated in several phases, which are described in <a href="#sa.12">Par.A.12</a>.The first phases do low-level lexical transformations, carry out directivesintroduced by the lines beginning with the # character, and perform macrodefinition and expansion. When the preprocessing of <a href="#sa.12">Par.A.12</a> iscomplete, the program has been reduced to a sequence of tokens.<h3><a name="sa.2.1">A.2.1 Tokens</a></h3>There are six classes of tokens: identifiers, keywords, constants, stringliterals, operators, and other separators. Blanks, horizontal and verticaltabs, newlines, formfeeds and comments as described below (collectively,``white space'') are ignored except as they separate tokens. Some white spaceis required to separate otherwise adjacent identifiers, keywords, andconstants.<p>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 atoken.<h3><a name="sa.2.2">A.2.2 Comments</a></h3>The characters <tt>/*</tt> introduce a comment, which terminates with thecharacters <tt>*/</tt>. Comments do not nest, and they do not occur within astring or character literals.<h3><a name="sa.2.3">A.2.3 Identifiers</a></h3>An identifier is a sequence of letters and digits. The first character mustbe a letter; the underscore <tt>_</tt> counts as a letter. Upper and lowercase letters are different. Identifiers may have any length, and for internalidentifiers, at least the first 31 characters are significant; someimplementations may take more characters significant. Internal identifiersinclude preprocessor macro names and all other names that do not haveexternal linkage (<a href="#sa.11.2">Par.A.11.2</a>). Identifiers with external linkage aremore restricted: implementations may make as few as the first six characterssignificant, and may ignore case distinctions.<h3><a name="sa.2.4">A.2.4 Keywords</a></h3>The following identifiers are reserved for the use as keywords, and may notbe used otherwise:<pre>     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</pre>Some implementations also reserve the words <tt>fortran</tt> and <tt>asm</tt>.<p><dl><dd><font size="-1">The keywords <tt>const</tt>, <tt>signed</tt>, and <tt>volatile</tt> are newwith the ANSI standard; <tt>enum</tt> and <tt>void</tt> are new since thefirst edition, but in common use; <tt>entry</tt>, formerly reserved but neverused, is no longer reserved.</font></dl><h3><a name="sa.2.5">A.2.5 Constants</a></h3>There are several kinds of constants. Each has a data type; <a href="#sa.4.2">Par.A.4.2</a>discusses the basic types:<p><em>&nbsp;&nbsp;&nbsp;&nbsp;constant:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;integer-constant<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;character-constant<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;floating-constant<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enumeration-constant</em><h4><a name="sa.2.5.1">A.2.5.1 Integer Constants</a></h4>An integer constant consisting of a sequence of  digits is taken to be octalif it begins with 0 (digit zero), decimal otherwise. Octal constants do notcontain the digits <tt>8</tt> or <tt>9</tt>. A sequence of digits preceded by<tt>0x</tt> or <tt>0X</tt> (digit zero) is taken to be a hexadecimal integer. Thehexadecimal digits include <tt>a</tt> or <tt>A</tt> through <tt>f</tt> or <tt>F</tt> withvalues <tt>10</tt> through <tt>15</tt>.<p>An integer constant may be suffixed by the letter <tt>u</tt> or <tt>U</tt>, tospecify that it is unsigned. It may also be suffixed by the letter <tt>l</tt> or<tt>L</tt> to specify that it is long.<p>The type of an integer constant depends on its form, value and suffix. (See<a href="#sa.4">Par.A.4</a> for a discussion of types). If it is unsuffixed anddecimal, it has the first of these types in which its value can berepresented: <tt>int</tt>, <tt>long int</tt>, <tt>unsigned long int</tt>. Ifit is unsuffixed, octal or hexadecimal, it has the first possible of thesetypes: <tt>int</tt>, <tt>unsigned int</tt>, <tt>long int</tt>, <tt>unsignedlong int</tt>. If it is suffixed by <tt>u</tt> or <tt>U</tt>, then<tt>unsigned int</tt>, <tt>unsigned long int</tt>. If it is suffixed by<tt>l</tt> or <tt>L</tt>, then <tt>long int</tt>, <tt>unsigned long int</tt>.If an integer constant is suffixed by <tt>UL</tt>, it is <tt>unsigned long</tt>.<dl><dd><font size="-1">The elaboration of the types of integer constants goes considerably beyondthe first edition, which merely caused large integer constants to be<tt>long</tt>. The <tt>U</tt> suffixes are new.</font></dl><h4><a name="sa.2.5.2">A.2.5.2 Character Constants</a></h4>A character constant is a sequence of one or more characters enclosed insingle quotes as in <tt>'x'</tt>. The value of a character constant with onlyone character is the numeric value of the character in the machine'scharacter set at execution time. The value of a multi-character constant isimplementation-defined.<p>Character constants do not contain the <tt>'</tt> character or newlines; inorder to represent them, and certain other characters, the following escapesequences may be used:<p><table align="center" border=1><td>newline        </td><td>NL (LF)&nbsp;</td><td><tt>\n</tt>&nbsp;&nbsp;&nbsp;&nbsp;</td><td>backslash    </td><td><tt>\</tt>  </td><td><tt>\\</tt></td><tr><td>horizontal tab </td><td>HT     </td><td><tt>\t</tt></td><td>question mark</td><td><tt>?</tt>  </td><td><tt>\?</tt></td><tr><td>vertical tab   </td><td>VT     </td><td><tt>\v</tt></td><td>single quote </td><td><tt>'</tt>  </td><td><tt>\'</tt></td><tr><td>backspace      </td><td>BS     </td><td><tt>\b</tt></td><td>double quote </td><td><tt>"</tt>  </td><td><tt>\"</tt></td><tr><td>carriage return</td><td>CR     </td><td><tt>\r</tt></td><td>octal number </td><td><tt>ooo</tt></td><td><tt>\ooo</tt></td><tr><td>formfeed       </td><td>FF     </td><td><tt>\f</tt></td><td>hex number   </td><td><tt>hh</tt> </td><td><tt>\xhh</tt></td><tr><td>audible alert  </td><td>BEL    </td><td><tt>\a</tt></td></table><p>The escape <tt>\ooo</tt> consists of the backslash followed by 1, 2,or 3 octal digits, which are taken to specify the value of the desiredcharacter. A common example of this construction is <tt>\0</tt>(not followed by a digit), which specifies the character NUL. The escape<tt>\xhh</tt> consists of the backslash, followed by <tt>x</tt>, followedby hexadecimal digits, which are taken to specify the value of the desiredcharacter. There is no limit on the number of digits, but the behavior isundefined if the resulting character value exceeds that of the largestcharacter. For either octal or hexadecimal escape characters, if theimplementation treats the <tt>char</tt> type as signed, the value issign-extended as if cast to <tt>char</tt> type. If the character following the\ is not one of those specified, the behavior is undefined.<p>In some implementations, there is an extended set of characters that cannotbe represented in the <tt>char</tt> type. A constant in this extended set iswritten with a preceding <tt>L</tt>, for example <tt>L'x'</tt>, and is called awide character constant. Such a constant has type <tt>wchar_t</tt>, an integraltype defined in the standard header <tt>&lt;stddef.h&gt;</tt>. As with ordinarycharacter constants, hexadecimal escapes may be used; the effect is undefinedif the specified value exceeds that representable with <tt>wchar_t</tt>.<p><dl><dd><font size="-1">Some of these escape sequences are new, in particular the hexadecimalcharacter representation. Extended characters are also new. The charactersets commonly used in the Americas and western Europe can be encoded to fitin the <tt>char</tt> type; the main intent in adding <tt>wchar_t</tt> was toaccommodate Asian languages.</font></dl><h4><a name="sa.2.5.3">A.2.5.3 Floating Constants</a></h4>A floating constant consists of an integer part, a decimal part, a fractionpart, an <tt>e</tt> or <tt>E</tt>, an optionally signed integer exponent and anoptional type suffix, one of <tt>f</tt>, <tt>F</tt>, <tt>l</tt>, or <tt>L</tt>.The integer and fraction parts both consist of a sequence of digits. Either theinteger part, or the fraction part (not both) may be missing; either thedecimal point or the <tt>e</tt> and the exponent (not both) may be missing. Thetype is determined by the suffix; <tt>F</tt> or <tt>f</tt> makes it <tt>float</tt>,<tt>L</tt> or <tt>l</tt> makes it <tt>long double</tt>, otherwise it is <tt>double</tt>.<h4><a name="sa.2.5.4">A2.5.4 Enumeration Constants</a></h4>Identifiers declared as enumerators (see <a href="#sa.8.4">Par.A.8.4</a>) areconstants of type <tt>int</tt>.<h3><a name="sa.2.6">A.2.6 String Literals</a></h3>A string literal, also called a string constant, is a sequence of characterssurrounded by double quotes as in <tt>"..."</tt>. A string has type ``array ofcharacters'' and storage class <tt>static</tt> (see <a href="#sa.3">Par.A.3</a> below)and is initialized with the given characters. Whether identical stringliterals are distinct is implementation-defined, and the behavior of aprogram that attempts to alter a string literal is undefined.<p>Adjacent string literals are concatenated into a single string. After anyconcatenation, a null byte <tt>\0</tt> is appended to the string sothat programs that scan the string can find its end. String literals do notcontain newline or double-quote characters; in order to represent them, thesame escape sequences as for character constants are available.<p>As with character constants, string literals in an extended character set arewritten with a preceding <tt>L</tt>, as in <tt>L"..."</tt>. Wide-character stringliterals have type ``array of <tt>wchar_t</tt>.'' Concatenation of ordinary andwide string literals is undefined.<p><dl><dd><font size="-1">The specification that string literals need not be distinct, and theprohibition against modifying them, are new in the ANSI standard, as is theconcatenation of adjacent string literals. Wide-character string literals arenew.</font></dl><h2><a name="sa.3">A.3 Syntax Notation</a></h2>In the syntax notation used in this manual, syntactic categories areindicated by <em>italic</em> type, and literal words and characters in<tt>typewriter</tt> style. Alternative categories are usually listed on separatelines; in a few cases, a long set of narrow alternatives is presented on one

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -