source: public/doc/gnu-c/Operators_002fPunctuation.html@ 02598c2

Last change on this file since 02598c2 was 02598c2, checked in by Mikhail Kirillov <w96k@…>, on Oct 6, 2022 at 12:36:29 PM

Add gnu-c

  • Property mode set to 100644
File size: 6.6 KB
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- Copyright (C) 2022 Richard Stallman and Free Software Foundation, Inc.
4
5(The work of Trevis Rothwell and Nelson Beebe has been assigned or
6licensed to the FSF.)
7
8Permission is granted to copy, distribute and/or modify this document
9under the terms of the GNU Free Documentation License, Version 1.3 or
10any later version published by the Free Software Foundation; with the
11Invariant Sections being "GNU General Public License," with the
12Front-Cover Texts being "A GNU Manual," and with the Back-Cover
13Texts as in (a) below. A copy of the license is included in the
14section entitled "GNU Free Documentation License."
15
16(a) The FSF's Back-Cover Text is: "You have the freedom to copy and
17modify this GNU manual. Buying copies from the FSF supports it in
18developing GNU and promoting software freedom." -->
19<!-- Created by GNU Texinfo 6.7, http://www.gnu.org/software/texinfo/ -->
20<head>
21<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
22<title>Operators/Punctuation (GNU C Language Manual)</title>
23
24<meta name="description" content="Operators/Punctuation (GNU C Language Manual)">
25<meta name="keywords" content="Operators/Punctuation (GNU C Language Manual)">
26<meta name="resource-type" content="document">
27<meta name="distribution" content="global">
28<meta name="Generator" content="makeinfo">
29<link href="index.html" rel="start" title="Top">
30<link href="Symbol-Index.html" rel="index" title="Symbol Index">
31<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
32<link href="Lexical-Syntax.html" rel="up" title="Lexical Syntax">
33<link href="Line-Continuation.html" rel="next" title="Line Continuation">
34<link href="Identifiers.html" rel="prev" title="Identifiers">
35<style type="text/css">
36<!--
37a.summary-letter {text-decoration: none}
38blockquote.indentedblock {margin-right: 0em}
39div.display {margin-left: 3.2em}
40div.example {margin-left: 3.2em}
41div.lisp {margin-left: 3.2em}
42kbd {font-style: oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47span.nolinebreak {white-space: nowrap}
48span.roman {font-family: initial; font-weight: normal}
49span.sansserif {font-family: sans-serif; font-weight: normal}
50ul.no-bullet {list-style: none}
51-->
52</style>
53
54
55</head>
56
57<body lang="en">
58<span id="Operators_002fPunctuation"></span><div class="header">
59<p>
60Next: <a href="Line-Continuation.html" accesskey="n" rel="next">Line Continuation</a>, Previous: <a href="Identifiers.html" accesskey="p" rel="prev">Identifiers</a>, Up: <a href="Lexical-Syntax.html" accesskey="u" rel="up">Lexical Syntax</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
61</div>
62<hr>
63<span id="Operators-and-Punctuation"></span><h3 class="section">5.6 Operators and Punctuation</h3>
64<span id="index-operators"></span>
65<span id="index-punctuation"></span>
66
67<p>Here we describe the lexical syntax of operators and punctuation in C.
68The specific operators of C and their meanings are presented in
69subsequent chapters.
70</p>
71<p>Most operators in C consist of one or two characters that can&rsquo;t be
72used in identifiers. The characters used for operators in C are
73&lsquo;<samp>!~^&amp;|*/%+-=&lt;&gt;,.?:</samp>&rsquo;.
74</p>
75<p>Some operators are a single character. For instance, &lsquo;<samp>-</samp>&rsquo; is the
76operator for negation (with one operand) and the operator for
77subtraction (with two operands).
78</p>
79<p>Some operators are two characters. For example, &lsquo;<samp>++</samp>&rsquo; is the
80increment operator. Recognition of multicharacter operators works by
81grouping together as many consecutive characters as can constitute one
82operator.
83</p>
84<p>For instance, the character sequence &lsquo;<samp>++</samp>&rsquo; is always interpreted
85as the increment operator; therefore, if we want to write two
86consecutive instances of the operator &lsquo;<samp>+</samp>&rsquo;, we must separate them
87with a space so that they do not combine as one token. Applying the
88same rule, <code>a+++++b</code> is always tokenized as <code>a++&nbsp;++&nbsp;+&nbsp;b<!-- /@w --></code>, not as <code>a++&nbsp;+&nbsp;++b<!-- /@w --></code>, even though the latter could be part
89of a valid C program and the former could not (since <code>a++</code>
90is not an lvalue and thus can&rsquo;t be the operand of <code>++</code>).
91</p>
92<p>A few C operators are keywords rather than special characters. They
93include <code>sizeof</code> (see <a href="Type-Size.html">Type Size</a>) and <code>_Alignof</code>
94(see <a href="Type-Alignment.html">Type Alignment</a>).
95</p>
96<p>The characters &lsquo;<samp>;{}[]()</samp>&rsquo; are used for punctuation and grouping.
97Semicolon (&lsquo;<samp>;</samp>&rsquo;) ends a statement. Braces (&lsquo;<samp>{</samp>&rsquo; and
98&lsquo;<samp>}</samp>&rsquo;) begin and end a block at the statement level
99(see <a href="Blocks.html">Blocks</a>), and surround the initializer (see <a href="Initializers.html">Initializers</a>)
100for a variable with multiple elements or components (such as arrays or
101structures).
102</p>
103<p>Square brackets (&lsquo;<samp>[</samp>&rsquo; and &lsquo;<samp>]</samp>&rsquo;) do array indexing, as in
104<code>array[5]</code>.
105</p>
106<p>Parentheses are used in expressions for explicit nesting of
107expressions (see <a href="Basic-Arithmetic.html">Basic Arithmetic</a>), around the parameter
108declarations in a function declaration or definition, and around the
109arguments in a function call, as in <code>printf (&quot;Foo %d\n&quot;, i)</code>
110(see <a href="Function-Calls.html">Function Calls</a>). Several kinds of statements also use
111parentheses as part of their syntax&mdash;for instance, <code>if</code>
112statements, <code>for</code> statements, <code>while</code> statements, and
113<code>switch</code> statements. See <a href="if-Statement.html">if Statement</a>, and following
114sections.
115</p>
116<p>Parentheses are also required around the operand of the operator
117keywords <code>sizeof</code> and <code>_Alignof</code> when the operand is a data
118type rather than a value. See <a href="Type-Size.html">Type Size</a>.
119</p>
120<hr>
121<div class="header">
122<p>
123Next: <a href="Line-Continuation.html" accesskey="n" rel="next">Line Continuation</a>, Previous: <a href="Identifiers.html" accesskey="p" rel="prev">Identifiers</a>, Up: <a href="Lexical-Syntax.html" accesskey="u" rel="up">Lexical Syntax</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Index.html" title="Index" rel="index">Index</a>]</p>
124</div>
125
126
127
128</body>
129</html>
Note: See TracBrowser for help on using the repository browser.