非常教程

C参考手册

C 语法

Alternative operators and tokens

C 源代码可以用任何包含 ISO 646:1983不变字符集的非 ASCII 8位字符集编写。但是,几个 C 操作符和标点符号需要 ISO 646代码集之外的字符:{, }, [, ], #, \, ^, |, ~。为了能够使用其中部分或全部符号不存在的字符编码(例如德国 DIN 66003),有两种可能性:使用这些字符的操作符的替代拼写或两个或三个 ISO 646兼容字符的特殊组合这被解释为它们是单个非 ISO 646字符。

运算符宏(C95)

对于使用以 ISO <iso646.h>宏定义的非 ISO646字符的操作符,还有其他拼写方式:

| Defined in header <iso646.h> |

|:----|

| Primary | Alternative |

| && | and (macro constant) |

| &= | and_eq (macro constant) |

| & | bitand (macro constant) |

| | | bitor (macro constant) |

| ~ | compl (macro constant) |

| ! | not (macro constant) |

| != | not_eq (macro constant) |

| || | or (macro constant) |

| |= | or_eq (macro constant) |

| ^ | xor (macro constant) |

| ^= | xor_eq (macro constant) |

字符&!是不变的 ISO-646下,但提供了使用这些字符无论如何,以适应更加严格的历史字符集运营商的替代品。

eq对于相等运算符没有其他拼写(如),==因为该字符=出现在所有支持的字符集中。

Alternative tokens(C95)

以下替代令牌是核心语言的一部分,并且在各方面的语言中,每个替代令牌的行为与其主令牌完全相同,但其拼写(字符串操作符可以使拼写可见)除外。两个字母的替代令牌有时被称为“二元符号”

Primary

Alternative

{

<%

}

%>

[

<:

]

:>

%:

%:%:

Trigraphs

在识别注释和字符串文字之前,会分析以下三个字符组(trigraphs),并且每个三角形的外观都会被相应的主要字符替换:

Primary

Trigraph

{

??<

}

??>

[

??(

]

??)

??=

\

??/

^

??'

|

??!

~

??-

由于 trigraphs 被提前处理,所以注释// Will the next line be executed?????/会有效地注释掉下面的行,并将字符串文字(比如"What's going on??!"被解析为)注释掉"What's going on|"

以下示例演示了<iso646.h>头文件中的替代运算符拼写以及使用二元和三元符。

第一个命令行参数 argv1中的空格字符需要引号:“,World!”。

%:include <stdlib.h>
%:include <stdio.h>
%:include <iso646.h>
 
int main(int argc, char** argv)
??<
    if (argc > 1 and argv<:1:> not_eq NULL)
    <%
       printf("Hello%s\n", argv<:1:>);
    %>
 
    return EXIT_SUCCESS;
??>

可能的输出:

Hello, World!

C 语法相关

1.#define directive
2.#elif directive
3.#else directive
4.#endif directive
5.#error directive
6.#if directive
7.#ifdef directive
8.#ifndef directive
9.#include directive
10.#line directive
11.#pragma directive
12.alignas
13.Analyzability
14.Arithmetic operators
15.Arithmetic types
16.Array declaration
17.Array initialization
18.ASCII Chart
19.Assignment operators
20. types
21.Basic concepts
22.Bit fields
23.break statement
24.C language
25.C Operator Precedence
26.cast operator
27.character constant
28.Comments
29.Comparison operators
30.compound literals
31.Conditional inclusion
32.Conformance
33.const type qualifier
34.Constant expressions
35.continue statement
36.Declarations
37.do-while loop
38.Enumerations
39.Escape sequences
40.Expressions
41.External and tentative definitions
42.File scope
43.floating constant
44.for loop
45.Function declarations
46.Function definitions
47.Functions
48.Generic selection
49.goto statement
50.Identifier
51.if statement
52.Implicit conversions
53.Increment/decrement operators
54.Initialization
55.inline function specifier
56.integer constant
57.Lifetime
58.Logical operators
59.Lookup and name spaces
60.Main function
61.Member access operators
62.Memory model
63.Objects and alignment
64.Order of evaluation
65.Other operators
66.Phases of translation
67.Pointer declaration
68.Preprocessor
69.restrict type qualifier
70.return statement
71.Scalar initialization
72.Scope
73.sizeof operator
74.Statements
75.static assert declaration
76.Static storage duration
77.Storage-class specifiers
78.string literals
79.Struct and union initialization
80.Struct declaration
81.switch statement
82.Thread storage duration
83.Type
84.Type
85.Typedef declaration
86.Undefined behavior
87.Union declaration
88.Value categories
89.Variadic arguments
90.volatile type qualifier
91.while loop
92._Alignof operator
93._Noreturn function specifier
C

C 语言是一门通用计算机编程语言,应用广泛。C 语言的设计目标是提供一种能以简易的方式编译、处理低级存储器、产生少量的机器码以及不需要任何运行环境支持便能运行的编程语言。