Files
oldlinux-files/Ref-docs/c_lib_guide/1.1.html
2024-02-19 00:21:47 -05:00

224 lines
5.4 KiB
HTML

<html>
<head>
<title>
C Guide--1.1 Characters
</title>
<!-- Changed by: eric huss, 12-Mar-1997 -->
</head>
<body text="#000000" bgcolor="#FFFFFF">
<center>
<table border=0 width=100%>
<tr>
<td align=left width=20% valign=top>
<a href="index.html">
<img src="left.gif" border=0>
Previous Section<br>
TOC</a></td>
<td align=center width=60% valign=top>
| <a href="index.html">Table of Contents</a> |
<a href="index2.html">Index</a> |</td>
<td align=right width=20% valign=top>
<a href="1.2.html">
Next Section
<img src="right.gif" border=0><br>
1.2 Identifiers</a></td>
</tr>
</table>
</center>
<hr>
<p>
<h1>1.1.1 Trigraph Characters</h1>
<p>
A trigraph sequence found in the source code is converted to its respective translation
character. This allows people to enter certain characters that are not allowed under some (rare)
platforms.
<center>
<table>
<tr ALIGN=CENTER>
<td>Trigraph Sequence</td>
<td>Translation Character</td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??=</b></code></td>
<td><code><b>#</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??(</b></code></td>
<td><code><b>[</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??/</b></code></td>
<td><code><b>\</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??)</b></code></td>
<td><code><b>]</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??'</b></code></td>
<td><code><b>^</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??&lt;</b></code></td>
<td><code><b>{</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??!</b></code></td>
<td><code><b>|</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??&gt;</b></code></td>
<td><code><b>}</b></code></td>
</tr>
<tr ALIGN=CENTER>
<td><code><b>??-</b></code></td>
<td><code><b>~</b></code></td>
</tr>
</table>
</center>
Example:
<blockquote><code><b>
printf("No???/n");
</b></code></blockquote>
translates into:
<blockquote><code><b>
printf("No?\n");
</b></code></blockquote>
<h1>1.1.2 Escape sequences</h1>
<p>
The following escape sequences allow special characters to be put
into the source code.
<center>
<table>
<tr>
<td>Escape Sequence</td>
<td>Name</td>
<td>Meaning</td>
</tr>
<tr>
<td><code><b>\a</b></code></td>
<td>Alert</td>
<td>Produces an audible or visible alert.</td>
</tr>
<tr>
<td><code><b>\b</b></code></td>
<td>Backspace</td>
<td>Moves the cursor back one position (non-destructive).</td>
</tr>
<tr>
<td><code><b>\f</b></code></td>
<td>Form Feed</td>
<td>Moves the cursor to the first position of the next page.</td>
</tr>
<tr>
<td><code><b>\n</b></code></td>
<td>New Line</td>
<td>Moves the cursor to the first position of the next line.</td>
</tr>
<tr>
<td><code><b>\r</b></code></td>
<td>Carriage Return</td>
<td>Moves the cursor to the first position of the current line.</td>
</tr>
<tr>
<td><code><b>\t</b></code></td>
<td>Horizontal Tab</td>
<td>Moves the cursor to the next horizontal tabular position.</td>
</tr>
<tr>
<td><code><b>\v</b></code></td>
<td>Vertical Tab</td>
<td>Moves the cursor to the next vertical tabular position.</td>
</tr>
<tr>
<td><code><b>\'</b></code></td>
<td></td>
<td>Produces a single quote.</td>
</tr>
<tr>
<td><code><b>\"</b></code></td>
<td></td>
<td>Produces a double quote.</td>
</tr>
<tr>
<td><code><b>\?</b></code></td>
<td></td>
<td>Produces a question mark.</td>
</tr>
<tr>
<td><code><b>\\</b></code></td>
<td></td>
<td>Produces a single backslash.</td>
</tr>
<tr>
<td><code><b>\0</b></code></td>
<td></td>
<td>Produces a null character.</td>
</tr>
<tr>
<td><code><b>\</b></code><i>ddd</i></td>
<td></td>
<td>Defines one character by the octal digits (base-8 number).
Multiple characters may be defined in the same escape
sequence, but the value is implementation-specific (see examples).
</td>
</tr>
<tr>
<td><code><b>\x</b></code><i>dd</i></td>
<td></td>
<td>Defines one character by the hexadecimal digit (base-16 number).</td>
</tr>
</table>
</center>
Examples:
<blockquote>
<code><b>printf("\12");</b></code><br>
Produces the decimal character 10 (x0A Hex).<br>
<br>
<code><b>printf("\xFF");</b></code><br>
Produces the decimal character -1 or 255 (depending on sign).<br>
<br>
<code><b>printf("\x123");</b></code><br>
Produces a single character (value is undefined). May cause errors.<br>
<br>
<code><b>printf("\0222");</b></code><br>
Produces two characters whose values are implementation-specific.
</blockquote>
<h1>1.1.3 Comments</h1>
<p>
Comments in the source code are ignored by the compiler. They are encapsulated
starting with <code><b>/*</b></code> and ending with
<code><b>*/</b></code>. According to the ANSI standard,
nested comments are not allowed, although some implementations allow it.
<p>
Single line comments are becoming more common, although not defined in the ANSI
standard. Single line comments begin with <code><b>//</b></code> and are
automatically terminated at the end of the current line.
<hr>
<center>
<table border=0 width=100%>
<tr>
<td align=left width=20% valign=top>
<a href="index.html">
<img src="left.gif" border=0>
Previous Section<br>
TOC</a></td>
<td align=center width=60% valign=top>
| <a href="index.html">Table of Contents</a> |
<a href="index2.html">Index</a> |</td>
<td align=right width=20% valign=top>
<a href="1.2.html">
Next Section
<img src="right.gif" border=0><br>
1.2 Identifiers</a></td>
</tr>
</table>
</center>
</body>
</html>