add directory Ref-docs
This commit is contained in:
223
Ref-docs/c_lib_guide/1.1.html
Normal file
223
Ref-docs/c_lib_guide/1.1.html
Normal file
@@ -0,0 +1,223 @@
|
||||
<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>??<</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>
|
||||
</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>
|
||||
567
Ref-docs/c_lib_guide/1.2.html
Normal file
567
Ref-docs/c_lib_guide/1.2.html
Normal file
@@ -0,0 +1,567 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--1.2 Indentifiers
|
||||
</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF">
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.1.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.1 Characters</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.3.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.3 Functions</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
<p>
|
||||
|
||||
|
||||
<a name="keywords"></a>
|
||||
<h1>1.2.1 Keywords</h1>
|
||||
<p>
|
||||
The following keywords are reserved and may not be used as an
|
||||
identifier for any other purpose.
|
||||
<center>
|
||||
<table>
|
||||
<tr>
|
||||
<td><code><b>auto</b></code></td>
|
||||
<td><code><b>double</b></code></td>
|
||||
<td><code><b>int</b></code></td>
|
||||
<td><code><b>long</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>break</b></code></td>
|
||||
<td><code><b>else</b></code></td>
|
||||
<td><code><b>long</b></code></td>
|
||||
<td><code><b>switch</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>case</b></code></td>
|
||||
<td><code><b>enum</b></code></td>
|
||||
<td><code><b>register</b></code></td>
|
||||
<td><code><b>typedef</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>char</b></code></td>
|
||||
<td><code><b>extern</b></code></td>
|
||||
<td><code><b>return</b></code></td>
|
||||
<td><code><b>union</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>const</b></code></td>
|
||||
<td><code><b>float</b></code></td>
|
||||
<td><code><b>short</b></code></td>
|
||||
<td><code><b>unsigned</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>continue</b></code></td>
|
||||
<td><code><b>for</b></code></td>
|
||||
<td><code><b>signed</b></code></td>
|
||||
<td><code><b>void</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>default</b></code></td>
|
||||
<td><code><b>goto</b></code></td>
|
||||
<td><code><b>sizeof</b></code></td>
|
||||
<td><code><b>volatile</b></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>do</b></code></td>
|
||||
<td><code><b>if</b></code></td>
|
||||
<td><code><b>static</b></code></td>
|
||||
<td><code><b>while</b></code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<a name="variables"></a>
|
||||
<h1>1.2.2 Variables</h1>
|
||||
<p>
|
||||
A variable may be defined using any uppercase or lowercase character,
|
||||
a numerical digit
|
||||
(0 through 9), and the underscore character (_). The first character
|
||||
of the variable may not be a
|
||||
numerical digit or underscore. Variable names are case sensitive.
|
||||
<p>
|
||||
The scope of the variable (where it can be used), is determined
|
||||
by where it is defined. If
|
||||
it is defined outside any block or list of parameters, then it has
|
||||
<i>file scope</i>. This means it may be
|
||||
accessed anywhere in the current source code file. This is normally
|
||||
called a global variable and
|
||||
is normally defined at the top of the source code. All other types
|
||||
of variables are local variables.
|
||||
If a variable is defined in a block (encapsulated with <code><b>{</b></code>
|
||||
and <code><b>}</b></code>), then its scope begins when the
|
||||
variable is defined and ends when it hits the terminating
|
||||
<code><b>}</b></code>. This is called <i>block scope</i>. If the
|
||||
variable is defined in a function prototype, then the variable may
|
||||
only be accessed in that
|
||||
function. This is called <i>function prototype scope</i>.
|
||||
<p>
|
||||
Access to variables outside of their file scope can be made by using
|
||||
<i>linkage</i>. Linkage is
|
||||
done by placing the keyword <code><b>extern</b></code> prior to a variable
|
||||
declaration. This allows a variable that is
|
||||
defined in another source code file to be accessed.
|
||||
<p>
|
||||
Variables defined within a function scope have <i>automatic storage
|
||||
duration</i>. The life of
|
||||
the variable is determined by the life of the function. Space is
|
||||
allocated at the beginning of the
|
||||
function and terminated at the end of the function. <i>Static storage
|
||||
duration</i> can be obtained by
|
||||
placing the keyword <code><b>static</b></code> in front of the variable
|
||||
declaration. This causes the variable's space
|
||||
to be allocated when the program starts up and is kept during the life of
|
||||
the program. The value
|
||||
of the variable is preserved during subsequent calls to the function that
|
||||
defines it. Variables
|
||||
with file scope are automatically static variables.
|
||||
<p>
|
||||
A variable is defined by the following:
|
||||
<blockquote>
|
||||
<blockquote>
|
||||
<i>storage-class-specifier type-specifier variable-names,...</i><br>
|
||||
</blockquote>
|
||||
The storage-class-specifier can be one of the following:<br>
|
||||
<table>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>typedef</b></code></td>
|
||||
<td>The symbol name "<i>variable-name</i>" becomes a type-specifier
|
||||
of type "<i>type-specifier</i>". No variable is actually created,
|
||||
this is merely for convenience.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>extern</b></code></td>
|
||||
<td>Indicates that the variable is defined outside of the
|
||||
current file. This brings the variables scope into the current
|
||||
scope. No variable is actually created by this.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>static</b></code></td>
|
||||
<td>Causes a variable that is defined within a function to be
|
||||
preserved in subsequent calls to the function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>auto</b></code></td>
|
||||
<td>Causes a local variable to have a local lifetime (default).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>register</b></code></td>
|
||||
<td>Requests that the variable be accessed as quickly as
|
||||
possible. This request is not guaranteed. Normally, the variable's
|
||||
value is kept within a CPU register for maximum speed.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
The type-specifier can be one of the following:<br>
|
||||
<table>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>void</b></code></td>
|
||||
<td VALIGN=TOP>Defines an empty or NULL value whose type is incomplete.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>char, signed char</b></code></td>
|
||||
<td VALIGN=TOP>Variable is large enough to store a basic character in the
|
||||
character set. The value is either signed or nonnegative.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>unsigned char</b></code></td>
|
||||
<td VALIGN=TOP>Same as char, but unsigned values only.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>short, signed short, short int, signed short int</b></code></td>
|
||||
<td VALIGN=TOP>Defines a short signed integer. May be the same range as a
|
||||
normal int, or half the bits of a normal int.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>unsigned short, unsigned short int</b></code></td>
|
||||
<td VALIGN=TOP>Defines an unsigned short integer.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>int, signed, signed int</b></code>, or no type specifier</td>
|
||||
<td VALIGN=TOP>Defines a signed integer. If no type specifier is given,
|
||||
then this is the default.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>unsigned int, unsigned</b></code></td>
|
||||
<td VALIGN=TOP>Same as int, but unsigned values only.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>long, signed long, long int, signed long int</b></code></td>
|
||||
<td VALIGN=TOP>Defines a long signed integer. May be twice the bit size
|
||||
as a normal int, or the same as a normal int.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>unsigned long, unsigned long int</b></code></td>
|
||||
<td VALIGN=TOP>Same as long, but unsigned values only.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>float</b></code></td>
|
||||
<td VALIGN=TOP> A floating-point number. Consists of a sign, a mantissa
|
||||
(number greater than or equal to 1), and an exponent. The
|
||||
mantissa is taken to the power of the exponent then given the
|
||||
sign. The exponent is also signed allowing extremely small
|
||||
fractions. The mantissa gives it a finite precision.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>double</b></code></td>
|
||||
<td VALIGN=TOP>A more accurate floating-point number than float. Normally
|
||||
twice as many bits in size.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td VALIGN=TOP><code><b>long double</b></code></td>
|
||||
<td VALIGN=TOP>Increases the size of double.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</blockquote>
|
||||
<p>
|
||||
Here are the maximum and minimum sizes of the type-specifiers on
|
||||
most common implementations. Note: some implementations may be
|
||||
different.<br>
|
||||
<center>
|
||||
<table>
|
||||
<tr>
|
||||
<td><b>Type</b></td>
|
||||
<td><b>Size</b></td>
|
||||
<td><b>Range</b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>unsigned char</b></code></td>
|
||||
<td>8 bits</td>
|
||||
<td>0 to 255</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>char</b></code></td>
|
||||
<td>8 bits</td>
|
||||
<td>-128 to 127</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>unsigned int</b></code></td>
|
||||
<td>16 bits</td>
|
||||
<td>0 to 65,535</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>short int</b></code></td>
|
||||
<td>16 bits</td>
|
||||
<td>-32,768 to 32,767</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>int</b></code></td>
|
||||
<td>16 bits</td>
|
||||
<td>-32,768 to 32,767</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>unsigned long</b></code></td>
|
||||
<td>32 bits</td>
|
||||
<td>0 to 4,294,967,295</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>long</b></code></td>
|
||||
<td>32 bits</td>
|
||||
<td>-2,147,483,648 to 2,147,483,647</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>float</b></code></td>
|
||||
<td>32 bits</td>
|
||||
<td>1.17549435 * (10^-38) to 3.40282347 * (10^+38)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>double</b></code></td>
|
||||
<td>64 bits</td>
|
||||
<td>2.2250738585072014 * (10^-308) to 1.7976931348623157 * (10^+308)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>long double</b></code></td>
|
||||
<td>80 bits</td>
|
||||
<td>3.4 * (10^-4932) to 1.1 * (10^4932)</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
Examples:<br>
|
||||
<blockquote>
|
||||
<code><b>int bob=32;</b></code><br>
|
||||
Creates variable "bob" and initializes it to the value 32.<br>
|
||||
<br>
|
||||
<code><b>char loop1,loop2,loop3='\x41';</b></code><br>
|
||||
Creates three variables. The value of "loop1" and "loop2"
|
||||
is undefined. The value of loop3 is the letter "A".<br>
|
||||
<br>
|
||||
<code><b>typedef char boolean;</b></code><br>
|
||||
Causes the keyword "boolean" to represent variable-type "char".<br>
|
||||
<br>
|
||||
<code><b>boolean yes=1;</b></code><br>
|
||||
Creates variable "yes" as type "char" and sets its value to 1.
|
||||
</blockquote>
|
||||
|
||||
<a name="enum"></a>
|
||||
<h1>1.2.3 Enumerated Tags</h1>
|
||||
<p>
|
||||
Enumeration allows a series of constant integers to be easily
|
||||
assigned. The format to create a enumeration specifier is:
|
||||
<blockquote>
|
||||
<code><b>enum </b></code><i>identifier</i><code><b>
|
||||
{</code></b><i>enumerator-list</i><code><b>};</b></code><br>
|
||||
<i>Identifier</i> is a handle for identification, and is optional.<br>
|
||||
<i>Enumerator-list</i> is a list of variables to be created. They
|
||||
will be constant integers. Each variable is given the value of the
|
||||
previous variable plus 1. The first variable is given the value of 0.
|
||||
</blockquote>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b>enum {joe, mary, bob, fran};</b></code><br>
|
||||
Creates 4 variables. The value of joe is 0, mary is 1,
|
||||
bob is 2, and fran is 3.<br>
|
||||
<br>
|
||||
<ocde><b>enum test {larry, floyd=20, ted};</b></code><br>
|
||||
Creates 3 variables with the identifier test. The value of larry is
|
||||
0, floyd is 20, and ted is 21.
|
||||
</blockquote>
|
||||
<a name="arrays"></a>
|
||||
<h1>1.2.4 Arrays</h1>
|
||||
<p>
|
||||
Arrays create single or multidimensional matrices. They are defined
|
||||
by appending an integer encapsulated in brackets at the end of a variable
|
||||
name. Each additional set of brackets defines an additional dimension to
|
||||
the array. When addressing an index in the array, indexing
|
||||
begins at 0 and ends at 1 less than the defined array. If no initial
|
||||
value is given to the array size, then the size is determined by the
|
||||
initializers. When defining a multidimensional array, nested
|
||||
curly braces can be used to specify which dimension of the array to
|
||||
initialize. The outermost nest of curly braces defines the leftmost
|
||||
dimension, and works from left to right.
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b>int x[5];</b></code><br>
|
||||
Defines 5 integers starting at x[0], and ending at x[4].
|
||||
Their values are undefined.<br>
|
||||
<br>
|
||||
<code><b>char str[16]="Blueberry";</b></code><br>
|
||||
Creates a string. The value at str[8] is the character
|
||||
"y". The value at str[9] is the null character. The values
|
||||
from str[10] to str[15] are undefined.<br>
|
||||
<br>
|
||||
<code><b>char s[]="abc";</b></code><br>
|
||||
Dimensions the array to 4 (just long enough to hold the
|
||||
string plus a null character), and stores the string in the array.<br>
|
||||
<br>
|
||||
<code><b>int y[3]={4};</b></code><br>
|
||||
Sets the value of y[0] to 4 and y[1] and y[2] to 0.<br>
|
||||
<br>
|
||||
<pre><code><b>int joe[4][5]={
|
||||
{1,2,3,4,5},
|
||||
{6,7,8,9,10},
|
||||
{11,12,13,14,15}
|
||||
};</b></code></pre>
|
||||
The first row initializes joe[0], the second row joe[1] and so
|
||||
forth. joe[3] is initialized to 5 zeros.<br>
|
||||
<br>
|
||||
The same effect is achieved by:<br>
|
||||
<code><b>int joe[4][5]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};</b></code>
|
||||
</blockquote>
|
||||
<a name="struct"></a>
|
||||
<h1>1.2.5 Structures and Unions</h1>
|
||||
<p>
|
||||
Structures and unions provide a way to group common variables
|
||||
together. To define a structure use:
|
||||
<blockquote>
|
||||
<pre><code><b>struct </b></code><i>structure-name</i><code><b> {</b></code>
|
||||
|
||||
<i>variables,...</i>
|
||||
|
||||
<code><b>}</code></b> <i>structure-variables,...</i><code><b>;</b></code></pre>
|
||||
<br>
|
||||
</blockquote>
|
||||
<i>Structure-name</i> is optional and not needed if the structure
|
||||
variables are defined. Inside it can contain any number of
|
||||
variables separated by semicolons. At the end,
|
||||
<i>structure-variables</i> defines the actual names of the
|
||||
individual structures. Multiple structures can be defined by
|
||||
separating the variable names with commas. If no
|
||||
<i>structure-variables</i> are given, no variables are created.
|
||||
<i>Structure-variables</i> can be defined separately by specifying:<br>
|
||||
<br>
|
||||
<blockquote>
|
||||
<code><b>struct </b></code><i>structure-name new-structure-variable</i><code><b>;</b></code><br>
|
||||
</blockquote>
|
||||
<i>new-structure-variable</i> will be created and has a separate
|
||||
instance of all the variables in <i>structure-name</i>.<br>
|
||||
<br>
|
||||
To access a variable in the structure, you must use a record
|
||||
selector (<code><b>.</b></code>).<br>
|
||||
<br>
|
||||
Unions work in the same way as structures except that all variables
|
||||
are contained in the same location in memory. Enough space is allocated
|
||||
for only the largest variable in the union. All other variables must
|
||||
share the same memory location. Unions are defined using the union
|
||||
keyword.
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<pre><code><b>struct my-structure {
|
||||
int fred[5];
|
||||
char wilma, betty;
|
||||
float barny=1;
|
||||
};</b></code></pre>
|
||||
This defines the structure my-structure, but nothing has yet been done.<br>
|
||||
<br>
|
||||
<code><b>struct my-structure account1;</b></code><br>
|
||||
This creates account1 and it has all of the variables from
|
||||
my-structure. account1.barny contains the value "1".<br>
|
||||
<br>
|
||||
<pre><code><b>union my-union {
|
||||
char character_num;
|
||||
int integer_num;
|
||||
long long_num;
|
||||
float float_num;
|
||||
double double_num;
|
||||
} number;</b></code></pre>
|
||||
This defines the union number and allocates just enough space for
|
||||
the variable double_num.<br>
|
||||
<br>
|
||||
<code><b>number.integer_num=1;</b></code><br>
|
||||
Sets the value of integer_num to "1".<br>
|
||||
<code><b>number.float_num=5;</b></code><br>
|
||||
Sets the value of float_num to "5".<br>
|
||||
<code><b>printf("%i",integer_num);</b></code><br>
|
||||
This is undefined since the location of integer_num was overwritten
|
||||
in the previous line by float_num.
|
||||
</blockquote>
|
||||
<a name="const"></a>
|
||||
<h1>1.2.6 Constants</h1>
|
||||
<p>
|
||||
Constants provide a way to define a variable which cannot be
|
||||
modified by any other part in the code. Constants can be defined by
|
||||
placing the keyword <code><b>const</b></code> in front of any variable
|
||||
declaration. If the keyword <code><b>volatile</b></code> is placed after
|
||||
<code><b>const</b></code>, then this allows external routines to modify the
|
||||
variable (such
|
||||
as hardware devices). This also forces the compiler to retrieve the
|
||||
value of the variable each time it is referenced rather than possibly
|
||||
optimizing it in a register.
|
||||
<p>
|
||||
Constant numbers can be defined in the following way:
|
||||
<blockquote>
|
||||
Hexadecimal constant:
|
||||
<blockquote>
|
||||
<code><b>0x </b></code><i>hexadecimal digits...</i><br>
|
||||
Where <i>hexadecimal digits</i> is any digit or any letter
|
||||
<code><b>A</b></code> through <code><b>F</b></code> or <code><b>a</b></code>
|
||||
through <code><b>f</b></code>.
|
||||
</blockquote>
|
||||
Decimal constant:
|
||||
<blockquote>
|
||||
Any number where the first number is not zero.
|
||||
</blockquote>
|
||||
Octal constant:
|
||||
<blockquote>
|
||||
Any number where the first number must be zero.
|
||||
</blockquote>
|
||||
Floating constant:
|
||||
<blockquote>
|
||||
A fractional number, optionally followed by either
|
||||
<code><b>e</b></code> or <code><b>E</b></code> then the exponent.
|
||||
</blockquote>
|
||||
|
||||
The number may be suffixed by:<br>
|
||||
<code><b>U</b></code> or <code><b>u</b></code>:
|
||||
<blockquote>
|
||||
Causes the number to be an unsigned long integer.
|
||||
</blockquote>
|
||||
<code><b>L</b></code> or <code><b>l</b></code>:
|
||||
<blockquote>
|
||||
If the number is a floating-point number, then it is a long
|
||||
double, otherwise it is an unsigned long integer.
|
||||
</blockquote>
|
||||
<code><b>F</b></code> or <code><b>f</b></code>:
|
||||
<blockquote>
|
||||
Causes the number to be a floating-point number.
|
||||
</blockquote>
|
||||
</blockquote>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b>const float PI=3.141;</b></code><br>
|
||||
Causes the variable PI to be created with value 3.141.
|
||||
Any subsequent attempts to write to PI are not allowed.<br>
|
||||
<br>
|
||||
<code><b>const int joe=0xFFFF;</b></code><br>
|
||||
Causes joe to be created with the value of 65535 decimal.<br>
|
||||
<br>
|
||||
<code><b>const float penny=7.4e5;</b></code><br>
|
||||
Causes penny to be created with the value of 740000.000000.
|
||||
</blockquote>
|
||||
|
||||
<a name="strings"></a>
|
||||
<h1>1.2.7 Strings</h1>
|
||||
<p>
|
||||
Strings are simply an array of characters encapsulated in double
|
||||
quotes. At the end of the string a null character is appended.
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b>"\x65"</b></code> and <code><b>"A"</b></code> are the same
|
||||
string.<br>
|
||||
<br>
|
||||
<code><b>char fred[25]="He said, \"Go away!\"";</b></code><br>
|
||||
The value at fred[9] is a double quote. The value at fred[20] is
|
||||
the null character.
|
||||
</blockquote>
|
||||
|
||||
<a name="sizeof"></a>
|
||||
<h1>1.2.8 sizeof Keyword</h1>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>size_t sizeof </b></code><i>expression</i>
|
||||
</blockquote>
|
||||
<i>or</i>
|
||||
<blockquote>
|
||||
<code><b>size_t sizeof (</b></code><i>type</i><code><b>)</b></code>
|
||||
</blockquote>
|
||||
The sizeof keyword returns the number of bytes of the given
|
||||
expression or type.<br>
|
||||
<code><b>size_t</b></code> is an unsigned integer result.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote>
|
||||
<code><b>printf("The number of bytes in an int is %d.\n",sizeof(int));</b></code>
|
||||
</blockquote>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.1.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.1 Characters</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.3.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.3 Functions</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
158
Ref-docs/c_lib_guide/1.3.html
Normal file
158
Ref-docs/c_lib_guide/1.3.html
Normal file
@@ -0,0 +1,158 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--1.3 Functions
|
||||
</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="1.2.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.2 Identifiers</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.4.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.4 References</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<p>
|
||||
|
||||
|
||||
<hr>
|
||||
<h1>1.3.1 Function Definition</h1>
|
||||
<p>
|
||||
A function is declared in the following manner:
|
||||
<blockquote>
|
||||
<i>return-type function-name</i><code><b>(</b></code><i>parameter-list,...</i><code><b>) { </b></code><i>body...</i><code><b> }</b></code>
|
||||
</blockquote>
|
||||
<i>return-type</i> is the variable type that the function returns. This can
|
||||
not be an array type or a function type. If not given, then
|
||||
<code><b>int</b></code> is assumed.
|
||||
<p>
|
||||
<i>function-name</i> is the name of the function.
|
||||
<p>
|
||||
<i>parameter-list</i> is the list of parameters that the function takes
|
||||
separated by commas. If no parameters are given, then the function does
|
||||
not take any and should be defined with an empty set of parenthesis or
|
||||
with the keyword <code><b>void</b></code>. If no variable type is in front
|
||||
of a variable in
|
||||
the paramater list, then <code><b>int</b></code> is assumed. Arrays and
|
||||
functions are not
|
||||
passed to functions, but are automatically converted to pointers. If the
|
||||
list is terminated with an ellipsis (<code><b>,...</b></code>), then there
|
||||
is no set number of
|
||||
parameters. Note: the header <code><b>stdarg.h</b></code> can be used to
|
||||
access arguments when using an ellipsis.
|
||||
<p>
|
||||
If the function is accessed before it is defined, then it must be
|
||||
prototyped so the compiler knows about the function. Prototyping normally
|
||||
occurs at the beginning of the source code, and is done in the following
|
||||
manner:
|
||||
<blockquote>
|
||||
<i>return-type function-name</i><code><b>(</b></code><i>paramater-type-list</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
<i>return-type</i> and <i>function-name</i> must correspond exactly to the
|
||||
actual
|
||||
function definition. <i>parameter-type-list</i> is a list separated by
|
||||
commas of
|
||||
the types of variable parameters. The actual names of the parameters do
|
||||
not have to be given here, although they may for the sake of clarity.
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b>int joe(float, double, int);</b></code><br>
|
||||
This defines the prototype for function joe.<br>
|
||||
<br>
|
||||
<pre><code><b>int joe(float coin, double total, int sum)
|
||||
{
|
||||
/*...*/
|
||||
}</b></code></pre>
|
||||
This is the actual function joe.<br>
|
||||
<br>
|
||||
<code><b>int mary(void), *lloyd(double);</b></code><br>
|
||||
This defines the prototype for the function mary with no parameters and
|
||||
return type int. Function llyod is defined with a double type paramater
|
||||
and returns a pointer to an int.<br>
|
||||
<br>
|
||||
<code><b>int (*peter)();</b></code><br>
|
||||
Defines peter as a pointer to a function with no parameters specified.
|
||||
The value of peter can be changed to represent different functions.<br>
|
||||
<br>
|
||||
<code><b>int (*aaron(char *(*)(void)) (long, int);</b></code><br>
|
||||
Defines the function aaron which returns a pointer to a function. The
|
||||
function aaron takes one argument: a pointer to a function which returns a
|
||||
character pointer and takes no arguments. The returned function returns a
|
||||
type int and has two parameters of type long and int.
|
||||
</blockquote>
|
||||
<h1>1.3.2 Program Startup</h1>
|
||||
<p>
|
||||
A program begins by calling the function main. There is no prototype
|
||||
required for this. It can be defined with no parameters such as:
|
||||
<blockquote>
|
||||
<code><b>int main(void) { </b></code><i>body...</i><code><b> }</b></code>
|
||||
</blockquote>
|
||||
Or with the following two parameters:
|
||||
<blockquote>
|
||||
<code><b>int main(int argc, char *argv[]) { </b></code><i>body...</i><code><b> }</code></b>
|
||||
</blockquote>
|
||||
Note that they do not have to be called <code><b>argc</b></code> or
|
||||
<code><b>argv</b></code>, but this is the common naming system.
|
||||
<p>
|
||||
<code><b>argc</b></code> is a nonnegative integer. If <code><b>argc</b></code> is greater than zero, then
|
||||
the string pointed to by <code><b>argv[0]</b></code> is the name of the program. If <code><b>argc</b></code> is
|
||||
greater than one, then the strings pointed to by <code><b>argv[1]</b></code> through
|
||||
<code><b>argv[argc-1]</b></code> are the parameters passed to the program by the system.
|
||||
<p>
|
||||
Example:
|
||||
<pre><code><b>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int loop;
|
||||
|
||||
if(argc>0)
|
||||
printf("My program name is %s.\n",argv[0]);
|
||||
|
||||
if(argc>1)
|
||||
{
|
||||
for(loop=1;loop<argc;loop++)
|
||||
printf("Parameter #%i is %s.\n",loop,argv[loop]);
|
||||
}
|
||||
}
|
||||
</b></code></pre>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.2.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.2 Identifiers</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.4.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.4 References</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
155
Ref-docs/c_lib_guide/1.4.html
Normal file
155
Ref-docs/c_lib_guide/1.4.html
Normal file
@@ -0,0 +1,155 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--1.4 References
|
||||
</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="1.3.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.3 Functions</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.5.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.5 Operators</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
<h1>1.4.1 Pointers and the Address Operator</h1>
|
||||
<p>
|
||||
Pointers are variables that contain the memory address for another variable. A pointer is
|
||||
defined like a normal variable, but with an asterisk before the variable name. The type-specifier
|
||||
determines what kind of variable the pointer points to but does not affect the actual pointer.
|
||||
<p>
|
||||
The address operator causes the memory address for a variable to be returned. It is
|
||||
written with an ampersand sign before the variable name.
|
||||
<p>
|
||||
When using a pointer, referencing just the pointer such as:
|
||||
<blockquote><code><b>
|
||||
int *my_pointer;<br>
|
||||
int barny;<br>
|
||||
my_pointer=&barny;<br>
|
||||
</b></code></blockquote>
|
||||
Causes my_pointer to contain the address of barny. Now the pointer can be use
|
||||
indirection to reference the variable it points to. Indirection is done by prefixing an asterisk to
|
||||
the pointer variable.
|
||||
<blockquote><code><b>
|
||||
*my_pointer=3;
|
||||
</b></code></blockquote>
|
||||
This causes the value of barny to be 3. Note that the value of <code><b>my_pointer</b></code> is unchanged.
|
||||
<p>
|
||||
Pointers offer an additional method for addressing an array. The following array:
|
||||
<blockquote><code><b>
|
||||
int my_array[3];</b></code>
|
||||
</blockquote>
|
||||
Can be addressed normally such as:
|
||||
<blockquote><code><b>
|
||||
my_array[2]=3;
|
||||
</b></code>
|
||||
</blockquote>
|
||||
The same can be accomplished with:
|
||||
<blockquote><code><b>
|
||||
*(my_array+2)=3;</b></code>
|
||||
</blockquote>
|
||||
Note that <code><b>my_array</b></code> is a pointer <i>constant</i>. Its value cannot be modified such as:
|
||||
<blockquote><code><b>
|
||||
my_array++;</b></code>
|
||||
This is illegal.
|
||||
</blockquote>
|
||||
However, if a pointer variable is created such as:
|
||||
<blockquote><code><b>
|
||||
int *some_pointer=my_array;</b></code>
|
||||
</blockquote>
|
||||
Then modifying the pointer will correctly increment the pointer so as to point to the next
|
||||
element in the array.
|
||||
<blockquote><code><b>
|
||||
*(some_pointer+1)=3;</b></code>
|
||||
</blockquote>
|
||||
This will cause the value of <code><b>my_array[1]</b></code> to be 3. On a system where an <code><b>int</b></code> takes up two bytes, adding 1 to <code><b>some_pointer</b></code> did not actually increase it by 1, but by 2 so that it pointed to the next
|
||||
|
||||
element in the array.
|
||||
<p>
|
||||
Functions can also be represented with a pointer. A function pointer is defined in the
|
||||
same way as a function prototype, but the function name is replaced by the pointer name
|
||||
prefixed with an asterisk and encapsulated with parenthesis. Such as:
|
||||
<blockquote><code><b>
|
||||
int (*fptr)(int, char);<br>
|
||||
fptr=some_function;</b></code>
|
||||
</blockquote>
|
||||
To call this function:
|
||||
<blockquote><code><b>
|
||||
(*ftpr)(3,'A');</b></code>
|
||||
</blockquote>
|
||||
This is equivalent to:
|
||||
<blockquote><code><b>
|
||||
some_function(3,'A');</b></code></blockquote>
|
||||
<p>
|
||||
A structure or union can have a pointer to represent it. Such as:
|
||||
<blockquote><code><b>
|
||||
struct some_structure homer;<br>
|
||||
struct some_structure *homer_pointer;<br>
|
||||
homer_pointer=&homer;
|
||||
</b></code></blockquote>
|
||||
This defines homer_pointer to point to the structure homer. Now, when you use the
|
||||
pointer to reference something in the structure, the record selector now becomes <code><b>-></b></code> instead of a
|
||||
period.<br>
|
||||
<blockquote><code><b>
|
||||
homer_pointer->an_element=5;</b></code>
|
||||
</blockquote>
|
||||
This is the same as:
|
||||
<blockquote><code><b>
|
||||
homer.an_element=5;
|
||||
</b></code></blockquote>
|
||||
The void pointer can represent an unknown pointer type.
|
||||
<blockquote><code><b>
|
||||
void *joe;
|
||||
</b></code></blockquote>
|
||||
This is a pointer to an undetermined type.
|
||||
|
||||
<h1> 1.4.2 Typecasting</h1>
|
||||
<p>
|
||||
Typecasting allows a variable to act like a variable of another type. The method of
|
||||
typecasting is done by prefixing the variable type enclosed by parenthesis before the variable
|
||||
name. The actual variable is not modified.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote><code><b>
|
||||
float index=3;
|
||||
int loop=(int)index;
|
||||
</b></code></blockquote>
|
||||
This causes index to be typecasted to act like an <code><b>int</b></code>.
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.3.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.3 Functions</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.5.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.5 Operators</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
580
Ref-docs/c_lib_guide/1.5.html
Normal file
580
Ref-docs/c_lib_guide/1.5.html
Normal file
@@ -0,0 +1,580 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--1.5 Operators
|
||||
</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="1.4.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.4 References</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.6.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.6 Statements</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1>1.5.1 Postfix</h1>
|
||||
<p>
|
||||
Postfix operators are operators that are suffixed to an expression.
|
||||
<blockquote>
|
||||
<i>operand</i><code><b>++;</b></code><br>
|
||||
This causes the value of the <i>operand</i> to be returned. After the result is obtained, the
|
||||
value of the operand is incremented by 1.
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<i>operand</i><code><b>--;</b></code><br>
|
||||
This is the same but the value of the operand is decremented by 1.
|
||||
</blockquote>
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote><code><b>
|
||||
int joe=3;<br>
|
||||
joe++;</b></code>
|
||||
</blockquote>
|
||||
The value of <code><b>joe</b></code> is now 4.
|
||||
<blockquote><code><b>
|
||||
printf("%i",joe++);</b></code>
|
||||
</blockquote>
|
||||
This outputs the number 4. The value of <code><b>joe</b></code> is now 5.
|
||||
|
||||
<h1> 1.5.2 Unary and Prefix</h1>
|
||||
<p>
|
||||
Prefix operators are operators that are prefixed to an expression.
|
||||
<blockquote>
|
||||
<code><b>++</b></code><i>operand</i><code><b>;</b></code><br>
|
||||
This causes the value of the operand to be incremented by 1. Its new value is then
|
||||
returned.
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<code><b>--</b></code><i>operand</i><code><b>;</b></code><br>
|
||||
This is the same but the value of the operand is decremented by 1.
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<code><b>!</b></code><i>operand</i><br>
|
||||
Returns the logical NOT operation on the operand. A true operand returns false, a false
|
||||
operand returns true. Also known as the bang operand.
|
||||
</blockquote>
|
||||
<blockquote>
|
||||
<code><b>~</b></code><i>operand</i><br>
|
||||
Returns the compliment of the operand. The returned value is the operand with its bits
|
||||
reversed (1's become 0's, 0's become 1's).
|
||||
</blockquote>
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b>int bart=7;<br>
|
||||
printf("%i",--bart);</b></code><br>
|
||||
This outputs the number 6. The value of bart is now 6.<br>
|
||||
<br>
|
||||
<code><b>int lisa=1;<br>
|
||||
printf("%i",!lisa);</b></code><br>
|
||||
This outputs 0 (false).
|
||||
</blockquote>
|
||||
<h1>1.5.3 Normal</h1>
|
||||
<p>
|
||||
There are several normal operators which return the result defined for each:
|
||||
<blockquote>
|
||||
<i>expression1</i><code><b> + </b></code><i>expression</i><br>
|
||||
The result of this is the sum of the two expressions.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> - </b></code><i>expression2</i><br>
|
||||
The result of this is the value of <i>expression2</i> subtracted from <i>expression1</i>.
|
||||
<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> * </b></code><i>expression2</i><br>
|
||||
The result of this is the value of <i>expression1</i> multiplied by <i>expression2</i>.
|
||||
<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> / </b></code><i>expression2</i><br>
|
||||
The result of this is the value of <i>expression1</i> divided by <i>expression2</i>.
|
||||
<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> % </b></code><i>expression2</i><br>
|
||||
The result of this is the value of the remainder after dividing <i>expression1</i> by <i>expression2</i>.
|
||||
Also called the modulo operator.
|
||||
<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> & </b></code><i>expression2</i><br>
|
||||
Returns a bitwise AND operation done on <i>expression1</i> and <i>expression2</i>. The result is a
|
||||
value the same size as the expressions with its bits modified using the following rules: Both bits
|
||||
must be 1 (on) to result in 1 (on), otherwise the result is 0 (off).
|
||||
<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br>
|
||||
<i>expression1</i><code><b> | </b></code><i>expression2</i><br>
|
||||
Returns a bitwise OR operation done on <i>expression1</i> and <i>expression2</i>. The result is a
|
||||
value the same size as the expressions with its bits modified using the following rules: Both bits
|
||||
must be 0 (off) to result in 0 (off), otherwise the result is 1 (on).
|
||||
<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br>
|
||||
<i>expression1</i><code><b> ^ </b></code><i>expression2</i><br>
|
||||
Returns a bitwise XOR operation done on <i>expression1</i> and <i>expression2</i>. The result is a
|
||||
value the same size as the expressions with its bits modified using the following rules: If both
|
||||
bits are the same, then the result is 0 (off), otherwise the result is 1 (on).
|
||||
<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br>
|
||||
<i>expression1</i><code><b> >> </b></code><i>shift_value</i><br>
|
||||
Returns <i>expression1</i> with its bits shifted to the right by the <i>shift_value</i>. The leftmost bits
|
||||
are replaced with zeros if the value is nonnegative or unsigned. This result is the integer part of
|
||||
<i>expression1</i> divided by 2 raised to the power of <i>shift_value</i>. If <i>expression1</i> is signed, then the
|
||||
result is implementation specific.
|
||||
<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> << </b></code><i>shift_value</i><br>
|
||||
Returns <i>expression1</i> with its bits shifted to the left by the <i>shift_value</i>. The rightmost bits
|
||||
are replaced with zeros. This result is the value of <i>expression1</i> multiplied by the value of 2
|
||||
raised to the power of <i>shift_value</i>. If <i>expression1</i> is signed, then the result is implementation
|
||||
specific.
|
||||
</blockquote>
|
||||
<h1> 1.5.4 Boolean</h1>
|
||||
<p>
|
||||
The boolean operators return either 1 (true) or 0 (false).
|
||||
<blockquote>
|
||||
<i>expression1</i><code><b> && </b></code><i>expression2</i><br>
|
||||
Returns the logical AND operation of <i>expression1</i> and <i>expression2</i>. The result is 1 (true)
|
||||
if both expressions are true, otherwise the result is 0 (false).
|
||||
<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br>
|
||||
<i>expression1</i><code><b> || </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns the logical OR operation of <i>expression1</i> and <i>expression2</i>. The result is 0 (false)
|
||||
if bother expressions are false, otherwise the result is 1 (true).
|
||||
<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<br>
|
||||
<i>expression1</i><code><b> < </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns 1 (true) if <i>expression1</i> is less than <i>expression2</i>, otherwise the result is 0 (false).
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<i>expression1</i><code><b> > </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns 1 (true) if <i>expression1</i> is greater than <i>expression2</i>, otherwise the result is 0
|
||||
(false).
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<i>expression1</i><code><b> <= </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns 1 (true) if <i>expression1</i> is less than or equal to <i>expression2</i>, otherwise the result is
|
||||
0 (false).
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<i>expression1</i><code><b> >= </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns 1 (true) if <i>expression1</i> is greater than or equal to <i>expression2</i>, otherwise the
|
||||
result is 0 (false).
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<i>expression1</i><code><b> == </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns 1 (true) if <i>expression1</i> is equal to <i>expression2</i>, otherwise the result is 0 (false).
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<i>expression1</i><code><b> != </b></code><i>expression2</i>
|
||||
<br>
|
||||
Returns 1 (true) if <i>expression</i>1 is not equal to <i>expression2</i>, otherwise the result is 0
|
||||
(false).
|
||||
<br>
|
||||
</blockquote>
|
||||
|
||||
<h1> 1.5.5 Assignment</h1>
|
||||
<p>
|
||||
An assignment operator stores the value of the right expression into the left expression.
|
||||
<blockquote>
|
||||
<i>expression1</i><code><b> = </b></code><i>expression2</i><br>
|
||||
The value of <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> *= </b></code><i>expression2</i><br>
|
||||
The value of <i>expression1</i> times <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> /= </b></code><i>expression2</i><br>
|
||||
The value of <i>expression1</i> divided by <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> %= </b></code><i>expression2</i><br>
|
||||
The value of the remainder of <i>expression1</i> divided by <i>expression2</i> is stored in
|
||||
<i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> += </b></code><i>expression2</i><br>
|
||||
The value of <i>expression1</i> plus <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> -= </b></code><i>expression2</i><br>
|
||||
The value of <i>expression1</i> minus <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> <<= </b></code><i>shift_value</i><br>
|
||||
The value of <i>expression1</i>'s bits are shifted to the left by <i>shift_value</i> and stored in
|
||||
<i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> >>= </b></code><i>shift_value</i><br>
|
||||
The value of <i>expression1</i>'s bits are shifted to the right by <i>shift_value</i> and stored in
|
||||
<i>expression1</i>.<br>
|
||||
<br>
|
||||
<i>expression1</i><code><b> &= </b></code><i>expression2</i><br>
|
||||
The value of the bitwise AND of <i>expression1</i> and <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br>
|
||||
<i>expression1</i><code><b> ^= </b></code><i>expression2</i><br>
|
||||
The value of the bitwise XOR of <i>expression1</i> and <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr align=center>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br>
|
||||
<i>expression1</i><code><b> |= </b></code><i>expression2</i><br>
|
||||
The value of the bitwise OR of <i>expression1</i> and <i>expression2</i> is stored in <i>expression1</i>.<br>
|
||||
<center>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<th>e1</th>
|
||||
<th>e2</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
<td>0</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>0</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
<tr ALIGN=CENTER>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
<td>1</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</blockquote>
|
||||
<br>
|
||||
<h1> 1.5.6 Precedence</h1>
|
||||
<p>
|
||||
The operators have a set order of precedence during evaluation. Items encapsulated in
|
||||
parenthesis are evaluated first and have the highest precedence. The following chart shows the
|
||||
order of precedence with the items at the top having highest precedence.
|
||||
<p>
|
||||
<center>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Operator</th>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>!</td>
|
||||
<td>Logical NOT. Bang.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>++ --</td>
|
||||
<td>Increment and decrement operators.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>* / %</td>
|
||||
<td>Multiplicative operators.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>+ -</td>
|
||||
<td>Additive operators.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><< >></td>
|
||||
<td>Shift operators.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>< > <= >=</td>
|
||||
<td>Inequality comparators.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>== !=</td>
|
||||
<td>Equality comparators</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>&</td>
|
||||
<td>Bitwise AND.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>^</td>
|
||||
<td>Bitwise XOR.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>|</td>
|
||||
<td>Bitwise OR.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>&&</td>
|
||||
<td>Logical AND.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>||</td>
|
||||
<td>Logical OR.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>?:</td>
|
||||
<td>Conditional.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>= <i>op</i>=</td>
|
||||
<td>Assignment.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote><code><b>
|
||||
17 * 5 + !(1+1) && 0
|
||||
</b></code></blockquote>
|
||||
Evaluates to 0 (false).
|
||||
<blockquote><code><b>
|
||||
5+7<4
|
||||
</b></code></blockquote>
|
||||
Evaluates to 1 (true).
|
||||
<blockquote><code><b>
|
||||
a<b<c
|
||||
</b></code></blockquote>
|
||||
Same as (a<b)<c.
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.4.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.4 References</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.6.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.6 Statements</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
323
Ref-docs/c_lib_guide/1.6.html
Normal file
323
Ref-docs/c_lib_guide/1.6.html
Normal file
@@ -0,0 +1,323 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--1.6 Statements
|
||||
</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="1.5.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.5 Operators</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.7.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.7 Preprocessing Directives</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<a name="if"></a>
|
||||
<h1>1.6.1 if</h1>
|
||||
<p>
|
||||
The if statement evaluates an expression. If that expression is true, then a statement is
|
||||
executed. If an else clause is given and if the expression is false, then the else's statement is
|
||||
executed.
|
||||
<p>
|
||||
Syntax:<br>
|
||||
<blockquote>
|
||||
<code><b>if(</b></code> <i>expression</i> <code><b>)</b></code> <i>statement1</i><code><b>;</b></code><br>
|
||||
<br>
|
||||
<i>or</i><br>
|
||||
<br>
|
||||
<code><b>if(</b></code> <i>expression</i> <code><b>)</b></code> <i>statement1</i><code><b>;</b></code><br>
|
||||
<code><b>else</b></code> <i>statement2</i> <code><b>;</b></code><br>
|
||||
</blockquote>
|
||||
<br>
|
||||
Examples:<br>
|
||||
<blockquote><code><b><pre>
|
||||
|
||||
if(loop<3) counter++;
|
||||
|
||||
if(x==y)
|
||||
x++;
|
||||
else
|
||||
y++;
|
||||
|
||||
if(z>x)
|
||||
{
|
||||
z=5;
|
||||
x=3;
|
||||
}
|
||||
else
|
||||
{
|
||||
z=3;
|
||||
x=5;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
|
||||
<a name="switch"></a>
|
||||
<h1> 1.6.2 switch</h1>
|
||||
<p>
|
||||
A switch statement allows a single variable to be compared with several possible
|
||||
constants. If the variable matches one of the constants, then a execution jump is made to that
|
||||
point. A constant can not appear more than once, and there can only be one default expression.<br>
|
||||
<br>
|
||||
Syntax:<br>
|
||||
<blockquote><pre>
|
||||
<code><b>switch (</b></code> <i>variable</i><code><b> )
|
||||
{
|
||||
case </b></code><i>const</i><code><b>:</b></code>
|
||||
<i>statements...</i><code><b>;
|
||||
default:
|
||||
</b></code><i>statements...</i><code><b>;
|
||||
}
|
||||
</b></code>
|
||||
</pre></blockquote>
|
||||
Examples:<br>
|
||||
<blockquote><code><b><pre>
|
||||
|
||||
switch(betty)
|
||||
{
|
||||
case 1:
|
||||
printf("betty=1\n");
|
||||
case 2:
|
||||
printf("betty=2\n");
|
||||
break;
|
||||
case 3:
|
||||
printf("betty=3\n");
|
||||
break;
|
||||
default:
|
||||
printf("Not sure.\n");
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
|
||||
If betty is 1, then two lines are printed: betty=1 and betty=2. If betty is 2, then only one line is
|
||||
printed: betty=2. If betty=3, then only one line is printed: betty=3. If betty does not equal 1, 2,
|
||||
or 3, then "Not sure." is printed.
|
||||
<br>
|
||||
<a name="while"></a>
|
||||
<h1> 1.6.3 while</h1>
|
||||
<p>
|
||||
The while statement provides an iterative loop.
|
||||
<br>
|
||||
Syntax:<br>
|
||||
<blockquote>
|
||||
<code><b>while(</b></code> <i> expression</i> <code><b>)</b></code> <i> statement...</i>
|
||||
</blockquote>
|
||||
<i>statement</i> is executed repeatedly as long as <i>expression</i> is true. The test on <i>expression</i>
|
||||
takes place before each execution of <i>statement</i>.
|
||||
<br>
|
||||
Examples:<br>
|
||||
<blockquote><code><b><pre>
|
||||
|
||||
while(*pointer!='j') pointer++;
|
||||
|
||||
while(counter<5)
|
||||
{
|
||||
printf("counter=%i",counter);
|
||||
counter++;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<br>
|
||||
<a name="do"></a>
|
||||
<h1> 1.6.4 do</h1>
|
||||
<br>
|
||||
The do...while construct provides an iterative loop.<br>
|
||||
<br>
|
||||
Syntax:<br>
|
||||
<blockquote>
|
||||
<code><b>do</code></b> <i>statement...</i> <code><b>while(</code></b> <i>expression</i> <code><b>);</code></b>
|
||||
</blockquote>
|
||||
<i>statement</i> is executed repeatedly as long as <i>expression</i> is true. The test on <i>expression</i>
|
||||
takes place after each execution of <i>statement</i>.<br>
|
||||
<br>
|
||||
Examples:<br>
|
||||
<blockquote><code><b><pre>
|
||||
|
||||
do {
|
||||
betty++;
|
||||
printf("%i",betty);
|
||||
} while (betty<100);
|
||||
|
||||
</pre></b></code></blockquote>
|
||||
<a name="for"></a>
|
||||
<h1> 1.6.5 for</h1>
|
||||
<p>
|
||||
The for statement allows for a controlled loop.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote>
|
||||
<code><b>for(</b></code> <i>expression1</i> ; <i>expression2</i> ; <i>expression3</i><code><b> )</b></code> <i>statement...</i>
|
||||
</blockquote>
|
||||
<i>expression1</i> is evaluated before the first iteration. After each iteration, <i>expression3</i> is
|
||||
evaluated. Both <i>expression1</i> and <i>expression3</i> may be ommited. If <i>expression2</i> is ommited, it is
|
||||
assumed to be 1. <i>statement</i> is executed repeatedly until the value of <i>expression2</i> is 0. The test
|
||||
on <i>expression2</i> occurs before each execution of <i>statement</i>.
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote>
|
||||
<code><b><pre>
|
||||
for(loop=0;loop<1000;loop++)
|
||||
printf("%i\n",loop);
|
||||
</pre></b></code>
|
||||
</blockquote>
|
||||
Prints numbers 0 through 999.
|
||||
<blockquote>
|
||||
<code><b><pre>
|
||||
for(x=3, y=5; x<100+y; x++, y--)
|
||||
{
|
||||
printf("%i\n",x);
|
||||
some_function();
|
||||
}
|
||||
</pre></b></code>
|
||||
</blockquote>
|
||||
Prints numbers 3 through 53. some_function is called 51 times.
|
||||
<br>
|
||||
<a name="goto"></a>
|
||||
<h1> 1.6.6 goto</h1>
|
||||
<p>
|
||||
The goto statement transfers program execution to some label within the program.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote>
|
||||
<code><b>goto</b></code><i> label</i><code><b>;</b></code><br>
|
||||
....<br>
|
||||
<i>label</i><code><b>:</b></code><br>
|
||||
</blockquote>
|
||||
Examples:
|
||||
<blockquote><code><b><pre>
|
||||
goto skip_point;
|
||||
printf("This part was skipped.\n");
|
||||
skip_point:
|
||||
printf("Hi there!\n");
|
||||
</pre></b></code>
|
||||
</blockquote>
|
||||
Only the text "Hi there!" is printed.
|
||||
<br>
|
||||
<a name="continue"></a>
|
||||
<h1> 1.6.7 continue</h1>
|
||||
<p>
|
||||
The continue statement can only appear in a loop body. It causes the rest of the
|
||||
statement body in the loop to be skipped.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote><code><b>
|
||||
continue;
|
||||
</b></code></blockquote>
|
||||
Examples:
|
||||
<blockquote><code><b><pre>
|
||||
for(loop=0;loop<100;loop++)
|
||||
{
|
||||
if(loop==50)
|
||||
continue;
|
||||
printf("%i\n",loop);
|
||||
}
|
||||
</pre></b></code>
|
||||
</blockquote>
|
||||
The numbers 0 through 99 are printed except for 50.
|
||||
<blockquote>
|
||||
<code><b><pre>
|
||||
joe=0;
|
||||
while(joe<1000)
|
||||
{
|
||||
for(zip=0;zip<100;zip++)
|
||||
{
|
||||
if(joe==500)
|
||||
continue;
|
||||
printf("%i\n",joe);
|
||||
}
|
||||
joe++;
|
||||
}
|
||||
</pre></b></code>
|
||||
</blockquote>
|
||||
Each number from 0 to 999 is printed 100 times except for the number 500 which is not printed
|
||||
at all.
|
||||
<a name="break"></a>
|
||||
<h1> 1.6.8 break</h1>
|
||||
<p>
|
||||
The break statement can only appear in a switch body or a loop body. It causes the
|
||||
execution of the current enclosing switch or loop body to terminate.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote><code><b>
|
||||
break;
|
||||
</b></code></blockquote>
|
||||
Examples:
|
||||
<blockquote><code><b><pre>
|
||||
switch(henry)
|
||||
{
|
||||
case 1: print("Hi!\n");
|
||||
break;
|
||||
case 2: break;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
If henry is equal to 2, nothing happens.
|
||||
<blockquote><code><b><pre>
|
||||
for(loop=0;loop<50;loop++)
|
||||
{
|
||||
if(loop==10)
|
||||
break;
|
||||
printf("%i\n",loop);
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
Only numbers 0 through 9 are printed.
|
||||
<a name="return"></a>
|
||||
<h1> 1.6.9 return</h1>
|
||||
<p>
|
||||
The return statement causes the current function to terminate. It can return a value to the
|
||||
calling function. A return statement can not appear in a function whose return type is void. If
|
||||
the value returned has a type different from that of the function's return type, then the value is
|
||||
converted. Using the return statement without an expression creates an undefined result.
|
||||
Reaching the } at the end of the function is the same as returning without an expression.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote><code><b>
|
||||
return</b></code> <i> expression</i><code><b>;</b></code>
|
||||
</blockquote>
|
||||
Examples:
|
||||
<blockquote><code><b><pre>
|
||||
int alice(int x, int y)
|
||||
{
|
||||
if(x<y)
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.5.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.5 Operators</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.7.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
1.7 Preprocessing Directives</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
277
Ref-docs/c_lib_guide/1.7.html
Normal file
277
Ref-docs/c_lib_guide/1.7.html
Normal file
@@ -0,0 +1,277 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--1.7 Preprocessing Directives
|
||||
</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="1.6.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.6 Statements</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="2.1.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.1 assert.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
<a name="conditional"></a>
|
||||
<h1>1.7.1 #if, #elif, #else, #endif</h1>
|
||||
<p>
|
||||
These preprocessing directives create conditional compiling parameters that control the
|
||||
compiling of the source code. They must begin on a separate line.
|
||||
<p>
|
||||
Syntax:<br>
|
||||
<blockquote>
|
||||
<code><b>
|
||||
#if</code></b> <i>constant_expression</i><br>
|
||||
<code><b>#else<br>
|
||||
#endif<br>
|
||||
<br>
|
||||
or<br>
|
||||
<br>
|
||||
#if</code></b> <i>constant_expression</i><br>
|
||||
<code><b>#elif</code></b> <i>constant_expression</i><br>
|
||||
<code><b>#endif</code></b><br>
|
||||
</blockquote>
|
||||
The compiler only compiles the code after the <b><code>#if</code></b> expression if the <i>constant_expression</i>
|
||||
evaluates to a non-zero value (true). If the value is 0 (false), then the compiler skips the lines
|
||||
until the next <b><code>#else</code></b>, <b><code>#elif</code></b>, or <b><code>#endif</code></b>. If there is a matching <b><code>#else</code></b>, and the <i>constant_expression</i>
|
||||
evaluated to 0 (false), then the lines between the <b><code>#else</code></b> and the <b><code>#endif</code></b> are compiled. If there is a
|
||||
matching <b><code>#elif</code></b>, and the preceding <b><code>#if</code></b> evaluated to false, then the <i>constant_expression</i> after that
|
||||
is evaluated and the code between the <b><code>#elif</code></b> and the <b><code>#endif</code></b> is compiled only if this expression
|
||||
evaluates to a non-zero value (true).
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote><code><b><pre>
|
||||
int main(void)
|
||||
{
|
||||
#if 1
|
||||
printf("Yabba Dabba Do!\n");
|
||||
#else
|
||||
printf("Zip-Bang!\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
Only "Yabba Dabba Do!" is printed.
|
||||
<blockquote><code><b><pre>
|
||||
int main(void)
|
||||
{
|
||||
#if 1
|
||||
printf("Checkpoint1\n");
|
||||
#elif 1
|
||||
printf("Checkpoint2\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
Only "Checkpoint1" is printed. Note that if the first line is #if 0, then only "Checkpoint2" would
|
||||
be printed.
|
||||
<blockquote><code><b><pre>
|
||||
#if OS==1
|
||||
printf("Version 1.0");
|
||||
#elif OS==2
|
||||
printf("Version 2.0");
|
||||
#else
|
||||
printf("Version unknown");
|
||||
#endif
|
||||
</pre></b></code></blockquote>
|
||||
Prints according to the setting of OS which is defined with a #define.
|
||||
<br>
|
||||
<a name="define"></a>
|
||||
<h1> 1.7.2 #define, #undef, #ifdef, #ifndef</h1>
|
||||
<p>
|
||||
The preprocessing directives <b><code>#define</b></code> and <b><code>#undef</b></code> allow the definition of identifiers which
|
||||
hold a certain value. These identifiers can simply be constants or a macro function. The
|
||||
directives <b><code>#ifdef</b></code> and <b><code>#ifndef</b></code> allow conditional compiling of certain lines of code based on
|
||||
whether or not an identifier has been defined.
|
||||
<p>
|
||||
Syntax:<br>
|
||||
<blockquote><code><b>
|
||||
#define</b></code> <i>identifier replacement-code</i><br>
|
||||
<br>
|
||||
<code><b>#undef</b></code> <i>identifier</i><br>
|
||||
<br>
|
||||
<code><b> #ifdef</b></code> <i>identifier</i><br>
|
||||
<code><b>#else</b></code> or <code><b>#elif</b></code><br>
|
||||
<code><b>#endif</b></code><br>
|
||||
<br>
|
||||
<code><b>#ifndef</b></code> <i>identifier</i><br>
|
||||
<code><b>#else</b></code> or <code><b>#elif</b></code><br>
|
||||
<code><b>#endif</b></code><br>
|
||||
<br>
|
||||
<code><b>#ifdef</b></code> <i>identifier</i> is the same is <code><b>#if defined(</b></code> <i>identifier</i><code><b>)</b></code>.<br>
|
||||
<code><b>#ifndef</b></code> <i>identifier</i> is the same as <code><b>#if
|
||||
!defined(</b></code><i>identifier</i><code><b>)</b></code>.<br>
|
||||
An identifier defined with <code><b>#define</b></code> is available anywhere in the source code until a
|
||||
<code><b>#undef</b></code> is reached.<br>
|
||||
A function macro can be defined with <code><b>#define</b></code> in the following manner:<br>
|
||||
<br>
|
||||
<code><b>#define</b></code> <i>identifier</i><code><b>(</b></code><i>parameter-list</i><code><b>) (</b></code><i>replacement-text</i><code><b>)</b></code><br>
|
||||
<br>
|
||||
The values in the <i>parameter-list</i> are replaced in the <i>replacement-text</i>.<br>
|
||||
<br>
|
||||
</blockquote>
|
||||
Examples:
|
||||
<blockquote><code><b><pre>
|
||||
#define PI 3.141
|
||||
printf("%f",PI);
|
||||
|
||||
#define DEBUG
|
||||
#ifdef DEBUG
|
||||
printf("This is a debug message.");
|
||||
#endif
|
||||
|
||||
#define QUICK(x) printf("%s\n",x);
|
||||
QUICK("Hi!")
|
||||
|
||||
#define ADD(x, y) x + y
|
||||
z=3 * ADD(5,6)
|
||||
</pre></b></code></blockquote>
|
||||
This evaluates to 21 due to the fact that multiplication takes precedence over addition.
|
||||
<blockquote><code><b><pre>
|
||||
#define ADD(x,y) (x + y)
|
||||
z=3 * ADD(5,6)
|
||||
</pre></b></code></blockquote>
|
||||
This evaluates to 33 due to the fact that the summation is encapsulated in parenthesis which
|
||||
takes precedence over multiplication.
|
||||
<p>
|
||||
<a name="include"></a>
|
||||
<h1> 1.7.3 #include</h1>
|
||||
<p>
|
||||
The <b><code>#include</code></b> directive allows external header files to be processed by the compiler.
|
||||
<p>
|
||||
Syntax:<br>
|
||||
<blockquote><code><b>
|
||||
#include <</b></code><i>header-file</i><code><b>><br>
|
||||
<br>
|
||||
or<br>
|
||||
<br>
|
||||
#include "</b></code><i>source-file</i><code><b>"</b></code><br>
|
||||
</blockquote>
|
||||
When enclosing the file with < and >, then the implementation searches the known
|
||||
header directories for the file (which is implementation-defined) and processes it. When
|
||||
enclosed with double quotation marks, then the entire contents of the source-file is replaced at
|
||||
this point. The searching manner for the file is implementation-specific.
|
||||
<p>
|
||||
Examples:
|
||||
<blockquote><code><b>
|
||||
#include <stdio.h><br>
|
||||
#include "my_header.h"<br>
|
||||
</b></code></blockquote>
|
||||
<a name="line"></a>
|
||||
<h1> 1.7.4 #line</h1>
|
||||
<p>
|
||||
The <code><b>#line</b></code> directive allows the current line number and the apparent name of the current
|
||||
sourcecode filename to be changed.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote><code><b>
|
||||
#line</b></code> <i>line-number filename</i>
|
||||
</blockquote>
|
||||
Note that if the filename is not given, then it stays the same. The line number on the
|
||||
current line is one greater than the number of new-line characters (so the first line number is 1).
|
||||
<br>
|
||||
Examples:
|
||||
<blockquote><code><b>
|
||||
#line 50 user.c<br>
|
||||
<br>
|
||||
#line 23<br>
|
||||
</b></code></blockquote>
|
||||
|
||||
<a name="error"></a>
|
||||
<h1> 1.7.5 #error</h1>
|
||||
<p>
|
||||
The <code><b>#error</b></code> directive will cause the compiler to halt compiling and return with the
|
||||
specified error message.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote><code><b>
|
||||
#error</b></code> <i> message</i>
|
||||
</blockquote>
|
||||
Examples:
|
||||
<blockquote><code><b>
|
||||
#ifndef VERSION<br>
|
||||
#error Version number not specified.<br>
|
||||
#endif<br>
|
||||
</b></code></blockquote>
|
||||
<a name="pragma"></a>
|
||||
<h1> 1.7.6 #pragma</h1>
|
||||
<p>
|
||||
This <code><b>#pragma</b></code> directive allows a directive to be defined. Its effects are
|
||||
implementation-defined. If the pragma is not supported, then it is ignored.
|
||||
<p>
|
||||
Syntax:
|
||||
<blockquote><code><b>
|
||||
#pragma</b></code> <i>directive</i>
|
||||
</blockquote>
|
||||
|
||||
<a name="macros"></a>
|
||||
<h1> 1.7.7 Predefined Macros</h1>
|
||||
<p>
|
||||
The following macros are already defined by the compiler and cannot be changed.
|
||||
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td valign=top>__LINE__</td>
|
||||
<td>A decimal constant representing the current line number.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>__FILE__</td>
|
||||
<td>A string representing the current name of the source code file.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>__DATE__</td>
|
||||
<td>A string representing the current date when compiling began for the current
|
||||
source file. It is in the format "mmm dd yyyy", the same as what is generated by
|
||||
the asctime function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>__TIME__</td>
|
||||
<td>A string literal representing the current time when cimpiling began for the current
|
||||
source file. It is in the format "hh:mm:ss", the same as what is generated by the
|
||||
asctime function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top>__STDC__</td>
|
||||
<td>The decimal constant 1. Used to indicate if this is a standard C compiler.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.6.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.6 Statements</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="2.1.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.1 assert.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
98
Ref-docs/c_lib_guide/2.1.html
Normal file
98
Ref-docs/c_lib_guide/2.1.html
Normal file
@@ -0,0 +1,98 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.1 assert.h
|
||||
</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="1.7.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.7 Preprocessing Directives</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="2.2.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.2 ctype.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
<h1>2.1 assert.h</h1>
|
||||
<p>
|
||||
The assert header is used for debugging purposes.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
assert();
|
||||
</b></code></blockquote>
|
||||
External References:
|
||||
<blockquote><code><b>
|
||||
NDEBUG
|
||||
</b></code></blockquote>
|
||||
<a name="assert"></a>
|
||||
<h2>2.1.1 assert</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void assert(int </b></code><i>expression</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
The assert macro allows diagnostic information to be written to the standard error file.
|
||||
<p>
|
||||
If expression evaluates to 0 (false), then the expression, sourcecode filename, and line
|
||||
number are sent to the standard error, and then calls the abort function. If the identifier
|
||||
<code><b>NDEBUG</b></code> ("no debug") is defined with <code><b>#define NDEBUG</b></code> then the macro assert does nothing.
|
||||
<p>
|
||||
Common error outputting is in the form:
|
||||
<blockquote><code><b>
|
||||
Assertion failed:</code></b><i> expression</i><code><b>, file</b></code> <i>filename</i><code><b>, line</b></code><i> line-number</i>
|
||||
</blockquote>
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<assert.h>
|
||||
|
||||
void open_record(char *record_name)
|
||||
{
|
||||
assert(record_name!=NULL);
|
||||
/* Rest of code */
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
open_record(NULL);
|
||||
}
|
||||
|
||||
</pre></b></code></blockquote>
|
||||
<hr>
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="1.7.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
1.7 Preprocessing Directives</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="2.2.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.2 ctype.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
143
Ref-docs/c_lib_guide/2.10.html
Normal file
143
Ref-docs/c_lib_guide/2.10.html
Normal file
@@ -0,0 +1,143 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.10 stdarg.h
|
||||
</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="2.9.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.9 signal.h</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="2.11.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.11 stddef.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.10 stdarg.h</h1>
|
||||
<p>
|
||||
The stdarg header defines several macros used to get the arguments in a function when
|
||||
the number of arguments is not known.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
va_start();<br>
|
||||
va_arg();<br>
|
||||
va_end();<br>
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
typedef va_list
|
||||
</b></code></blockquote>
|
||||
<a name="variables"></a>
|
||||
<h2>2.10.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
The <code><b>va_list</b></code> type is a type suitable for use in accessing the arguments of a function with
|
||||
the stdarg macros.
|
||||
<p>
|
||||
A function of variable arguments is defined with the ellipsis <code><b>(,...)</b></code> at the end of the
|
||||
parameter list.
|
||||
<p>
|
||||
<a name="va_start"></a>
|
||||
<h2>2.10.2 va_start</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>void va_start(va_list</b></code><i> ap</i><code><b>,</b></code><i> last_arg</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
Initializes <i>ap</i> for use with the <code><b>va_arg</b></code> and <code><b>va_end</b></code> macros. <i>last_arg</i> is the last known fixed
|
||||
argument being passed to the function (the argument before the ellipsis).
|
||||
<p>
|
||||
Note that <code><b>va_start</b></code> must be called before using <code><b>va_arg</b></code> and <code><b>va_end</b></code>.
|
||||
<p>
|
||||
<a name="va_arg"></a>
|
||||
<h2>2.10.3 va_arg</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<i>type</i><code><b> va_arg(va_list</b></code><i> ap</i><code><b>,</b></code><i> type</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
Expands to the next argument in the paramater list of the function with type <i>type</i>. Note
|
||||
that <i>ap</i> must be initialized with <code><b>va_start</b></code>. If there is no next argument, then the result is
|
||||
undefined.
|
||||
<p>
|
||||
<a name="va_end"></a>
|
||||
<h2>2.10.4 va_end</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>void va_end(va_list</b></code><i> ap</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
<p>
|
||||
Allows a function with variable arguments which used the <code><b>va_start</b></code> macro to return. If
|
||||
<code><b>va_end</b></code> is not called before returning from the function, the result is undefined. The variable
|
||||
argument list<i> ap</i> may no longer be used after a call to <code><b>va_end</b></code> without a call to <code><b>va_start</b></code>.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<stdarg.h>
|
||||
#include<stdio.h>
|
||||
|
||||
void sum(char *, int, ...);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
sum("The sum of 10+15+13 is %d.\n",3,10,15,13);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void sum(char *string, int num_args, ...)
|
||||
{
|
||||
int sum=0;
|
||||
va_list ap;
|
||||
int loop;
|
||||
|
||||
va_start(ap,num_args);
|
||||
for(loop=0;loop<num_args;loop++)
|
||||
sum+=va_arg(ap,int);
|
||||
|
||||
printf(string,sum);
|
||||
va_end(ap);
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.9.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.9 signal.h</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="2.11.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.11 stddef.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body></html>
|
||||
|
||||
|
||||
108
Ref-docs/c_lib_guide/2.11.html
Normal file
108
Ref-docs/c_lib_guide/2.11.html
Normal file
@@ -0,0 +1,108 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.11 stddef.h
|
||||
</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="2.10.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.10 stdarg.h</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="2.12.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.12 stdio.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.11 stddef.h</h1>
|
||||
<p>
|
||||
The stddef header defines several standard definitions. Many of these definitions also
|
||||
appear in other headers.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
NULL<br>
|
||||
offsetof();<br>
|
||||
</b></code></blockquote>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
typedef ptrdiff_t<br>
|
||||
typedef size_t<br>
|
||||
typedef wchar_t<br>
|
||||
</b></code></blockquote>
|
||||
<a name="variables"></a>
|
||||
<h2>2.11.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
<code><b>ptrdiff_t</b></code> is the result of subtracting two pointers.<br>
|
||||
<code><b>size_t</b></code> is the unsigned integer result of the sizeof keyword.<br>
|
||||
<code><b>wchar_t</b></code> is an integer type of the size of a wide character constant.<br>
|
||||
<p>
|
||||
<code><b>NULL</b></code> is the value of a null pointer constant.
|
||||
<p>
|
||||
<code><b>offsetof(</b></code><i>type</i><code><b>,</b></code><i> member-designator</i><code><b>)</b></code>
|
||||
<p>
|
||||
This results in a constant integer of type <code><b>size_t</b></code> which is the offset in bytes of a structure
|
||||
member from the beginning of the structure. The member is given by <i>member-designator</i>, and
|
||||
the name of the structure is given in <i>type</i>.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<stddef.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct user{
|
||||
char name[50];
|
||||
char alias[50];
|
||||
int level;
|
||||
};
|
||||
|
||||
printf("level is the %d byte in the user structure.\n"),
|
||||
offsetof(struct user,level));
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
The output should be:<br>
|
||||
<pre>
|
||||
level is the 100 byte in the user structure.
|
||||
</pre>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.10.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.10 stdarg.h</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="2.12.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.12 stdio.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
973
Ref-docs/c_lib_guide/2.12.html
Normal file
973
Ref-docs/c_lib_guide/2.12.html
Normal file
@@ -0,0 +1,973 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.12 stdio.h
|
||||
</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="2.11.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.11 stddef.h</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="2.13.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.13 stdlib.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.12 stdio.h</h1>
|
||||
<p>
|
||||
The stdio header provides functions for performing input and output.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><b><code>
|
||||
NULL<br>
|
||||
_IOFBF<br>
|
||||
_IOLBF<br>
|
||||
_IONBF<br>
|
||||
BUFSIZ<br>
|
||||
EOF<br>
|
||||
FOPEN_MAX<br>
|
||||
FILENAME_MAX<br>
|
||||
L_tmpnam<br>
|
||||
SEEK_CUR<br>
|
||||
SEEK_END<br>
|
||||
SEEK_SET<br>
|
||||
TMP_MAX<br>
|
||||
stderr<br>
|
||||
stdin<br>
|
||||
stdout<br>
|
||||
</code></b></blockquote>
|
||||
<p>
|
||||
Functions:
|
||||
<blockquote><b><code>
|
||||
clearerr();<br>
|
||||
fclose();<br>
|
||||
feof();<br>
|
||||
ferror();<br>
|
||||
fflush();<br>
|
||||
fgetpos();<br>
|
||||
fopen();<br>
|
||||
fread();<br>
|
||||
freopen();<br>
|
||||
fseek();<br>
|
||||
fsetpos();<br>
|
||||
ftell();<br>
|
||||
fwrite();<br>
|
||||
remove();<br>
|
||||
rename();<br>
|
||||
rewind();<br>
|
||||
setbuf();<br>
|
||||
setvbuf();<br>
|
||||
tmpfile();<br>
|
||||
tmpnam();<br>
|
||||
fprintf();<br>
|
||||
fscanf();<br>
|
||||
printf();<br>
|
||||
scanf();<br>
|
||||
sprintf();<br>
|
||||
sscanf();<br>
|
||||
vfprintf();<br>
|
||||
vprintf();<br>
|
||||
vsprintf();<br>
|
||||
fgetc();<br>
|
||||
fgets();<br>
|
||||
fputc();<br>
|
||||
fputs();<br>
|
||||
getc();<br>
|
||||
getchar();<br>
|
||||
gets();<br>
|
||||
putc();<br>
|
||||
putchar();<br>
|
||||
puts();<br>
|
||||
ungetc(); <br>
|
||||
perror(); <br>
|
||||
</code></b></blockquote>
|
||||
Variables:
|
||||
<blockquote><b><code>
|
||||
typedef size_t<br>
|
||||
typedef FILE<br>
|
||||
typedef fpos_t<br>
|
||||
</code></b></blockquote>
|
||||
<a name="variables"></a>
|
||||
<h2>2.12.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
<blockquote>
|
||||
<code><b>size_t</b></code> is the unsigned integer result of the sizeof keyword.<br>
|
||||
<code><b>FILE</b></code> is a type suitable for storing information for a file stream.<br>
|
||||
<code><b>fpos_t</b></code> is a type suitable for storing any position in a file.<br>
|
||||
<br>
|
||||
<code><b>NULL</b></code> is the value of a null pointer constant.<br>
|
||||
<code><b>_IOFBF</b></code>, <code><b>_IOLBF</b></code>, and <code><b>_IONBF</b></code> are used in the setvbuf function.<br>
|
||||
<code><b>BUFSIZ</b></code> is an integer which represents the size of the buffer used by the setbuf function.<br>
|
||||
<code><b>EOF</b></code> is a negative integer which indicates an end-of-file has been reached.<br>
|
||||
<code><b>FOPEN_MAX</b></code> is an integer which represents the maximum number of files that the
|
||||
system can guarantee that can be opened simultaneously.<br>
|
||||
<code><b>FILENAME_MAX</b></code> is an integer which represents the longest length of a char array
|
||||
suitable for holding the longest possible filename. If the implementation imposes no limit, then
|
||||
this value should be the recommended maximum value.<br>
|
||||
<code><b>L_tmpnam</b></code> is an integer which represents the longest length of a char array suitable for
|
||||
holding the longest possible temporary filename created by the tmpnam function. <br>
|
||||
<code><b>SEEK_CUR</b></code>, <code><b>SEEK_END</b></code>, and <code><b>SEEK_SET </b></code>are used in the fseek function.<br>
|
||||
<code><b>TMP_MAX</b></code> is the maximum number of unique filenames that the function tmpnam can
|
||||
generate.<br>
|
||||
<code><b>stderr</b></code>, <code><b>stdin</b></code>, and <code><b>stdout</b></code> are pointers to <code><b>FILE</b></code> types which correspond to the standard
|
||||
error, standard input, and standard output streams.<br>
|
||||
</blockquote>
|
||||
<a name="streams"></a>
|
||||
<h2>2.12.2 Streams and Files</h2>
|
||||
<p>
|
||||
Streams facilitate a way to create a level of abstraction between the program and an
|
||||
input/output device. This allows a common method of sending and receiving data amongst the
|
||||
various types of devices available. There are two types of streams: text and binary.
|
||||
<p>
|
||||
Text streams are composed of lines. Each line has zero or more characters and are
|
||||
terminated by a new-line character which is the last character in a line. Conversions may occur
|
||||
on text streams during input and output. Text streams consist of only printable characters, the
|
||||
tab character, and the new-line character. Spaces cannot appear before a newline character,
|
||||
although it is implementation-defined whether or not reading a text stream removes these
|
||||
spaces. An implementation must support lines of up to at least 254 characters including the
|
||||
new-line character.
|
||||
<p>
|
||||
Binary streams input and output data in an exactly 1:1 ratio. No conversion exists and all
|
||||
characters may be transferred.
|
||||
<p>
|
||||
When a program begins, there are already three available streams: standard input,
|
||||
standard output, and standard error.
|
||||
<p>
|
||||
Files are associated with streams and must be opened to be used. The point of I/O within
|
||||
a file is determined by the file position. When a file is opened, the file position points to the
|
||||
beginning of the file unless the file is opened for an append operation in which case the position
|
||||
points to the end of the file. The file position follows read and write operations to indicate
|
||||
where the next operation will occur.
|
||||
<p>
|
||||
When a file is closed, no more actions can be taken on it until it is opened again. Exiting
|
||||
from the main function causes all open files to be closed.
|
||||
|
||||
<h2> 2.12.3 File Functions</h2>
|
||||
<a name="clearerr"></a>
|
||||
<h2>2.12.3.1 clearerr</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void clearerr(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Clears the end-of-file and error indicators for the given stream. As long as the error
|
||||
indicator is set, all stream operations will return an error until <ocde><b>clearerr</b></code> or <code><b>rewind</b></code> is called.
|
||||
<p>
|
||||
<a name="fclose"></a>
|
||||
<h2>2.12.3.2 fclose</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fclose(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
Closes the stream. All buffers are flushed.
|
||||
<p>
|
||||
If successful, it returns zero. On error it returns <code><b>EOF</b></code>.
|
||||
|
||||
<a name="feof"></a>
|
||||
<h2>2.12.3.3 feof</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int feof(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Tests the end-of-file indicator for the given stream. If the stream is at the end-of-file,
|
||||
then it returns a nonzero value. If it is not at the end of the file, then it returns zero.
|
||||
|
||||
<a name="ferror"></a>
|
||||
<h2>2.12.3.4 ferror</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int ferror(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Tests the error indicator for the given stream. If the error indicator is set, then it returns a
|
||||
nonzero value. If the error indicator is not set, then it returns zero.
|
||||
|
||||
<a name="fflush"></a>
|
||||
<h2>2.12.3.5 fflush</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fflush(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Flushes the output buffer of a stream. If stream is a null pointer, then all output buffers
|
||||
are flushed.
|
||||
<p>
|
||||
If successful, it returns zero. On error it returns <code><b>EOF</b></code>.
|
||||
|
||||
<a name="fgetpos"></a>
|
||||
<h2>2.12.3.6 fgetpos</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fgetpos(FILE *</b></code><i>stream</i><b><code>, fpos_t *</b></code><i>pos</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Gets the current file position of the stream and writes it to <i>pos</i>.
|
||||
<p>
|
||||
If successful, it returns zero. On error it returns a nonzero value and stores the error
|
||||
number in the variable <code><b>errno</b></code>.
|
||||
|
||||
<a name="fopen"></a>
|
||||
<h2>2.12.3.7 fopen</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
FILE *fopen(const char *</b></code><i>filename</i><b><code>, const char *</b></code><i>mode</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
Opens the filename pointed to by filename. The mode argument may be one of the
|
||||
following constant strings:
|
||||
<table border=0>
|
||||
<tr><td><code><b>r</b></code></td><td> read text mode</td></tr>
|
||||
<tr><td><code><b>w</b></code></td><td> write text mode (truncates file to zero length or creates new file)</td></tr>
|
||||
<tr><td><code><b>a </b></code></td><td> append text mode for writing (opens or creates file and sets file pointer to the
|
||||
end-of-file)</td></tr>
|
||||
<tr><td><code><b>rb</b></code></td><td> read binary mode</td></tr>
|
||||
<tr><td><code><b>wb </b></code></td><td> write binary mode (truncates file to zero length or creates new file)</td></tr>
|
||||
<tr><td><code><b>ab </b></code></td><td> append binary mode for writing (opens or creates file and sets file pointer to the
|
||||
end-of-file)</td></tr>
|
||||
<tr><td><code><b>r+</b></code></td><td> read and write text mode</td></tr>
|
||||
<tr><td><code><b>w+</b></code></td><td> read and write text mode (truncates file to zero length or creates new file)</td></tr>
|
||||
<tr><td><code><b>a+ </b></code></td><td> read and write text mode (opens or creates file and sets file pointer to the
|
||||
end-of-file)</td></tr>
|
||||
<tr><td><code><b>r+b</b></code> or<code><b> rb+</b></code></td><td> read and write binary mode</td></tr>
|
||||
<tr><td><code><b>w+b</b></code> or<code><b> wb+</b></code></td><td> read and write binary mode (truncates file to zero length or creates new file)</td></tr>
|
||||
<tr><td><code><b>a+b</b></code> or<code><b> ab+</b></code></td><td> read and write binary mode (opens or creates file and sets file pointer to the
|
||||
end-of-file)</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
If the file does not exist and it is opened with read mode (<code><b>r</b></code>), then the open fails.
|
||||
<p>
|
||||
If the file is opened with append mode (<code><b>a</b></code>), then all write operations occur at the end of
|
||||
the file regardless of the current file position.
|
||||
<p>
|
||||
If the file is opened in the update mode (<code><b>+</b></code>), then output cannot be directly followed by
|
||||
input and input cannot be directly followed by output without an intervening fseek, fsetpos,
|
||||
rewind, or fflush.
|
||||
<p>
|
||||
On success a pointer to the file stream is returned. On failure a null pointer is returned.
|
||||
|
||||
<a name="fread"></a>
|
||||
<h2>2.12.3.8 fread</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t fread(void *</b></code><i>ptr</i><b><code>, size_t </b></code><i>size</i><b><code>, size_t</b></code><i> nmemb</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Reads data from the given stream into the array pointed to by <i>ptr</i>. It reads <i>nmemb</i>
|
||||
number of elements of size <i>size</i>. The total number of bytes read is (<code><b>size*nmemb</b></code>).
|
||||
<p>
|
||||
On success the number of elements read is returned. On error or end-of-file the total
|
||||
number of elements successfully read (which may be zero) is returned.
|
||||
|
||||
<a name="freopen"></a>
|
||||
<h2>2.12.3.9 freopen</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
FILE *freopen(const char *</b></code><i>filename</i><b><code>, const char *</b></code><i>mode</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Associates a new filename with the given open stream. The old file in stream is closed.
|
||||
If an error occurs while closing the file, the error is ignored. The mode argument is the same as
|
||||
described in the fopen command. Normally used for reassociating stdin, stdout, or stderr.
|
||||
<p>
|
||||
On success the pointer to the stream is returned. On error a null pointer is returned.
|
||||
|
||||
<a name="fseek"></a>
|
||||
<h2>2.12.3.10 fseek</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fseek(FILE *</b></code><i>stream</i><b><code>, long int </b></code><i>offset</i><b><code>, int</b></code><i> whence</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Sets the file position of the stream to the given offset. The argument <i>offset</i> signifies the
|
||||
number of bytes to seek from the given whence position. The argument <i>whence</i> can be:
|
||||
<table border=0>
|
||||
<tr><td><code><b>SEEK_SET</b></code></td><td> Seeks from the beginning of the file.</td></tr>
|
||||
<tr><td><code><b>SEEK_CUR</b></code></td><td> Seeks from the current position.</td></tr>
|
||||
<tr><td><code><b>SEEK_END</b></code></td><td> Seeks from the end of the file.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
On a text stream, whence should be <code><b>SEEK_SET</b></code> and <i>offset</i> should be either zero or a
|
||||
value returned from <code><b>ftell</b></code>.
|
||||
<p>
|
||||
The end-of-file indicator is reset. The error indicator is NOT reset.
|
||||
<p>
|
||||
On success zero is returned. On error a nonzero value is returned.
|
||||
|
||||
<a name="fsetpos"></a>
|
||||
<h2>2.12.3.11 fsetpos</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fsetpos(FILE *</b></code><i>stream</i><b><code>, const fpos_t *</b></code><i>pos</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Sets the file position of the given stream to the given position. The argument <i>pos</i> is a
|
||||
position given by the function <code><b>fgetpos</b></code>. The end-of-file indicator is cleared.
|
||||
<p>
|
||||
On success zero is returned. On error a nonzero value is returned and the variable <code><b>errno</b></code>
|
||||
is set.
|
||||
|
||||
<a name="ftell"></a>
|
||||
<h2>2.12.3.12 ftell</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
long int ftell(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns the current file position of the given stream. If it is a binary stream, then the
|
||||
value is the number of bytes from the beginning of the file. If it is a text stream, then the value
|
||||
is a value useable by the fseek function to return the file position to the current position.
|
||||
<p>
|
||||
On success the current file position is returned. On error a value of <code><b>-1L</b></code> is returned and
|
||||
<code><b>errno</b></code> is set.
|
||||
|
||||
<a name="fwrite"></a>
|
||||
<h2>2.12.3.13 fwrite</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t fwrite(const void *</b></code><i>ptr</i><b><code>, size_t</b></code><i> size</i><b><code>, size_t</b></code><i> nmemb</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Writes data from the array pointed to by <i>ptr</i> to the given stream. It writes <i>nmemb</i>
|
||||
number of elements of size <i>size</i>. The total number of bytes written is (<code><b>size*nmemb</b></code>).
|
||||
<p>
|
||||
On success the number of elements writen is returned. On error the total number of
|
||||
elements successfully writen (which may be zero) is returned.
|
||||
|
||||
<a name="remove"></a>
|
||||
<h2>2.12.3.14 remove</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int remove(const char *</b></code><i>filename</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Deletes the given filename so that it is no longer accessible (unlinks the file). If the file
|
||||
is currently open, then the result is implementation-defined.
|
||||
<p>
|
||||
On success zero is returned. On failure a nonzero value is returned.
|
||||
|
||||
<a name="rename"></a>
|
||||
<h2>2.12.3.15 rename</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int rename(const char *</b></code><i>old_filename</i><b><code>, const char *</b></code><i>new_filename</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Causes the filename referred to by <i>old_filename</i> to be changed to <i>new_filename</i>. If the
|
||||
filename pointed to by <i>new_filename</i> exists, the result is implementation-defined.
|
||||
<p>
|
||||
On success zero is returned. On error a nonzero value is returned and the file is still
|
||||
accessible by its old filename.
|
||||
|
||||
<a name="rewind"></a>
|
||||
<h2>2.12.3.16 rewind</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void rewind(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Sets the file position to the beginning of the file of the given stream. The error and
|
||||
end-of-file indicators are reset.
|
||||
|
||||
<a name="setbuf"></a>
|
||||
<h2>2.12.3.17 setbuf</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void setbuf(FILE *</b></code><i>stream</i><b><code>, char *</b></code><i>buffer</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Defines how a stream should be buffered. This should be called after the stream has
|
||||
been opened but before any operation has been done on the stream. Input and output is fully
|
||||
buffered. The default <b><code>BUFSIZ</code></b> is the size of the buffer. The argument <i>buffer</i> points to an array
|
||||
to be used as the buffer. If <i>buffer</i> is a null pointer, then the stream is unbuffered.
|
||||
|
||||
<a name="setvbuf"></a>
|
||||
<h2>2.12.3.18 setvbuf</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int setvbuf(FILE *</b></code><i>stream</i><b><code>, char *</b></code><i>buffer</i><b><code>, int</b></code><i> mode</i><b><code>, size_t </b></code><i>size</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Defines how a stream should be buffered. This should be called after the stream has
|
||||
been opened but before any operation has been done on the stream. The argument <i>mode</i> defines
|
||||
how the stream should be buffered as follows:
|
||||
<table border=0>
|
||||
<tr><td valign=top><code><b>_IOFBF</b></code></td><td> Input and output is fully buffered.
|
||||
If the buffer is empty, an input operation attempts to fill the buffer.
|
||||
On output the buffer will be completely filled before any information is written to
|
||||
the file (or the stream is closed). </td></tr>
|
||||
<tr><td valign=top><code><b>_IOLBF</b></code></td><td> Input and output is line buffered.
|
||||
If the buffer is empty, an input operation attempts to fill the buffer.
|
||||
On output the buffer will be flushed whenever a newline character is written.</td></tr>
|
||||
<tr><td valign=top><code><b>_IONBF</b></code></td><td> Input and output is not buffered.
|
||||
No buffering is performed.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
The argument <i>buffer</i> points to an array to be used as the buffer. If <i>buffer</i> is a null
|
||||
pointer, then <code><b>setvbuf</b></code> uses <code><b>malloc</b></code> to create its own buffer.
|
||||
<p>
|
||||
The argument <i>size</i> determines the size of the array.
|
||||
<p>
|
||||
On success zero is returned. On error a nonzero value is returned.
|
||||
|
||||
<a name="tmpfile"></a>
|
||||
<h2>2.12.3.19 tmpfile</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
FILE *tmpfile(void);
|
||||
</b></code></blockquote>
|
||||
|
||||
Creates a temporary file in binary update mode (wb+). The tempfile is removed when
|
||||
the program terminates or the stream is closed.
|
||||
<p>
|
||||
On success a pointer to a file stream is returned. On error a null pointer is returned.
|
||||
|
||||
<a name="tmpnam"></a>
|
||||
<h2>2.12.3.20 tmpnam</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *tmpnam(char *</b></code><i>str</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Generates and returns a valid temporary filename which does not exist. Up to
|
||||
<code><b>TMP_MAX</b></code> different filenames can be generated.
|
||||
<p>
|
||||
If the argument <i>str</i> is a null pointer, then the function returns a pointer to a valid
|
||||
filename. If the argument <i>str</i> is a valid pointer to an array, then the filename is written to the
|
||||
array and a pointer to the same array is returned. The filename may be up to <code><b>L_tmpnam</b></code>
|
||||
characters long.
|
||||
<h2> 2.12.4 Formatted I/O Functions</h2>
|
||||
<a name="fprintf"></a>
|
||||
<a name="printf"></a>
|
||||
<a name="sprintf"></a>
|
||||
<a name="vfprintf"></a>
|
||||
<a name="vprintf"></a>
|
||||
<a name="vsprintf"></a>
|
||||
<h2>2.12.4.1 ..printf Functions</h2>
|
||||
<p>
|
||||
Declarations:
|
||||
<blockquote><code><b>
|
||||
int fprintf(FILE *</b></code><i>stream</i><b><code>, const char *</b></code><i>format</i><b><code>, ...);<br>
|
||||
int printf(const char *</b></code><i>format</i><b><code>, ...);<br>
|
||||
int sprintf(char *</b></code><i>st</i><b><code>r, const char *</b></code><i>format</i><b><code>, ...);<br>
|
||||
int vfprintf(FILE *</b></code><i>stream</i><b><code>, const char *</b></code><i>format</i><b><code>, va_list </b></code><i>arg</i><b><code>);<br>
|
||||
int vprintf(const char *</b></code><i>format</i><b><code>, va_list</b></code><i> arg</i><b><code>);<br>
|
||||
int vsprintf(char *</b></code><i>str</i><b><code>, const char *</b></code><i>format</i><b><code>, va_list</b></code><i> arg</i><b><code>);<br>
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
The ..printf functions provide a means to output formatted information to a stream.
|
||||
<p>
|
||||
<table border=0>
|
||||
<tr><td><code><b>fprintf</b></code></td><td> sends formatted output to a stream</td></tr>
|
||||
<tr><td><code><b>printf</b></code></td><td> sends formatted output to stdout</td></tr>
|
||||
<tr><td><code><b>sprintf</b></code></td><td> sends formatted output to a string</td></tr>
|
||||
<tr><td><code><b>vfprintf</b></code></td><td> sends formatted output to a stream using an argument list</td></tr>
|
||||
<tr><td><code><b>vprintf</b></code></td><td> sends formatted output to stdout using an argument list</td></tr>
|
||||
<tr><td><code><b>vsprintf </b></code></td><td> sends formatted output to a string using an argument list</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
These functions take the format string specified by the <i>format</i> argument and apply each
|
||||
following argument to the format specifiers in the string in a left to right fashion. Each character
|
||||
in the format string is copied to the stream except for conversion characters which specify a
|
||||
format specifier.
|
||||
<p>
|
||||
The string commands (<code><b>sprintf</b></code> and <code><b>vsprintf</b></code>) append a null character to the end of the
|
||||
string. This null character is not counted in the character count.
|
||||
<p>
|
||||
The argument list commands (<code><b>vfprintf</b></code>, <code><b>vprintf</b></code>, and <code><b>vsprintf</b></code>) use an argument list which
|
||||
is prepared by <code><b>va_start</b></code>. These commands do not call <code><b>va_end</b></code> (the caller must call it).
|
||||
<p>
|
||||
A conversion specifier begins with the <code><b>%</b></code> character. After the <code><b>%</b></code> character come the
|
||||
following in this order:
|
||||
<table border=0>
|
||||
<tr><td>[<b>flags</b>]</td><td> Control the conversion (optional).</td></tr>
|
||||
<tr><td>[<b>width</b>]</td><td> Defines the number of characters to print (optional).</td></tr>
|
||||
<tr><td>[<b>.precision</b>]</td><td> Defines the amount of precision to print for a number type (optional).</td></tr>
|
||||
<tr><td>[<b>modifier</b>]</td><td> Overrides the size (type) of the argument (optional).</td></tr>
|
||||
<tr><td>[<b>type</b>]</td><td> The type of conversion to be applied (required).</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<b>Flags</b>:<br>
|
||||
<table border=0>
|
||||
<tr><td valign=top><code><b>-</b></code></td><td> Value is left justified (default is right justified). Overrides the 0 flag.</td></tr>
|
||||
<tr><td valign=top><code><b>+</b></code></td><td> Forces the sign (+ or -) to always be shown. Default is to just show the - sign. Overrides
|
||||
the space flag.</td></tr>
|
||||
<tr><td valign=top><code><b>space</b></code></td><td> Causes a positive value to display a space for the sign. Negative values still show the -
|
||||
sign.</td></tr>
|
||||
<tr><td valign=top><code><b>#</b></code></td><td> Alternate form:
|
||||
<table border=0>
|
||||
<tr><th> Conversion Character</th><th> Result</th><tr>
|
||||
<tr><td><code><b> o</b></code></td><td> Precision is increased to make the first digit a zero.</td></tr>
|
||||
<tr><td><code><b> X or x </b></code></td><td> Nonzero value will have 0x or 0X prefixed to it.</td></tr>
|
||||
<tr><td><code><b> E, e, f, g, or G </b></code></td><td> Result will always have a decimal point.</td></tr>
|
||||
<tr><td><code><b> G or g </b></code></td><td> Trailing zeros will not be removed.</td></tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td valign=top><code><b>0 </b></code></td><td> For d, i, o, u, x, X, e, E, f, g, and G leading zeros are used to pad the field width instead
|
||||
of spaces. This is useful only with a width specifier. Precision overrides this flag.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<b>Width</b>:<br>
|
||||
The width of the field is specified here with a decimal value. If the value is not large
|
||||
enough to fill the width, then the rest of the field is padded with spaces (unless the 0 flag is
|
||||
specified). If the value overflows the width of the field, then the field is expanded to fit the
|
||||
value. If a <code><b>*</b></code> is used in place of the width specifer, then the next argument (which must be an <code><b>int</b></code>
|
||||
type) specifies the width of the field. Note: when using the <code><b>*</b></code> with the width and/or precision
|
||||
specifier, the width argument comes first, then the precision argument, then the value to be
|
||||
converted.
|
||||
<p>
|
||||
<b>Precision</b>:<br>
|
||||
The precision begins with a dot (.) to distinguish itself from the width specifier. The
|
||||
precision can be given as a decimal value or as an asterisk (<code><b>*</b></code>). If a <code><b>*</b></code> is used, then the next
|
||||
argument (which is an <code><b>int</b></code> type) specifies the precision. Note: when using the <code><b>*</b></code> with the width
|
||||
and/or precision specifier, the width argument comes first, then the precision argument, then the
|
||||
value to be converted. Precision does not affect the c type.
|
||||
<table border=0>
|
||||
<tr><th>[.precision]</th><th> Result</th></tr>
|
||||
<tr><td valign=top>(<i>none</i>)</td><td> Default precision values:<br>
|
||||
1 for <code><b>d</b></code>, <code><b>i</b></code>, <code><b>o</b></code>, <code><b>u</b></code>, <code><b>x</b></code>, <code><b>X</b></code> types. The minimum number of digits to appear.<br>
|
||||
6 for <code><b>f</b></code>, <code><b>e</b></code>, <code><b>E</b></code> types. Specifies the number of digits after the decimal point.<br>
|
||||
For <code><b>g</b></code> or <code><b>G</b></code> types all significant digits are shown.<br>
|
||||
For <code><b>s</b></code> type all characters in string are print up to but not including the null
|
||||
character.</td></tr>
|
||||
|
||||
<tr><td valign=top><code><b>.</b></code> <i>or</i> <code><b>.0</b></code></td><td> For <code><b>d</b></code>, <code><b>i</b></code>, <code><b>o</b></code>, <code><b>u</b></code>, <code><b>x</b></code>, <code><b>X</b></code> types the default precis
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ion value is used unless the value is zero
|
||||
in which case no characters are printed.<br>
|
||||
For <code><b>f</b></code>, <code><b>e</b></code>, <code><b>E</b></code> types no decimal point character or digits are printed.<br>
|
||||
For <code><b>g</b></code> or <code><b>G</b></code> types the precision is assumed to be 1.<br>
|
||||
</td></tr>
|
||||
<tr><td valign=top><code><b>.</b></code><i>n</i> </td><td> For <code><b>d</b></code>, <code><b>i</b></code>, <code><b>o</b></code>, <code><b>u</b></code>, <code><b>x</b></code>, <code><b>X</b></code> types then at least n digits are printed (padding
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
with zeros if
|
||||
necessary).<br>
|
||||
For <code><b>f</b></code>, <code><b>e</b></code>, <code><b>E</b></code> types specifies the number of digits after the decimal point.<br>
|
||||
For <code><b>g</b></code> or <code><b>G</b></code> types specifies the number of significant digits to print.<br>
|
||||
For<code><b> s</b></code> type specifies the maximum number of characters to print.<br>
|
||||
</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<b>Modifier</b>:<br>
|
||||
A modifier changes the way a conversion specifier type is interpreted.
|
||||
<table broder=0>
|
||||
<tr><td><b>[modifier]</b></td><td><b> [type]</b></td><td> <b>Effect</b></td></tr>
|
||||
<tr><td><code><b>h</b></code></td><td> <code><b>d</b></code>, <code><b>i</b></code>, <code><b>o</b></code>, <code><b>u</b></code>, <code><b>x</b></code>, <code><b>X</b></code></td><td> Value is first converted to a short int or unsigned short i
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nt.</td></tr>
|
||||
<tr><td><code><b>h</b></code></td><td> <code><b>n</b></code> </td><td> Specifies that the pointer points to a short int.</td></tr>
|
||||
<tr><td><code><b>l</b></code></td><td> <code><b>d</b></code>, <code><b>i</b></code>, <code><b>o</b></code>, <code><b>u</b></code>, <code><b>x</b></code>, <code><b>X</b></code> </td><td> Value is first converted to a long int or unsigned long int
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.</td></tr>
|
||||
<tr><td><code><b>l</b></code></td><td> <code><b>n</b></code></td><td> Specifies that the pointer points to a long int.</td></tr>
|
||||
<tr><td><code><b>L</b></code></td><td> <code><b>e</b></code>, <code><b>E</b></code>, <code><b>f</b></code>, <code><b>g</b></code>, <code><b>G</b></code></td><td> Value is first converted to a long double.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<b>Conversion specifier type</b>:<br>
|
||||
The conversion specifier specifies what type the argument is to be treated as.
|
||||
<table border=0>
|
||||
<tr><th>[type] </th><th> Output</th></tr>
|
||||
<tr><td valign=top><code><b>d</b></code>, <code><b>i</b></code></td><td> Type <code><b>signed int</b></code>.</td></tr>
|
||||
<tr><td valign=top><code><b>o</b></code></td><td> Type <code><b>unsigned int</b></code> printed in octal.</td></tr>
|
||||
<tr><td valign=top><code><b>u</b></code> </td><td> Type <code><b>unsigned int</b></code> printed in decimal.</td></tr>
|
||||
<tr><td valign=top><code><b>x</b></code> </td><td> Type <code><b>unsigned int</b></code> printed in hexadecimal as dddd using a, b, c, d, e, f.</td></tr>
|
||||
<tr><td valign=top><code><b>X</b></code> </td><td> Type <code><b>unsigned int</b></code> printed in hexadecimal as dddd using A, B, C, D, E, F.</td></tr>
|
||||
<tr><td valign=top><code><b>f</b></code> </td><td> Type <code><b>double</b></code> printed as [-]ddd.ddd.</td></tr>
|
||||
<tr><td valign=top><code><b>e</b></code>, <code><b>E</b></code> </td><td> Type <code><b>double</b></code> printed as [-]d.ddde<64>dd where there is one digit printed before the
|
||||
decimal (zero only if the value is zero). The exponent contains at least two
|
||||
digits. If type is E then the exponent is printed with a capital E.</td></tr>
|
||||
<tr><td valign=top><code><b>g</b></code>, <code><b>G</b></code> </td><td> Type <code><b>double</b></code> printed as type e or E if the exponent is less than -4 or greater than
|
||||
or equal to the precision. Otherwise printed as type f. Trailing zeros are
|
||||
removed. Decimal point character appears only if there is a nonzero decimal digit.</td></tr>
|
||||
<tr><td valign=top><code><b>c</b></code></td><td> Type <code><b>char</b></code>. Single character is printed.</td></tr>
|
||||
<tr><td valign=top><code><b>s</b></code></td><td> Type pointer to array. String is printed according to precision (no precision prints
|
||||
entire string).</td></tr>
|
||||
<tr><td valign=top><code><b>p</b></code> </td><td> Prints the value of a pointer (the memory location it holds).</td></tr>
|
||||
<tr><td valign=top><code><b>n</b></code> </td><td> The argument must be a pointer to an <code><b>int</b></code>. Stores the number of characters printed
|
||||
thus far in the int. No characters are printed.</td></tr>
|
||||
<tr><td valign=top><code><b>%</b></code> </td><td> A <code><b>%</b></code> sign is printed.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
The number of characters printed are returned. If an error occurred, -1 is returned.
|
||||
|
||||
<a name="fscanf"></a>
|
||||
<a name="scanf"></a>
|
||||
<a name="sscanf"></a>
|
||||
<h2>2.12.4.2 ..scanf Functions</h2>
|
||||
<p>
|
||||
Declarations:
|
||||
<blockquote><code><b>
|
||||
int fscanf(FILE *</b></code><i>stream</i><b><code>, const char *</b></code><i>format</i><b><code>, ...);<br>
|
||||
int scanf(const char *</b></code><i>format</i><b><code>, ...);<br>
|
||||
int sscanf(const char *</b></code><i>str</i><b><code>, const char *</b></code><i>format</i><b><code>, ...);<br>
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
The ..scanf functions provide a means to input formatted information from a stream.
|
||||
<table border=0>
|
||||
<tr><td><code><b>fscanf</b></code></td><td> reads formatted input from a stream</td></tr>
|
||||
<tr><td><code><b>scanf</b></code></td><td> reads formatted input from stdin</td></tr>
|
||||
<tr><td><code><b>sscanf</b></code></td><td> reads formatted input from a string</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
These functions take input in a manner that is specified by the format argument and store
|
||||
each input field into the following arguments in a left to right fashion.
|
||||
<p>
|
||||
Each input field is specified in the format string with a conversion specifier which
|
||||
specifies how the input is to be stored in the appropriate variable. Other characters in the format
|
||||
string specify characters that must be matched from the input, but are not stored in any of the
|
||||
following arguments. If the input does not match then the function stops scanning and returns.
|
||||
A whitespace character may match with any whitespace character (space, tab, carriage return,
|
||||
new line, vertical tab, or formfeed) or the next incompatible character.
|
||||
<p>
|
||||
An input field is specified with a conversion specifer which begins with the <code><b>%</b></code> character.
|
||||
After the <code><b>%</b></code> character come the following in this order:
|
||||
<table border=0>
|
||||
<tr><td><b>[*]</b></td><td> Assignment suppressor (optional).</td></tr>
|
||||
<tr><td><b>[width]</b></td><td> Defines the maximum number of characters to read (optional).</td></tr>
|
||||
<tr><td><b>[modifier]</b></td><td> Overrides the size (type) of the argument (optional).</td></tr>
|
||||
<tr><td><b>[type] </b></td><td> The type of conversion to be applied (required).</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<b>Assignment suppressor:</b><br>
|
||||
Causes the input field to be scanned but not stored in a variable.
|
||||
<p>
|
||||
<b>Width:</b><br>
|
||||
The maximum width of the field is specified here with a decimal value. If the input is
|
||||
smaller than the width specifier (i.e. it reaches a nonconvertible character), then what was read
|
||||
thus far is converted and stored in the variable.
|
||||
<p>
|
||||
<b>Modifier:</b><br>
|
||||
A modifier changes the way a conversion specifier type is interpreted.
|
||||
<table border=0>
|
||||
<tr><td><b>[modifier]</b></td><td><b> [type]</b></td><td><b> Effect</b><td></tr>
|
||||
<tr><td><b><code>h</code></b></td><td> <b><code>d</code></b>, <b><code>i</code></b>, <b><code>o</code></b>, <b><code>u</code></b>, <b><code>x</code></b> </td><td> The argument is a <b><code>short int</code></b> or <b><code>unsigned short int</code></b>.<
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/td></tr>
|
||||
<tr><td><b><code>h</code></b></td><td> <b><code>n</code></b> </td><td> Specifies that the pointer points to a <b><code>short int</code></b>.</td></tr>
|
||||
<tr><td><b><code>l</code></b></td><td> <b><code>d</code></b>, <b><code>i</code></b>, <b><code>o</code></b>, <b><code>u</code></b>, <b><code>x</code></b> </td><td> The argument is a <b><code>long int</code></b> or <b><code>unsigned long int</code>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</b>.</td></tr>
|
||||
<tr><td><b><code>l</code></b></td><td> <b><code>n</code></b> </td><td> Specifies that the pointer points to a <b><code>long int</code></b>.</td></tr>
|
||||
<tr><td><b><code>l</code></b></td><td> <b><code>e</code></b>, <b><code>f</code></b>, <b><code>g</code></b> </td><td> The argument is a <b><code>double</code></b>.</td></tr>
|
||||
<tr><td><b><code>L</code></b></td><td> <b><code>e</code></b>, <b><code>f</code></b>, <b><code>g</code></b> </td><td> The argument is a <b><code>long double</code></b>.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
<b>Conversion specifier type:</b><br>
|
||||
The conversion specifier specifies what type the argument is. It also controls what a
|
||||
valid convertible character is (what kind of characters it can read so it can convert to something
|
||||
compatible).
|
||||
<table border=0>
|
||||
<tr><td><b>[type]</b></td><td><b> Input</b></td></tr>
|
||||
<tr><td valign=top><code><b>d</b></code></td><td> Type <code><b>signed int</b></code> represented in base 10. Digits 0 through 9 and the sign (+ or -).</td></tr>
|
||||
<tr><td valign=top><code><b>i</b></code></td><td> Type <code><b>signed int</b></code>. The base (radix) is dependent on the first two characters. If the
|
||||
first character is a digit from 1 to 9, then it is base 10. If the first digit is a zero
|
||||
and the second digit is a digit from 1 to 7, then it is base 8 (octal). If the first digit is a
|
||||
zero and the second character is an x or X, then it is base 16 (hexadecimal).</td></tr>
|
||||
<tr><td valign=top><code><b>o</b></code></td><td> Type <code><b>unsigned int</b></code>. The input must be in base 8 (octal). Digits 0 through 7 only.</td></tr>
|
||||
<tr><td valign=top><code><b>u</b></code></td><td> Type <code><b>unsigned int</b></code>. The input must be in base 10 (decimal). Digits 0 through 9
|
||||
only.</td></tr>
|
||||
<tr><td valign=top><code><b>x, X</b></code></td><td> Type <code><b>unsigned int</b></code>. The input must be in base 16 (hexadecimal). Digits 0 through 9 or A through Z or a through z. The characters 0x or 0X may be optionally
|
||||
prefixed to the value.</td></tr>
|
||||
<tr><td valign=top><code><b>e</b></code>, <code><b>E</b></code>, <code><b>f</b></code>, <code><b>g</b></code>,<code><b> G</b></code></b></code></td><td> Type <code><b>float</b></code>. Begins with an optional sign. Then one or more digits, followed by
|
||||
an optional decimal-point and decimal value. Finally ended with an optional signed
|
||||
exponent value designated with an e or E.</td></tr>
|
||||
<tr><td valign=top><code><b>s</b></code></td><td> Type character array. Inputs a sequence of non-whitespace characters (space, tab,
|
||||
carriage return, new line, vertical tab, or formfeed). The array must be large
|
||||
enough to hold the sequence plus a null character appended to the end.</td></tr>
|
||||
<tr><td valign=top><code><b>[...]</b></code></td><td> Type character array. Allows a search set of characters. Allows input of only
|
||||
those character encapsulated in the brackets (the scanset). If the first character is a
|
||||
carrot (^), then the scanset is inverted and allows any ASCII character except
|
||||
those specified between the brackets. On some systems a range can be specified
|
||||
with the dash character (-). By specifying the beginning character, a dash, and an
|
||||
ending character a range of characters can be included in the scanset. A null character is appended to the end of the array.</td></tr>
|
||||
<tr><td valign=top><code><b>c</b></code></td><td> Type character array. Inputs the number of characters specified in the width
|
||||
field. If no width field is specified, then 1 is assumed. No null character is
|
||||
appended to the array.</td></tr>
|
||||
<tr><td valign=top><code><b>p</b></code></td><td> Pointer to a pointer. Inputs a memory address in the same fashion of the <code><b>%p</b></code> type
|
||||
produced by the printf function.</td></tr>
|
||||
<tr><td valign=top><code><b>n </b></code></td><td> The argument must be a pointer to an <code><b>int</b></code>. Stores the number of characters read
|
||||
thus far in the <code><b>int</b></code>. No characters are read from the input stream.</td></tr>
|
||||
<tr><td valign=top><code><b>% </b></code></td><td> Requires a matching <code><b>%</b></code> sign from the input.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
Reading an input field (designated with a conversion specifier) ends when an
|
||||
incompatible character is met, or the width field is satisfied.
|
||||
<p>
|
||||
On success the number of input fields converted and stored are returned. If an input
|
||||
failure occurred, then EOF is returned.
|
||||
<h2> 2.12.5 Character I/O Functions</h2>
|
||||
<a name="fgetc"></a>
|
||||
<h2>2.12.5.1 fgetc</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fgetc(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Gets the next character (an <code><b>unsigned char</b></code>) from the specified stream and advances the
|
||||
position indicator for the stream.
|
||||
<p>
|
||||
On success the character is returned. If the end-of-file is encountered, then <code><b>EOF</b></code> is
|
||||
returned and the end-of-file indicator is set. If an error occurs then the error indicator for the
|
||||
stream is set and <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="fgets"></a>
|
||||
<h2>2.12.5.2 fgets</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *fgets(char *</b></code><i>str</i><b><code>, int </b></code><i>n</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Reads a line from the specified stream and stores it into the string pointed to by <i>str</i>. It
|
||||
stops when either (n-1) characters are read, the newline character is read, or the end-of-file is
|
||||
reached, whichever comes first. The newline character is copied to the string. A null character
|
||||
is appended to the end of the string.
|
||||
<p>
|
||||
On success a pointer to the string is returned. On error a null pointer is returned. If the
|
||||
end-of-file occurs before any characters have been read, the string remains unchanged.
|
||||
|
||||
<a name="fputc"></a>
|
||||
<h2>2.12.5.3 fputc</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fputc(int</b></code><i> char</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Writes a character (an <code><b>unsigned char</b></code>) specified by the argument <i>char</i> to the specified
|
||||
stream and advances the position indicator for the stream.
|
||||
<p>
|
||||
On success the character is returned. If an error occurs, the error indicator for the stream
|
||||
is set and <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="fputs"></a>
|
||||
<h2>2.12.5.4 fputs</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int fputs(const char *</b></code><i>str</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Writes a string to the specified stream up to but not including the null character.
|
||||
<p>
|
||||
On success a nonnegative value is returned. On error <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="getc"></a>
|
||||
<h2>2.12.5.5 getc</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int getc(FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Gets the next character (an <code><b>unsigned char</b></code>) from the specified stream and advances the
|
||||
position indicator for the stream.
|
||||
<p>
|
||||
This may be a macro version of <code><b>fgetc</b></code>.
|
||||
<p>
|
||||
On success the character is returned. If the end-of-file is encountered, then <code><b>EOF</b></code> is
|
||||
returned and the end-of-file indicator is set. If an error occurs then the error indicator for the
|
||||
stream is set and <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="getchar"></a>
|
||||
<h2>2.12.5.6 getchar</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int getchar(void);
|
||||
</b></code></blockquote>
|
||||
|
||||
|
||||
Gets a character (an <code><b>unsigned char</b></code>) from <code><b>stdin</b></code>.
|
||||
<p>
|
||||
On success the character is returned. If the end-of-file is encountered, then <code><b>EOF</b></code> is
|
||||
returned and the end-of-file indicator is set. If an error occurs then the error indicator for the
|
||||
stream is set and <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="gets"></a>
|
||||
<h2>2.12.5.7 gets</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *gets(char *</b></code><i>str</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Reads a line from <code><b>stdin</b></code> and stores it into the string pointed to by <i>str</i>. It stops when either
|
||||
the newline character is read or when the end-of-file is reached, whichever comes first. The
|
||||
newline character is not copied to the string. A null character is appended to the end of the
|
||||
string.
|
||||
<p>
|
||||
On success a pointer to the string is returned. On error a null pointer is returned. If the
|
||||
end-of-file occurs before any characters have been read, the string remains unchanged.
|
||||
|
||||
<a name="putc"></a>
|
||||
<h2>2.12.5.8 putc</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int putc(int</b></code><i> char</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Writes a character (an<code><b> unsigned char</b></code>) specified by the argument <i>char</i> to the specified
|
||||
stream and advances the position indicator for the stream.
|
||||
<p>
|
||||
This may be a macro version of<code><b> fputc</b></code>.
|
||||
<p>
|
||||
On success the character is returned. If an error occurs, the error indicator for the stream
|
||||
is set and<code><b> EOF</b></code> is returned.
|
||||
|
||||
<a name="putchar"></a>
|
||||
<h2>2.12.5.9 putchar</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int putchar(int</b></code><i> char</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Writes a character (an <code><b>unsigned char</b></code>) specified by the argument <i>char</i> to <code><b>stdout</b></code>.
|
||||
<p>
|
||||
On success the character is returned. If an error occurs, the error indicator for the stream
|
||||
is set and <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="puts"></a>
|
||||
<h2>2.12.5.10 puts</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int puts(const char *</b></code><i>str</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Writes a string to <code><b>stdout</b></code> up to but not including the null character. A newline character
|
||||
is appended to the output.
|
||||
<p>
|
||||
On success a nonnegative value is returned. On error <code><b>EOF</b></code> is returned.
|
||||
|
||||
<a name="ungetc"></a>
|
||||
<h2>2.12.5.11 ungetc</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int ungetc(int </b></code><i>char</i><b><code>, FILE *</b></code><i>stream</i><b><code>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Pushes the character <i>char</i> (an <code><b>unsigned char</b></code>) onto the specified stream so that the this is
|
||||
the next character read. The functions <code><b>fseek</b></code>, <code><b>fsetpos</b></code>, and <code><b>rewind</b></code> discard any characters pushed
|
||||
onto the stream.
|
||||
<p>
|
||||
Multiple characters pushed onto the stream are read in a FIFO manner (first in, first out).
|
||||
<p>
|
||||
On success the character pushed is returned. On error <code><b>EOF</b></code> is returned.
|
||||
<h2> 2.12.7 Error Functions</h2>
|
||||
<a name="perror"></a>
|
||||
<h2>2.12.7.1 perror</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void perror(const char *</b></code><i>str</i><b><code>);
|
||||
|
||||
</b></code></blockquote>
|
||||
Prints a descriptive error message to stderr. First the string <i>str</i> is printed followed by a
|
||||
colon then a space. Then an error message based on the current setting of the variable <code><b>errno</b></code> is
|
||||
printed.
|
||||
<hr>
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.11.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.11 stddef.h</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="2.13.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.13 stdlib.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
680
Ref-docs/c_lib_guide/2.13.html
Normal file
680
Ref-docs/c_lib_guide/2.13.html
Normal file
@@ -0,0 +1,680 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.13 stdlib.h
|
||||
</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="2.12.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.12 stdio.h</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="2.14.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.14 string.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1>2.13 stdlib.h</h1>
|
||||
<p>
|
||||
The stdlib header defines several general operation functions and macros.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><b><code>
|
||||
NULL<br>
|
||||
EXIT_FAILURE<br>
|
||||
EXIT_SUCCESS<br>
|
||||
RAND_MAX<br>
|
||||
MB_CUR_MAX<br>
|
||||
</code></b></blockquote>
|
||||
<p>
|
||||
Variables:
|
||||
<blockquote><b><code>
|
||||
typedef size_t<br>
|
||||
typedef wchar_t<br>
|
||||
struct div_t<br>
|
||||
struct ldiv_t<br>
|
||||
</code></b></blockquote>
|
||||
<p>
|
||||
Functions:
|
||||
<blockquote><b><code>
|
||||
abort();<br>
|
||||
abs();<br>
|
||||
atexit();<br>
|
||||
atof();<br>
|
||||
atoi();<br>
|
||||
atol();<br>
|
||||
bsearch();<br>
|
||||
calloc();<br>
|
||||
div();<br>
|
||||
exit();<br>
|
||||
free();<br>
|
||||
getenv();<br>
|
||||
labs();<br>
|
||||
ldiv();<br>
|
||||
malloc();<br>
|
||||
mblen();<br>
|
||||
mbstowcs();<br>
|
||||
mbtowc();<br>
|
||||
qsort();<br>
|
||||
rand();<br>
|
||||
realloc();<br>
|
||||
srand();<br>
|
||||
strtod();<br>
|
||||
strtol();<br>
|
||||
strtoul();<br>
|
||||
system();<br>
|
||||
wcstombs();<br>
|
||||
wctomb();<br>
|
||||
</code></b></blockquote>
|
||||
<a name="variables"></a>
|
||||
<h2>2.13.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
<code><b>size_t</b></code> is the unsigned integer result of the <code><b>sizeof</b></code> keyword.<br>
|
||||
<code><b>wchar_t</b></code> is an integer type of the size of a wide character constant.<br>
|
||||
<code><b>div_t</b></code> is the structure returned by the <code><b>div</b></code> function.<br>
|
||||
<code><b>ldiv_t</b></code> is the structure returned by the <code><b>ldiv</b></code> function.<br>
|
||||
<p>
|
||||
<code><b>NULL</b></code> is the value of a null pointer constant.<br>
|
||||
<code><b>EXIT_FAILURE</b></code> and <code><b>EXIT_SUCCESS</b></code> are values for the exit function to return
|
||||
termination status.<br>
|
||||
<code><b>RAND_MAX</b></code> is the maximum value returned by the rand function.<br>
|
||||
<code><b>MB_CUR_MAX</b></code> is the maximum number of bytes in a multibyte character set which
|
||||
cannot be larger than <code><b>MB_LEN_MAX</b></code>.<br>
|
||||
<p>
|
||||
<h2> 2.13.2 String Functions</h2>
|
||||
<a name="atof"></a>
|
||||
<h2>2.13.2.1 atof</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
double atof(const char *</b></code><i>str</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The string pointed to by the argument <i>str</i> is converted to a floating-point number (type
|
||||
<code><b>double</b></code>). Any initial whitespace characters are skipped (space, tab, carriage return, new line,
|
||||
vertical tab, or formfeed). The number may consist of an optional sign, a string of digits with an
|
||||
optional decimal character, and an optional <code><b>e</b></code> or <code><b>E</b></code> followed by a optionally signed exponent.
|
||||
Conversion stops when the first unrecognized character is reached.
|
||||
<p>
|
||||
On success the converted number is returned. If no conversion can be made, zero is
|
||||
returned. If the value is out of range of the type double, then <code><b>HUGE_VAL</b></code> is returned with the
|
||||
appropriate sign and <code><b>ERANGE</b></code> is stored in the variable <code><b>errno</b></code>. If the value is too small to be
|
||||
returned in the type <code><b>double</b></code>, then zero is returned and <code><b>ERANGE</b></code> is stored in the variable <code><b>errno</b></code>.
|
||||
|
||||
<a name="atoi"></a>
|
||||
<h2>2.13.2.2 atoi</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int atoi(const char *</b></code><i>str</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The string pointed to by the argument <i>str</i> is converted to an integer (type <code><b>int</b></code>). Any initial
|
||||
whitespace characters are skipped (space, tab, carriage return, new line, vertical tab, or
|
||||
formfeed). The number may consist of an optional sign and a string of digits. Conversion stops
|
||||
when the first unrecognized character is reached.
|
||||
<p>
|
||||
On success the converted number is returned. If the number cannot be converted, then <code><b>0</b></code>
|
||||
is returned.
|
||||
|
||||
<a name="atol"></a>
|
||||
<h2>2.13.2.3 atol</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
long int atol(const char *</b></code><i>str</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The string pointed to by the argument <i>str</i> is converted to a long integer (type <code><b>long int</b></code>).
|
||||
Any initial whitespace characters are skipped (space, tab, carriage return, new line, vertical tab,
|
||||
or formfeed). The number may consist of an optional sign and a string of digits. Conversion
|
||||
stops when the first unrecognized character is reached.
|
||||
<p>
|
||||
On success the converted number is returned. If the number cannot be converted, then <code><b>0</b></code>
|
||||
is returned.
|
||||
|
||||
<a name="strtod"></a>
|
||||
<h2>2.13.2.4 strtod</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
double strtod(const char *</b></code><i>str</i><code><b>, char **</b></code><i>endptr</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The string pointed to by the argument <i>str</i> is converted to a floating-point number (type
|
||||
<code><b>double</b></code>). Any initial whitespace characters are skipped (space, tab, carriage return, new line,
|
||||
vertical tab, or formfeed). The number may consist of an optional sign, a string of digits with an
|
||||
optional decimal character, and an optional <code><b>e</b></code> or <code><b>E</b></code> followed by a optionally signed exponent.
|
||||
Conversion stops when the first unrecognized character is reached.
|
||||
<p>
|
||||
The argument <i>endptr</i> is a pointer to a pointer. The address of the character that stopped
|
||||
the scan is stored in the pointer that <i>endptr</i> points to.
|
||||
<p>
|
||||
On success the converted number is returned. If no conversion can be made, zero is
|
||||
returned. If the value is out of range of the type double, then <code><b>HUGE_VAL</b></code> is returned with the
|
||||
appropriate sign and <code><b>ERANGE</b></code> is stored in the variable <code><b>errno</b></code>. If the value is too small to be
|
||||
returned in the type <code><b>double</b></code>, then zero is returned and <code><b>ERANGE</b></code> is stored in the variable <code><b>errno</b></code>.
|
||||
|
||||
<a name="strtol"></a>
|
||||
<h2>2.13.2.5 strtol</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
long int strtol(const char *</b></code><i>str</i><code><b>, char **</b></code><i>endptr</i><code><b>, int </b></code><i>base</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
|
||||
The string pointed to by the argument <i>str</i> is converted to a long integer (type <code><b>long int</b></code>).
|
||||
Any initial whitespace characters are skipped (space, tab, carriage return, new line, vertical tab,
|
||||
or formfeed). The number may consist of an optional sign and a string of digits. Conversion
|
||||
stops when the first unrecognized character is reached.
|
||||
<p>
|
||||
If the <i>base</i> (radix) argument is zero, then the conversion is dependent on the first two
|
||||
characters. If the first character is a digit from 1 to 9, then it is base 10. If the first digit is a zero
|
||||
and the second digit is a digit from 1 to 7, then it is base 8 (octal). If the first digit is a zero and
|
||||
the second character is an x or X, then it is base 16 (hexadecimal).
|
||||
<p>
|
||||
If the <i>base</i> argument is from 2 to 36, then that base (radix) is used and any characters that
|
||||
fall outside of that base definition are considered unconvertible. For base 11 to 36, the
|
||||
characters A to Z (or a to z) are used. If the base is 16, then the characters 0x or 0X may precede
|
||||
the number.
|
||||
<p>
|
||||
The argument <i>endptr</i> is a pointer to a pointer. The address of the character that stopped
|
||||
the scan is stored in the pointer that <i>endptr</i> points to.
|
||||
<p>
|
||||
On success the converted number is returned. If no conversion can be made, zero is
|
||||
returned. If the value is out of the range of the type <code><b>long int</b></code>, then <code><b>LONG_MAX</b></code> or <code><b>LONG_MIN</b></code>
|
||||
is returned with the sign of the correct value and <code><b>ERANGE</b></code> is stored in the variable <code><b>errno</b></code>.
|
||||
|
||||
<a name="strtoul"></a>
|
||||
<h2>2.13.2.6 strtoul</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
unsigned long int strtoul(const char *</b></code><i>str</i><code><b>, char **</b></code><i>endptr</i><code><b>, int </b></code><i>base</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The string pointed to by the argument <i>str</i> is converted to an unsigned long integer (type
|
||||
<code><b>unsigned long int</b></code>). Any initial whitespace characters are skipped (space, tab, carriage return,
|
||||
new line, vertical tab, or formfeed). The number may consist of an optional sign and a string of
|
||||
digits. Conversion stops when the first unrecognized character is reached.
|
||||
<p>
|
||||
If the <i>base</i> (radix) argument is zero, then the conversion is dependent on the first two
|
||||
characters. If the first character is a digit from 1 to 9, then it is base 10. If the first digit is a zero
|
||||
and the second digit is a digit from 1 to 7, then it is base 8 (octal). If the first digit is a zero and
|
||||
the second character is an x or X, then it is base 16 (hexadecimal).
|
||||
<p>
|
||||
If the <i>base</i> argument is from 2 to 36, then that base (radix) is used and any characters that
|
||||
fall outside of that base definition are considered unconvertible. For base 11 to 36, the
|
||||
characters A to Z (or a to z) are used. If the <i>base</i> is 16, then the characters 0x or 0X may precede
|
||||
the number.
|
||||
<p>
|
||||
The argument <i>endptr</i> is a pointer to a pointer. The address of the character that stopped
|
||||
the scan is stored in the pointer that <i>endptr</i> points to.
|
||||
<p>
|
||||
On success the converted number is returned. If no conversion can be made, zero is
|
||||
returned. If the value is out of the range of the type <code><b>unsigned long int</b></code>, then <code><b>ULONG_MAX</b></code> is
|
||||
returned and <code><b>ERANGE</b></code> is stored in the variable <code><b>errno</b></code>.
|
||||
<h2> 2.13.3 Memory Functions</h2>
|
||||
<a name="calloc"></a>
|
||||
<h2>2.13.3.1 calloc</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *calloc(size_t </b></code><i>nitems</i><code><b>, size_t </b></code><i>size</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Allocates the requested memory and returns a pointer to it. The requested size is <i>nitems</i>
|
||||
each <i>size</i> bytes long (total memory requested is nitems*size). The space is initialized to all zero
|
||||
bits.
|
||||
<p>
|
||||
On success a pointer to the requested space is returned. On failure a null pointer is
|
||||
returned.
|
||||
|
||||
<a name="free"></a>
|
||||
<h2>2.13.3.2 free</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void free(void *</b></code><i>ptr</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Deallocates the memory previously allocated by a call to <code><b>calloc</b></code>, <code><b>malloc</b></code>, or <code><b>realloc</b></code>. The
|
||||
argument <i>ptr</i> points to the space that was previously allocated. If <i>ptr</i> points to a memory block
|
||||
that was not allocated with <code><b>calloc</b></code>, <code><b>malloc</b></code>, or <code><b>realloc</b></code>, or is a space that has been deallocated,
|
||||
then the result is undefined.
|
||||
<p>
|
||||
No value is returned.
|
||||
|
||||
<a name="malloc"></a>
|
||||
<h2>2.13.3.3 malloc</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *malloc(size_t </b></code><i>size</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Allocates the requested memory and returns a pointer to it. The requested size is <i>size</i>
|
||||
bytes. The value of the space is indeterminate.
|
||||
<p>
|
||||
On success a pointer to the requested space is returned. On failure a null pointer is
|
||||
returned.
|
||||
|
||||
<a name="realloc"></a>
|
||||
<h2>2.13.3.4 realloc</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *realloc(void *</b></code><i>ptr</i><code><b>, size_t </b></code><i>size</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Attempts to resize the memory block pointed to by <i>ptr</i> that was previously allocated with
|
||||
a call to <code><b>malloc</b></code> or <code><b>calloc</b></code>. The contents pointed to by <i>ptr</i> are unchanged. If the value of <i>size</i> is
|
||||
greater than the previous size of the block, then the additional bytes have an undeterminate
|
||||
value. If the value of <i>size</i> is less than the previous size of the block, then the difference of bytes
|
||||
at the end of the block are freed. If ptr is null, then it behaves like <code><b>malloc</b></code>. If <i>ptr</i> points to a
|
||||
memory block that was not allocated with <code><b>calloc</b></code> or <code><b>malloc</b></code>, or is a space that has been
|
||||
deallocated, then the result is undefined. If the new space cannot be allocated, then the contents
|
||||
pointed to by <i>ptr</i> are unchanged. If size is zero, then the memory block is completely freed.
|
||||
<p>
|
||||
On success a pointer to the memory block is returned (which may be in a different
|
||||
location as before). On failure or if size is zero, a null pointer is returned.
|
||||
<h2> 2.13.4 Environment Functions</h2>
|
||||
<a name="abort"></a>
|
||||
<h2>2.13.4.1 abort</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void abort(void);
|
||||
</b></code></blockquote>
|
||||
|
||||
Causes an abnormal program termination. Raises the <code><b>SIGABRT</b></code> signal and an
|
||||
unsuccessful termination status is returned to the environment. Whether or not open streams are
|
||||
closed is implementation-defined.
|
||||
<p>
|
||||
No return is possible.
|
||||
|
||||
<a name="atexit"></a>
|
||||
<h2>2.13.4.2 atexit</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int atexit(void (*</b></code><i>func</i><code><b>)(void));
|
||||
</b></code></blockquote>
|
||||
|
||||
Causes the specified function to be called when the program terminates normally. At
|
||||
least 32 functions can be registered to be called when the program terminates. They are called
|
||||
in a last-in, first-out basis (the last function registered is called first).
|
||||
<p>
|
||||
On success zero is returned. On failure a nonzero value is returned.
|
||||
|
||||
<a name="exit"></a>
|
||||
<h2>2.13.4.3 exit</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void exit(int </b></code><i>status</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Causes the program to terminate normally. First the functions registered by atexit are
|
||||
called, then all open streams are flushed and closed, and all temporary files opened with tmpfile
|
||||
are removed. The value of <i>status</i> is returned to the environment. If <i>status</i> is <code><b>EXIT_SUCCESS</b></code>,
|
||||
then this signifies a successful termination. If <i>status</i> is <code><b>EXIT_FAILURE</b></code>, then this signifies an
|
||||
unsuccessful termination. All other values are implementation-defined.
|
||||
<p>
|
||||
No return is possible.
|
||||
|
||||
<a name="getenv"></a>
|
||||
<h2>2.13.4.4 getenv</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *getenv(const char *</b></code><i>name</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Searches for the environment string pointed to by <i>name</i> and returns the associated value
|
||||
to the string. This returned value should not be written to.
|
||||
<p>
|
||||
If the string is found, then a pointer to the string's associated value is returned. If the
|
||||
string is not found, then a null pointer is returned.
|
||||
|
||||
<a name="system"></a>
|
||||
<h2>2.13.4.5 system</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int system(const char *</b></code><i>string</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The command specified by string is passed to the host environment to be executed by the
|
||||
command processor. A null pointer can be used to inquire whether or not the command
|
||||
processor exists.
|
||||
<p>
|
||||
If string is a null pointer and the command processor exists, then zero is returned. All
|
||||
other return values are implementation-defined.
|
||||
<h2> 2.13.5 Searching and Sorting Functions</h2>
|
||||
<a name="bsearch"></a>
|
||||
<h2>2.13.5.1 bsearch</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *bsearch(const void *</b></code><i>key</i><code><b>, const void *</b></code><i>base</i><code><b>, size_t </b></code><i>nitems</i><code><b>, size_t </b></code><i>size</i><code><b>, int
|
||||
(*</b></code><i>compar</i><code><b>)(const void *, const void *));
|
||||
</b></code></blockquote>
|
||||
|
||||
Performs a binary search. The beginning of the array is pointed to by <i>base</i>. It searches
|
||||
for an element equal to that pointed to by <i>key</i>. The array is <i>nitems</i> long with each element in the
|
||||
array <i>size</i> bytes long.
|
||||
<p>
|
||||
The method of comparing is specified by the <i>compar</i> function. This function takes two
|
||||
arguments, the first is the key pointer and the second is the current element in the array being
|
||||
compared. This function must return less than zero if the compared value is less than the
|
||||
specified key. It must return zero if the compared value is equal to the specified key. It must
|
||||
return greater than zero if the compared value is greater than the specified key.
|
||||
<p>
|
||||
The array must be arranged so that elements that compare less than key are first,
|
||||
elements that equal key are next, and elements that are greater than key are last.
|
||||
<p>
|
||||
If a match is found, a pointer to this match is returned. Otherwise a null pointer is
|
||||
returned. If multiple matching keys are found, which key is returned is unspecified.
|
||||
|
||||
<a name="qsort"></a>
|
||||
<h2>2.13.5.2 qsort</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void qsort(void *</b></code><i>base</i><code><b>, size_t </b></code><i>nitems</i><code><b>, size_t </b></code><i>size</i><code><b>, int (*</b></code><i>compar</i><code><b>)(const void *, const
|
||||
void*));
|
||||
</b></code></blockquote>
|
||||
|
||||
Sorts an array. The beginning of the array is pointed to by <i>base</i>. The array is <i>nitems</i> long
|
||||
with each element in the array <i>size</i> bytes long.
|
||||
<p>
|
||||
The elements are sorted in ascending order according to the <i>compar</i> function. This
|
||||
function takes two arguments. These arguments are two elements being compared. This
|
||||
function must return less than zero if the first argument is less than the second. It must return
|
||||
zero if the first argument is equal to the second. It must return greater than zero if the first
|
||||
argument is greater than the second.
|
||||
<p>
|
||||
If multiple elements are equal, the order they are sorted in the array is unspecified.
|
||||
<p>
|
||||
No value is returned.
|
||||
|
||||
<blockquote><code><b><pre>
|
||||
Example:
|
||||
|
||||
#include<stdlib.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char string_array[10][50]={"John",
|
||||
"Jane",
|
||||
"Mary",
|
||||
"Rogery",
|
||||
"Dave",
|
||||
"Paul",
|
||||
"Beavis",
|
||||
"Astro",
|
||||
"George",
|
||||
"Elroy"};
|
||||
|
||||
/* Sort the list */
|
||||
qsort(string_array,10,50,strcmp);
|
||||
|
||||
/* Search for the item "Elroy" and print it */
|
||||
printf("%s",bsearch("Elroy",string_array,10,50,strcmp));
|
||||
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<h2> 2.13.6 Math Functions</h2>
|
||||
<a name="abs"></a>
|
||||
<h2>2.13.6.1 abs</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int abs(int </b></code><i>x</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns the absolute value of <i>x</i>. Note that in two's compliment that the most maximum
|
||||
number cannot be represented as a positive number. The result in this case is undefined.
|
||||
<p>
|
||||
The absolute value is returned.
|
||||
|
||||
<a name="div"></a>
|
||||
<h2>2.13.6.2 div</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
div_t div(int </b></code><i>numer</i><code><b>, int </b></code><i>denom</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Divides <i>numer</i> (numerator) by <i>denom</i> (denominator). The result is stored in the structure
|
||||
<code><b>div_t</b></code> which has two members:
|
||||
<blockquote>
|
||||
<code><b> int qout;<br>
|
||||
int rem;</b></code>
|
||||
</blockquote>
|
||||
Where <i>quot</i> is the quotient and <i>rem</i> is the remainder. In the case of inexact division, <i>quot</i>
|
||||
is rounded down to the nearest integer. The value <i>numer</i> is equal to <code><b>quot * denom + rem</b></code>.
|
||||
<p>
|
||||
The value of the division is returned in the structure.
|
||||
|
||||
<a name="labs"></a>
|
||||
<h2>2.13.6.3 labs</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
long int labs(long int </b></code><i>x</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns the absolute value of <i>x</i>. Not that in two's compliment that the most maximum
|
||||
number cannot be represented as a positive number. The result in this case is undefined.
|
||||
<p>
|
||||
The absolute value is returned.
|
||||
|
||||
<a name="ldiv"></a>
|
||||
<h2>2.13.6.4 ldiv</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
ldiv_t ldiv(long int </b></code><i>numer</i><code><b>, long int </b></code><i>denom</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Divides <i>numer</i> (numerator) by <i>denom</i> (denominator). The result is stored in the structure
|
||||
<code><b>ldiv_t</b></code> which has two members:
|
||||
<blockquote>
|
||||
<code><b> long int qout;<br>
|
||||
long int rem;</b></code>
|
||||
</blockquote>
|
||||
Where <i>quot</i> is the quotient and <i>rem</i> is the remainder. In the case of inexact division, <i>quot</i>
|
||||
is rounded down to the nearest integer. The value <i>numer</i> is equal to <code><b>quot * denom + rem</b></code>.
|
||||
<p>
|
||||
The value of the division is returned in the structure.
|
||||
|
||||
<a name="rand"></a>
|
||||
<h2>2.13.6.5 rand</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int rand(void);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns a pseudo-random number in the range of <code><b>0</b></code> to <code><b>RAND_MAX</b></code>.
|
||||
<p>
|
||||
The random number is returned.
|
||||
|
||||
<a name="srand"></a>
|
||||
<h2>2.13.6.6 srand</h2>
|
||||
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void srand(unsigned int </b></code><i>seed</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
This function seeds the random number generator used by the function <code><b>rand</b></code>. Seeding
|
||||
<code><b>srand</b></code> with the same seed will cause <code><b>rand</b></code> to return the same sequence of pseudo-random
|
||||
numbers. If <code><b>srand</b></code> is not called, <code><b>rand</b></code> acts as if <code><b>srand(1)</b></code> has been called.
|
||||
<p>
|
||||
No value is returned.
|
||||
<h2> 2.13.7 Multibyte Functions</h2>
|
||||
|
||||
The behavior of the multibyte functions are affected by the setting of <code><b>LC_CTYPE</b></code> in the
|
||||
location settings.
|
||||
|
||||
<a name="mblen"></a>
|
||||
<h2>2.13.7.1 mblen</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int mblen(const char *</b></code><i>str</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns the length of a multibyte character pointed to by the argument <i>str</i>. At most <i>n</i>
|
||||
bytes will be examined.
|
||||
<p>
|
||||
If <i>str</i> is a null pointer, then zero is returned if multibyte characters are not
|
||||
state-dependent (shift state). Otherwise a nonzero value is returned if multibyte character are
|
||||
state-dependent.
|
||||
<p>
|
||||
If <i>str</i> is not null, then the number of bytes that are contained in the multibyte character
|
||||
pointed to by <i>str</i> are returned. Zero is returned if str points to a null character. A value of -1 is
|
||||
returned if <i>str</i> does not point to a valid multibyte character.
|
||||
|
||||
<a name="mbstowcs"></a>
|
||||
<h2>2.13.7.2 mbstowcs</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t mbstowcs(schar_t *</b></code><i>pwcs</i><code><b>, const char *</b></code><i>str</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Converts the string of multibyte characters pointed to by the argument <i>str</i> to the array
|
||||
pointed to by <i>pwcs</i>. It stores no more than <i>n</i> values into the array. Conversion stops when it
|
||||
reaches the null character or <i>n</i> values have been stored. The null character is stored in the array
|
||||
as zero but is not counted in the return value.
|
||||
<p>
|
||||
If an invalid multibyte character is reached, then the value -1 is returned. Otherwise the
|
||||
number of values stored in the array is returned not including the terminating zero character.
|
||||
|
||||
<a name="mbtowc"></a>
|
||||
<h2>2.13.7.3 mbtowc</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int mbtowc(whcar_t *</b></code><i>pwc</i><code><b>, const char *</b></code><i>str</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Examines the multibyte character pointed to by the argument <i>str</i>. The value is converted
|
||||
and stored in the argument <i>pwc</i> if <i>pwc</i> is not null. It scans at most <i>n</i> bytes.
|
||||
<p>
|
||||
If <i>str</i> is a null pointer, then zero is returned if multibyte characters are not
|
||||
state-dependent (shift state). Otherwise a nonzero value is returned if multibyte character are
|
||||
state-dependent.
|
||||
<p>
|
||||
If <i>str</i> is not null, then the number of bytes that are contained in the multibyte character
|
||||
pointed to by str are returned. Zero is returned if <i>str</i> points to a null character. A value of -1 is
|
||||
returned if <i>str</i> does not point to a valid multibyte character.
|
||||
|
||||
<a name="wcstombs"></a>
|
||||
<h2>2.13.7.4 wcstombs</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t wcstombs(char *</b></code><i>str</i><code><b>, const wchar_t *</b></code><i>pwcs</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Converts the codes stored in the array <i>pwcs</i> to multibyte characters and stores them in the
|
||||
string <i>str</i>. It copies at most <i>n</i> bytes to the string. If a multibyte character overflows the <i>n</i>
|
||||
constriction, then none of that multibyte character's bytes are copied. Conversion stops when it
|
||||
reaches the null character or <i>n</i> bytes have been written to the string. The null character is stored
|
||||
in the string, but is not counted in the return value.
|
||||
<p>
|
||||
If an invalid code is reached, the value -1 is returned. Otherwise the number of bytes
|
||||
stored in the string is returned not including the terminating null character.
|
||||
|
||||
<a name="wctomb"></a>
|
||||
<h2>2.13.7.5 wctomb</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int wctomb(char *</b></code><i>str</i><code><b>, wchar_t </b></code><i>wchar</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Examines the code which corresponds to a multibyte character given by the argument
|
||||
<i>wchar</i>. The code is converted to a multibyte character and stored into the string pointed to by
|
||||
the argument <i>str</i> if <i>str</i> is not null.
|
||||
<p>
|
||||
If <i>str</i> is a null pointer, then zero is returned if multibyte characters are not
|
||||
state-dependent (shift state). Otherwise a nonzero value is returned if multibyte character are
|
||||
state-dependent.
|
||||
<p>
|
||||
If <i>str</i> is not null, then the number of bytes that are contained in the multibyte character
|
||||
wchar are returned. A value of -1 is returned if wchar is not a valid multibyte character.
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.12.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.12 stdio.h</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="2.14.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.14 string.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
512
Ref-docs/c_lib_guide/2.14.html
Normal file
512
Ref-docs/c_lib_guide/2.14.html
Normal file
@@ -0,0 +1,512 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.14 string.h
|
||||
</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="2.13.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.13 stdlib.h</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="2.15.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.15 time.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.14 string.h</h2>
|
||||
<p>
|
||||
The string header provides many functions useful for manipulating strings (character
|
||||
arrays).
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
NULL
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
typedef size_t
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
memchr();<br>
|
||||
memcmp();<br>
|
||||
memcpy();<br>
|
||||
memmove();<br>
|
||||
memset();<br>
|
||||
strcat();<br>
|
||||
strncat();<br>
|
||||
strchr();<br>
|
||||
strcmp();<br>
|
||||
strncmp();<br>
|
||||
strcoll();<br>
|
||||
strcpy();<br>
|
||||
strncpy();<br>
|
||||
strcspn();<br>
|
||||
strerror();<br>
|
||||
strlen();<br>
|
||||
strpbrk();<br>
|
||||
strrchr();<br>
|
||||
strspn();<br>
|
||||
strstr();<br>
|
||||
strtok();<br>
|
||||
strxfrm();
|
||||
</b></code></blockquote>
|
||||
|
||||
<a name="variables"></a>
|
||||
<h2>2.14.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
<ode><b>size_t</b></code> is the unsigned integer result of the sizeof keyword.<br>
|
||||
<code><b>NULL</b></code> is the value of a null pointer constant.
|
||||
<a name="memchr"></a>
|
||||
<h2> 2.14.2 memchr</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *memchr(const void *</b></code><i>str</i><code><b>, int </b></code><i>c</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Searches for the first occurrence of the character <i>c</i> (an <code><b>unsigned char</b></code>) in the first <i>n</i> bytes
|
||||
of the string pointed to by the argument <i>str</i>.
|
||||
<p>
|
||||
Returns a pointer pointing to the first matching character, or null if no match was found.
|
||||
<a name="memcmp"></a>
|
||||
<h2>2.14.3 memcmp</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int memcmp(const void *</b></code><i>str1</i><code><b>, const void *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Compares the first <i>n</i> bytes of <i>str1</i> and <i>str2</i>. Does not stop comparing even after the null
|
||||
character (it always checks <i>n</i> characters).
|
||||
<p>
|
||||
Returns zero if the first <i>n</i> bytes of <i>str1</i> and <i>str2</i> are equal. Returns less than zero or
|
||||
greater than zero if <i>str1</i> is less than or greater than <i>str2</i> respectively.
|
||||
|
||||
<a name="memcpy"></a>
|
||||
<h2>2.14.4 memcpy</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *memcpy(void *</b></code><i>str1</i><code><b>, const void *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Copies n characters from <i>str2</i> to <i>str1</i>. If <i>str1</i> and <i>str2</i> overlap the behavior is undefined.
|
||||
<p>
|
||||
Returns the argument <i>str1</i>.
|
||||
|
||||
<a name="memmove"></a>
|
||||
<h2>2.14.5 memmove</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *memmove(void *</b></code><i>str1</i><code><b>, const void *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Copies <i>n</i> characters from <i>str2</i> to <i>str1</i>. If <i>str1</i> and <i>str2</i> overlap the information is first
|
||||
completely read from <i>str1</i> and then written to <i>str2</i> so that the characters are copied correctly.
|
||||
<p>
|
||||
Returns the argument <i>str1</i>.
|
||||
|
||||
<a name="memset"></a>
|
||||
<h2>2.14.6 memset</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
void *memset(void *</b></code><i>str</i><code><b>, int </b></code><i>c</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Copies the character <i>c</i> (an <code><b>unsigned char</b></code>) to the first <i>n</i> characters of the string pointed to
|
||||
by the argument <i>str</i>.
|
||||
<p>
|
||||
The argument <i>str</i> is returned.
|
||||
|
||||
<a name="strcat"></a>
|
||||
<h2>2.14.7 strcat</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strcat(char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Appends the string pointed to by <i>str2</i> to the end of the string pointed to by <i>str1</i>. The
|
||||
terminating null character of <i>str1</i> is overwritten. Copying stops once the terminating null
|
||||
character of <i>str2</i> is copied. If overlapping occurs, the result is undefined.
|
||||
<p>
|
||||
The argument <i>str1</i> is returned.
|
||||
|
||||
<a name="strncat"></a>
|
||||
<h2>2.14.8 strncat</h2>
|
||||
<p>
|
||||
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strncat(char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Appends the string pointed to by <i>str2</i> to the end of the string pointed to by <i>str1</i> up to <i>n</i>
|
||||
characters long. The terminating null character of <i>str1</i> is overwritten. Copying stops once <i>n</i>
|
||||
characters are copied or the terminating null character of <i>str2</i> is copied. A terminating null
|
||||
character is always appended to <i>str1</i>. If overlapping occurs, the result is undefined.
|
||||
<p>
|
||||
The argument <i>str1</i> is returned.
|
||||
|
||||
<a name="strchr"></a>
|
||||
<h2>2.14.9 strchr</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strchr(const char *</b></code><i>str</i><code><b>, int </b></code><i>c</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Searches for the first occurrence of the character <i>c</i> (an unsigned char) in the string
|
||||
pointed to by the argument <i>str</i>. The terminating null character is considered to be part of the
|
||||
string.
|
||||
<p>
|
||||
Returns a pointer pointing to the first matching character, or null if no match was found.
|
||||
|
||||
<a name="strcmp"></a>
|
||||
<h2>2.14.10 strcmp</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int strcmp(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Compares the string pointed to by <i>str1</i> to the string pointed to by <i>str2</i>.
|
||||
<p>
|
||||
Returns zero if <i>str1</i> and <i>str2</i> are equal. Returns less than zero or greater than zero if <i>str1</i>
|
||||
is less than or greater than <i>str2</i> respectively.
|
||||
|
||||
<a name="strncmp"></a>
|
||||
<h2>2.14.11 strncmp</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int strncmp(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Compares at most the first <i>n</i> bytes of <i>str1</i> and <i>str2</i>. Stops comparing after the null
|
||||
character.
|
||||
<p>
|
||||
Returns zero if the first <i>n</i> bytes (or null terminated length) of <i>str1</i> and <i>str2</i> are equal.
|
||||
Returns less than zero or greater than zero if <i>str1</i> is less than or greater than <i>str2</i> respectively.
|
||||
|
||||
<a name="strcoll"></a>
|
||||
<h2>2.14.12 strcoll</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int strcoll(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Compares string <i>str1</i> to <i>str2</i>. The result is dependent on the <code><b>LC_COLLATE</b></code> setting of the
|
||||
location.
|
||||
<p>
|
||||
Returns zero if <i>str1</i> and <i>str2</i> are equal. Returns less than zero or greater than zero if <i>str1</i>
|
||||
is less than or greater than <i>str2</i> respectively.
|
||||
|
||||
<a name="strcpy"></a>
|
||||
<h2>2.14.13 strcpy</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strcpy(char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Copies the string pointed to by <i>str2</i> to <i>str1</i>. Copies up to and including the null character
|
||||
of <i>str2</i>. If <i>str1</i> and <i>str2</i> overlap the behavior is undefined.
|
||||
<p>
|
||||
Returns the argument <i>str1</i>.
|
||||
|
||||
<a name="strncpy"></a>
|
||||
<h2>2.14.14 strncpy</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strncpy(char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Copies up to <i>n</i> characters from the string pointed to by <i>str2</i> to <i>str1</i>. Copying stops when
|
||||
<i>n</i> characters are copied or the terminating null character in <i>str2</i> is reached. If the null character
|
||||
is reached, the null characters are continually copied to <i>str1</i> until <i>n</i> characters have been copied.
|
||||
<p>
|
||||
Returns the argument <i>str1</i>.
|
||||
|
||||
<a name="strcspn"></a>
|
||||
<h2>2.14.15 strcspn</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t strcspn(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Finds the first sequence of characters in the string <i>str1</i> that does not contain any character
|
||||
specified in <i>str2</i>.
|
||||
<p>
|
||||
Returns the length of this first sequence of characters found that do not match with <i>str2</i>.
|
||||
|
||||
<a name="strerror"></a>
|
||||
<h2>2.14.16 strerror</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strerror(int </b></code><i>errnum</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Searches an internal array for the error number <i>errnum</i> and returns a pointer to an error
|
||||
message string.
|
||||
<p>
|
||||
Returns a pointer to an error message string.
|
||||
|
||||
<a name="strlen"></a>
|
||||
<h2>2.14.17 strlen</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t strlen(const char *</b></code><i>str</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Computes the length of the string <i>str</i> up to but not including the terminating null
|
||||
character.
|
||||
<p>
|
||||
Returns the number of characters in the string.
|
||||
|
||||
<a name="strpbrk"></a>
|
||||
<h2>2.14.18 strpbrk</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strpbrk(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Finds the first character in the string <i>str1</i> that matches any character specified in <i>str2</i>.
|
||||
<p>
|
||||
A pointer to the location of this character is returned. A null pointer is returned if no
|
||||
character in <i>str2</i> exists in <i>str1</i>.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char string[]="Hi there, Chip!";
|
||||
char *string_ptr;
|
||||
|
||||
while((string_ptr=strpbrk(string," "))!=NULL)
|
||||
*string_ptr='-';
|
||||
|
||||
printf("New string is \"%s\".\n",string);
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
|
||||
The output should result in every space in the string being converted to a dash (-).
|
||||
|
||||
<a name="strrchr"></a>
|
||||
<h2>2.14.19 strrchr</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strrchr(const char *</b></code><i>str</i><code><b>, int </b></code><i>c</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Searches for the last occurrence of the character <i>c</i> (an <code><b>unsigned char</b></code>) in the string
|
||||
pointed to by the argument <i>str</i>. The terminating null character is considered to be part of the
|
||||
string.
|
||||
<p>
|
||||
Returns a pointer pointing to the last matching character, or null if no match was found.
|
||||
|
||||
<a name="strspn"></a>
|
||||
<h2>2.14.20 strspn</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t strspn(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Finds the first sequence of characters in the string <i>str1</i> that contains any character
|
||||
specified in <i>str2</i>.
|
||||
<p>
|
||||
Returns the length of this first sequence of characters found that match with <i>str2</i>.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char string[]="7803 Elm St.";
|
||||
|
||||
printf("The number length is %d.\n",strspn(string,"1234567890"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
The output should be:
|
||||
The number length is 4.
|
||||
|
||||
<a name="strstr"></a>
|
||||
<h2>2.14.21 strstr</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strstr(const char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Finds the first occurrence of the entire string <i>str2</i> (not including the terminating null
|
||||
character) which appears in the string <i>str1</i>.
|
||||
<p>
|
||||
Returns a pointer to the first occurrence of <i>str2</i> in <i>str1</i>. If no match was found, then a
|
||||
null pointer is returned. If <i>str2</i> points to a string of zero length, then the argument <i>str1</i> is
|
||||
returned.
|
||||
|
||||
<a name="strtok"></a>
|
||||
<h2>2.14.22 strtok</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *strtok(char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Breaks string <i>str1</i> into a series of tokens. If <i>str1</i> and <i>str2</i> are not null, then the following
|
||||
search sequence begins. The first character in <i>str1</i> that does not occur in <i>str2</i> is found. If <i>str1</i>
|
||||
consists entirely of characters specified in <i>str2</i>, then no tokens exist and a null pointer is
|
||||
returned. If this character is found, then this marks the beginning of the first token. It then
|
||||
begins searching for the next character after that which is contained in <i>str2</i>. If this character is
|
||||
not found, then the current token extends to the end of <i>str1</i>. If the character is found, then it is
|
||||
overwritten by a null character, which terminates the current token. The function then saves the
|
||||
following position internally and returns.
|
||||
<p>
|
||||
Subsequent calls with a null pointer for <i>str1</i> will cause the previous position saved to be
|
||||
restored and begins searching from that point. Subsequent calls may use a different value for
|
||||
<i>str2</i> each time.
|
||||
<p>
|
||||
Returns a pointer to the first token in <i>str1</i>. If no token is found then a null pointer is
|
||||
returned.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<string.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char search_string[]="Woody Norm Cliff";
|
||||
char *array[50];
|
||||
int loop;
|
||||
|
||||
array[0]=strtok(search_string," ");
|
||||
if(array[0]==NULL)
|
||||
{
|
||||
printf("No test to search.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for(loop=1;loop<50;loop++)
|
||||
{
|
||||
array[loop]=strtok(NULL," ");
|
||||
if(array[loop]==NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
for(loop=0;loop<50;loop++)
|
||||
{
|
||||
if(array[loop]==NULL)
|
||||
break;
|
||||
printf("Item #%d is %s.\n",loop,array[loop]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
This program replaces each space into a null character and stores a pointer to each substring into
|
||||
the array. It then prints out each item.
|
||||
|
||||
|
||||
<a name="strxfrm"></a>
|
||||
<h2>2.14.23 strxfrm</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t strxfrm(char *</b></code><i>str1</i><code><b>, const char *</b></code><i>str2</i><code><b>, size_t </b></code><i>n</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Transforms the string <i>str2</i> and places the result into <i>str1</i>. It copies at most <i>n</i> characters
|
||||
into <i>str1</i> including the null terminating character. The transformation occurs such that <code><b>strcmp</b></code>
|
||||
applied to two separate converted strings returns the same value as <code><b>strcoll</b></code> applied to the same
|
||||
two strings. If overlapping occurs, the result is undefined.
|
||||
<p>
|
||||
Returns the length of the transformed string (not including the null character).
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.13.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.13 stdlib.h</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="2.15.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.15 time.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
392
Ref-docs/c_lib_guide/2.15.html
Normal file
392
Ref-docs/c_lib_guide/2.15.html
Normal file
@@ -0,0 +1,392 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.15 time.h
|
||||
</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="2.14.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.14 string.h</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="index2.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
Index</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.15 time.h</h1>
|
||||
<p>
|
||||
|
||||
The time header provides several functions useful for reading and converting the current
|
||||
time and date. Some functions behavior is defined by the <code><b>LC_TIME</b></code> category of the location
|
||||
setting.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
NULL<br>
|
||||
CLOCKS_PER_SEC
|
||||
</b></code></blockquote>
|
||||
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
typedef size_t<br>
|
||||
typedef clock_t<br>
|
||||
typedef size_t<br>
|
||||
struct tm
|
||||
</b></code></blockquote>
|
||||
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
asctime();<br>
|
||||
clock();<br>
|
||||
ctime();<br>
|
||||
difftime();<br>
|
||||
gmtime();<br>
|
||||
localtime();<br>
|
||||
mktime();<br>
|
||||
strftime(); <br>
|
||||
time();
|
||||
</b></code></blockquote>
|
||||
|
||||
<a name="variables"></a>
|
||||
<h2>2.15.1 Variables and Definitions</h2>
|
||||
<blockquote>
|
||||
<code><b>NULL</b></code> is the value of a null pointer constant.<br>
|
||||
<code><b>CLOCKS_PER_SEC</b></code> is the number of processor clocks per second.<br>
|
||||
<p>
|
||||
<code><b>size_t</b></code> is the unsigned integer result of the sizeof keyword.<br>
|
||||
<code><b>clock_t</b></code> is a type suitable for storing the processor time.<br>
|
||||
<code><b>time_t</b></code> is a type suitable for storing the calendar time.<br>
|
||||
<p>
|
||||
<code><b>struct tm</b></code> is a structure used to hold the time and date. Its members are as follows:
|
||||
<code><b><pre>
|
||||
int tm_sec; /* seconds after the minute (0 to 61) */
|
||||
int tm_min; /* minutes after the hour (0 to 59) */
|
||||
int tm_hour; /* hours since midnight (0 to 23) */
|
||||
int tm_mday; /* day of the month (1 to 31) */
|
||||
int tm_mon; /* months since January (0 to 11) */
|
||||
int tm_year; /* years since 1900 */
|
||||
int tm_wday; /* days since Sunday (0 to 6 Sunday=0) */
|
||||
int tm_yday; /* days since January 1 (0 to 365) */
|
||||
int tm_isdst; /* Daylight Savings Time */
|
||||
</pre></b></code>
|
||||
</blockquote>
|
||||
<p>
|
||||
If <code><b>tm_isdst</b></code> is zero, then Daylight Savings Time is not in effect. If it is a positive value,
|
||||
then Daylight Savings Time is in effect. If it is negative, then the function using it is requested
|
||||
to attempt to calculate whether or not Daylight Savings Time is in effect for the given time.
|
||||
<p>
|
||||
Note that <code><b>tm_sec</b></code> may go as high as 61 to allow for up to two leap seconds.
|
||||
|
||||
<a name="asctime"></a>
|
||||
<h2> 2.15.2 asctime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *asctime(const struct tm *</b></code><i>timeptr</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
Returns a pointer to a string which represents the day and time of the structure <i>timeptr</i>.
|
||||
The string is in the following format:
|
||||
<blockquote><code><b>
|
||||
DDD MMM dd hh:mm:ss YYYY
|
||||
</b></code></blockquote>
|
||||
<table border=0>
|
||||
<tr><td><code><b>DDD</b></code></td><td> Day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat)</td></tr>
|
||||
<tr><td><code><b>MMM</b></code></td><td> Month of the year (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)</td></tr>
|
||||
<tr><td><code><b>dd</b></code></td><td> Day of the month (1,...,31)</td></tr>
|
||||
<tr><td><code><b>hh</b></code></td><td> Hour (0,...,23)</td></tr>
|
||||
<tr><td><code><b>mm </b></code></td><td> Minute (0,...,59)</td></tr>
|
||||
<tr><td><code><b>ss</b></code></td><td> Second (0,...,59)</td></tr>
|
||||
<tr><td><code><b>YYYY</b></code></td><td> Year</td></tr>
|
||||
</table>
|
||||
The string is terminated with a newline character and a null character. The string is
|
||||
always 26 characters long (including the terminating newline and null characters).
|
||||
<p>
|
||||
A pointer to the string is returned.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<time.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
time_t timer;
|
||||
|
||||
timer=time(NULL);
|
||||
printf("The current time is %s.\n",asctime(localtime(&timer)));
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<a name="clock"></a>
|
||||
<h2>2.15.3 clock</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
clock_t clock(void);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns the processor clock time used since the beginning of an implementation-defined
|
||||
era (normally the beginning of the program). The returned value divided by
|
||||
<code><b>CLOCKS_PER_SEC</b></code> results in the number of seconds. If the value is unavailable, then -1 is
|
||||
returned.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<time.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
clock_t ticks1, ticks2;
|
||||
|
||||
ticks1=clock();
|
||||
ticks2=ticks1;
|
||||
while((ticks2/CLOCKS_PER_SEC-ticks1/CLOCKS_PER_SEC)<1)
|
||||
ticks2=clock();
|
||||
|
||||
printf("Took %ld ticks to wait one second.\n",ticks2-ticks1);
|
||||
printf("This value should be the same as CLOCKS_PER_SEC which is %ld.\n",CLOCKS_PER_SEC);
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<a name="ctime"></a>
|
||||
<h2>2.15.4 ctime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *ctime(const time_t *</b></code><i>timer</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Returns a string representing the localtime based on the argument <i>timer</i>. This is
|
||||
equivalent to:
|
||||
<blockquote><code><b>
|
||||
asctime(locatime(timer));
|
||||
</b></code></blockquote>
|
||||
The returned string is in the following format:
|
||||
<blockquote><code><b>
|
||||
DDD MMM dd hh:mm:ss YYYY
|
||||
</b></code></blockquote>
|
||||
<table border=0>
|
||||
<tr><td><code><b>DDD</b></code></td><td> Day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat)</td></tr>
|
||||
<tr><td><code><b>MMM</b></code></td><td> Month of the year (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec)</td></tr>
|
||||
<tr><td><code><b>dd</b></code></td><td> Day of the month (1,...,31)</td></tr>
|
||||
<tr><td><code><b>hh</b></code></td><td> Hour (0,...,23)</td></tr>
|
||||
<tr><td><code><b>mm</b></code></td><td> Minute (0,...,59)</td></tr>
|
||||
<tr><td><code><b>ss</b></code></td><td> Second (0,...,59)</td></tr>
|
||||
<tr><td><code><b>YYYY</b></code></td><td> Year</td></tr>
|
||||
</table>
|
||||
The string is terminated with a newline character and a null character. The string is
|
||||
always 26 characters long (including the terminating newline and null characters).
|
||||
<p>
|
||||
A pointer to the string is returned.
|
||||
|
||||
<a name="difftime"></a>
|
||||
<h2>2.15.5 difftime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
double difftime(time_t </b></code><i>time1</i><code><b>, time_t </b></code><i>time2</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Calculates the difference of seconds between <i>time1</i> and <i>time2</i> (time1-time2).
|
||||
<p>
|
||||
Returns the number of seconds.
|
||||
|
||||
<a name="gmtime"></a>
|
||||
<h2>2.15.6 gmtime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
struct tm *gmtime(const time_t *</b></code><i>timer);
|
||||
</b></code></blockquote>
|
||||
|
||||
The value of timer is broken up into the structure <code><b>tm</b></code> and expressed in Coordinated
|
||||
Universal Time (UTC) also known as Greenwich Mean Time (GMT).
|
||||
<p>
|
||||
A pointer to the structure is returned. A null pointer is returned if UTC is not available.
|
||||
|
||||
<a name="localtime"></a>
|
||||
<h2>2.15.7 localtime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
struct tm *localtime(const time_t *</b></code><i>timer</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
The value of timer is broken up into the structure <code><b>tm</b></code> and expressed in the local time
|
||||
zone.
|
||||
<p>
|
||||
A pointer to the structure is returned.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<time.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
time_t timer;
|
||||
|
||||
timer=time(NULL);
|
||||
printf("The current time is %s.\n",asctime(localtime(&timer)));
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<a name="mktime"></a>
|
||||
<h2>2.15.8 mktime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
time_t mktime(struct tm *</b></code><i>timeptr</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Converts the structure pointed to by <i>timeptr</i> into a <code><b>time_t</b></code> value according to the local
|
||||
time zone. The values in the structure are not limited to their constraints. If they exceed their
|
||||
bounds, then they are adjusted accordingly so that they fit within their bounds. The original
|
||||
values of <code><b>tm_wday</b></code> (day of the week) and <code><b>tm_yday</b></code> (day of the year) are ignored, but are set
|
||||
correctly after the other values have been constrained. <code><b>tm_mday</b></code> (day of the month) is not
|
||||
corrected until after <code><b>tm_mon</b></code> and <code><b>tm_year</b></code> are corrected.
|
||||
<p>
|
||||
After adjustment the structure still represents the same time.
|
||||
<p>
|
||||
The encoded <code><b>time_t</b></code> value is returned. If the calendar time cannot be represented, then -1
|
||||
is returned.
|
||||
<p>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<time.h>
|
||||
#include<stdio.h>
|
||||
|
||||
/* find out what day of the week is January 1, 2001
|
||||
(first day of the 21st century) */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
struct tm time_struct;
|
||||
char days[7][4]={"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
|
||||
time_struct.tm_year=2001-1900;
|
||||
time_struct.tm_mon=0;
|
||||
time_struct.tm_mday=1;
|
||||
time_struct.tm_sec=0;
|
||||
time_struct.tm_min=0;
|
||||
time_struct.tm_hour=0;
|
||||
time_struct.tm_isdst=-1;
|
||||
|
||||
if(mktime(&time_struct)==-1)
|
||||
{
|
||||
printf("Error getting time.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("January 1, 2001 is a %s.\n",days[time_struct.tm_wday]);
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<a name="strftime"></a>
|
||||
<h2>2.15.9 strftime</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
size_t strftime(char *</b></code><i>str</i><code><b>, size_t </b></code><i>maxsize</i><code><b>, const char *</b></code><i>format</i><code><b>, const struct tm *</b></code><i>timeptr</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Formats the time represented in the structure <i>timeptr</i> according to the formatting rules
|
||||
defined in <i>format</i> and stored into <i>str</i>. No more than <i>maxsize</i> characters are stored into <i>str</i>
|
||||
(including the terminating null character).
|
||||
<p>
|
||||
All characters in the <i>format</i> string are copied to the <i>str</i> string, including the terminating
|
||||
null character, except for conversion characters. A conversion character begins with the <code><b>%</b></code> sign
|
||||
and is followed by another character which defines a special value that it is to be replaced by.
|
||||
<table border=0>
|
||||
<tr><td><b>Conversion<br>Character</b></td><td><b> What it is replaced by</b></td></tr>
|
||||
<tr><td><code><b>%a</b></code></td><td> abbreviated weekday name</td></tr>
|
||||
<tr><td><code><b>%A</b></code></td><td> full weekday name</td></tr>
|
||||
<tr><td><code><b>%b</b></code></td><td> abbreviated month name</td></tr>
|
||||
<tr><td><code><b>%B</b></code></td><td> full month name</td></tr>
|
||||
<tr><td><code><b>%c</b></code></td><td> appropriate date and time representation</td></tr>
|
||||
<tr><td><code><b>%d</b></code></td><td> day of the month (01-31)</td></tr>
|
||||
<tr><td><code><b>%H</b></code></td><td> hour of the day (00-23)</td></tr>
|
||||
<tr><td><code><b>%I</b></code></td><td> hour of the day (01-12)</td></tr>
|
||||
<tr><td><code><b>%j</b></code></td><td> day of the year (001-366)</td></tr>
|
||||
<tr><td><code><b>%m</b></code></td><td> month of the year (01-12)</td></tr>
|
||||
<tr><td><code><b>%M</b></code></td><td> minute of the hour (00-59)</td></tr>
|
||||
<tr><td><code><b>%p</b></code></td><td> AM/PM designator</td></tr>
|
||||
<tr><td><code><b>%S</b></code></td><td> second of the minute (00-61)</td></tr>
|
||||
<tr><td><code><b>%U</b></code></td><td> week number of the year where Sunday is the first day of week 1 (00-53)</td></tr>
|
||||
<tr><td><code><b>%w</b></code></td><td> weekday where Sunday is day 0 (0-6)</td></tr>
|
||||
<tr><td><code><b>%W</b></code></td><td> week number of the year where Monday is the first day of week 1 (00-53)</td></tr>
|
||||
<tr><td><code><b>%x</b></code></td><td> appropriate date representation</td></tr>
|
||||
<tr><td><code><b>%X</b></code></td><td> appropriate time representation</td></tr>
|
||||
<tr><td><code><b>%y</b></code></td><td> year without century (00-99)</td></tr>
|
||||
<tr><td><code><b>%Y</b></code></td><td> year with century</td></tr>
|
||||
<tr><td><code><b>%Z</b></code></td><td> time zone (possibly abbreviated) or no characters if time zone isunavailable</td></tr>
|
||||
<tr><td><code><b>%%</b></code></td><td> %</td></tr>
|
||||
</table>
|
||||
Returns the number of characters stored into str not including the terminating null
|
||||
character. On error zero is returned.
|
||||
|
||||
<a name="time"></a>
|
||||
<h2>2.15.10 time</h2>
|
||||
<p>
|
||||
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
time_t time(time_t *</b></code><i>timer</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
|
||||
Calculates the current calender time and encodes it into <code><b>time_t</b></code> format.
|
||||
<p>
|
||||
The <code><b>time_t</b></code> value is returned. If <i>timer</i> is not a null pointer, then the value is also stored
|
||||
into the object it points to. If the time is unavailable, then -1 is returned.
|
||||
<hr>
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.14.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.14 string.h</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="index2.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
Index</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
189
Ref-docs/c_lib_guide/2.2.html
Normal file
189
Ref-docs/c_lib_guide/2.2.html
Normal file
@@ -0,0 +1,189 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.2 ctype.h
|
||||
</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="2.1.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.1 assert.h</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="2.3.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.3 errno.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
<h1>2.2 ctype.h</h1>
|
||||
<p>
|
||||
The ctype header is used for testing and converting characters. A control character refers
|
||||
to a character that is not part of the normal printing set. In the ASCII character set, the control
|
||||
characters are the characters from 0 (NUL) through 0x1F (US), and the character 0x7F (DEL).
|
||||
Printable characters are those from 0x20 (space) to 0x7E (tilde).
|
||||
<p>
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
isalnum();<br>
|
||||
isalpha();<br>
|
||||
iscntrl();<br>
|
||||
isdigit();<br>
|
||||
isgraph();<br>
|
||||
islower();<br>
|
||||
isprint();<br>
|
||||
ispunct();<br>
|
||||
isspace();<br>
|
||||
isupper();<br>
|
||||
isxdigit();<br>
|
||||
tolower();<br>
|
||||
toupper();<br>
|
||||
</b></code></blockquote>
|
||||
|
||||
<a name="is"></a>
|
||||
<h2>2.2.1 is... Functions</h2>
|
||||
<p>
|
||||
Declarations:
|
||||
<blockquote><code><b>
|
||||
int isalnum(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isalpha(int</b></code> <i>character</i><code><b>);<br>
|
||||
int iscntrl(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isdigit(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isgraph(int</b></code> <i>character</i><code><b>);<br>
|
||||
int islower(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isprint(int</b></code> <i>character</i><code><b>);<br>
|
||||
int ispunct(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isspace(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isupper(int</b></code> <i>character</i><code><b>);<br>
|
||||
int isxdigit(int</b></code><i> character</i><code><b>);<br>
|
||||
</b></code></blockquote>
|
||||
The is... functions test the given character and return a nonzero (true) result if it satisfies
|
||||
the following conditions. If not, then 0 (false) is returned.
|
||||
<p>
|
||||
Conditions:
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td valign=top><code><b>isalnum</b></code></td>
|
||||
<td>a letter (A to Z or a to z) or a digit (0 to 9)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isalpha</b></code></td>
|
||||
<td valign=top>a letter (A to Z or a to z)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>iscntrl</b></code></td>
|
||||
<td valign=top>any control character (0x00 to 0x1F or 0x7F)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isdigit</b></code></td>
|
||||
<td valign=top>a digit (0 to 9)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isgraph</b></code></td>
|
||||
<td valign=top>any printing character except for the space character (0x21 to 0x7E)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>islower</b></code></td>
|
||||
<td valign=top>a lowercase letter (a to z)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isprint</b></code></td>
|
||||
<td valign=top>any printing character (0x20 to 0x7E)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>ispunct</b></code></td>
|
||||
<td valign=top>any punctuation character (any printing character except for space
|
||||
character or isalnum)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isspace</b></code></td>
|
||||
<td valign=top>a whitespace character (space, tab, carriage return, new line, vertical tab,
|
||||
or formfeed)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isupper</b></code></td>
|
||||
<td valign=top>an uppercase letter (A to Z)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>isxdigit</b></code></td>
|
||||
<td valign=top>a hexadecimal digit (0 to 9, A to F, or a to f)</td>
|
||||
</tr>
|
||||
</table>
|
||||
<a name="to"></a>
|
||||
<h2>2.2.2 to... Functions</h2>
|
||||
<p>
|
||||
Declarations:
|
||||
<blockquote><code><b>
|
||||
int tolower(int </b></code><i>character</i><code><b>);<br>
|
||||
int toupper(int </b></code><i>character</i><code><b>);<br>
|
||||
</b></code></blockquote>
|
||||
The to... functions provide a means to convert a single character. If the character
|
||||
matches the appropriate condition, then it is converted. Otherwise the character is returned
|
||||
unchanged.
|
||||
<p>
|
||||
Conditions:
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td valign=top><code><b>tolower</b></code></td>
|
||||
<td valign=top>If the character is an uppercase character (A to Z), then it is converted to
|
||||
lowercase (a to z)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign=top><code><b>toupper</b></code></td>
|
||||
<td valign=top>If the character is a lowercase character (a to z), then it is converted to
|
||||
uppercase (A to Z)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<ctype.h>
|
||||
#include<stdio.h>
|
||||
#include<string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int loop;
|
||||
char string[]="THIS IS A TEST";
|
||||
|
||||
for(loop=0;loop<strlen(string);loop++)
|
||||
string[loop]=tolower(string[loop]);
|
||||
|
||||
printf("%s\n",string);
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<hr>
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.1.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.1 assert.h</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="2.3.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.3 errno.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
97
Ref-docs/c_lib_guide/2.3.html
Normal file
97
Ref-docs/c_lib_guide/2.3.html
Normal file
@@ -0,0 +1,97 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.3 errno.h
|
||||
</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="2.2.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.2 ctype.h</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="2.4.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.4 float.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
<h1>2.3 errno.h</h1>
|
||||
<p>
|
||||
The errno header is used as a general error handler.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
EDOM<br>
|
||||
ERANGE<br>
|
||||
</b></code></blockquote>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
errno
|
||||
</b></code></blockquote>
|
||||
<a name="edom"></a>
|
||||
<h2>2.3.1 EDOM</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
#define EDOM</b></code> <i>some_value</i>
|
||||
</blockquote>
|
||||
<code><b>EDOM</b></code> is an identifier macro declared with <code><b>#define</b></code>. Its value represents a domain error
|
||||
which is returned by some math functions when a domain error occurs.
|
||||
<p>
|
||||
|
||||
<a name="erange"></a>
|
||||
<h2>2.3.2 ERANGE</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
#define ERANGE</b></code> <i>some_value</i>
|
||||
</blockquote>
|
||||
<code><b>ERANGE</b></code> is an identifier macro declared with <code><b>#define</b></code>. Its value represents a range error
|
||||
which is returned by some math functions when a range error occurs.
|
||||
<p>
|
||||
<a name="errno"></a>
|
||||
<h2>2.3.3 errno</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
int errno;
|
||||
</b></code></blockquote>
|
||||
The <code><b>errno</b></code> variable has a value of zero at the beginning of the program. If an error
|
||||
occurs, then this variable is given the value of the error number.
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.2.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.2 ctype.h</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="2.4.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.4 float.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
219
Ref-docs/c_lib_guide/2.4.html
Normal file
219
Ref-docs/c_lib_guide/2.4.html
Normal file
@@ -0,0 +1,219 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.4 float.h
|
||||
</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="2.3.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.3 errno.h</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="2.5.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.5 limits.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1>2.4 float.h</h1>
|
||||
<p>
|
||||
The float header defines the minimum and maximum limits of floating-point number
|
||||
values.
|
||||
<p>
|
||||
<h2>2.4.1 Defined Values</h2>
|
||||
<p>
|
||||
A floating-point number is defined in the following manner:
|
||||
<blockquote>
|
||||
<i>sign value </i>E<i> exponent</i>
|
||||
</blockquote>
|
||||
Where <i>sign</i> is plus or minus, <i>value</i> is the value of the number, and <i>exponent</i> is the value
|
||||
of the exponent.
|
||||
<p>
|
||||
The following values are defined with the <code><b>#define</b></code> directive. These values are
|
||||
implementation-specific, but may not be any lower than what is given here. Note that in all
|
||||
instances <code><b>FLT</b></code> refers to type float, <code><b>DBL</b></code> refers to double, and <code><b>LDBL</b></code> refers to long double.
|
||||
<p>
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>FLT_ROUNDS</b></code><br>
|
||||
</td>
|
||||
<td>
|
||||
Defines the way floating-point numbers are rounded.<br>
|
||||
<br>
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td><code><b>-1</b></code></td><td> indeterminable</td></tr>
|
||||
<tr>
|
||||
<td><code><b>0</b></code></td><td> toward zero</td></tr>
|
||||
<tr>
|
||||
<td><code><b>1</b></code></td><td> to nearest</td></tr>
|
||||
<tr>
|
||||
<td><code><b>2</b></code></td><td> toward positive infinity</td></tr>
|
||||
<tr>
|
||||
<td><code><b>3</b></code></td><td> toward negative infinity</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>FLT_RADIX 2</b></code><br>
|
||||
</td>
|
||||
<td>
|
||||
Defines the base (radix) representation of the exponent (i.e. base-2 is binary, base-10 is
|
||||
the normal decimal representation, base-16 is Hex).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
FLT_MANT_DIG<br>
|
||||
DBL_MANT_DIG<br>
|
||||
LDBL_MANT_DIG<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Defines the number of digits in the number (in the <code><b>FLT_RADIX</b></code> base).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
FLT_DIG 6<br>
|
||||
DBL_DIG 10<br>
|
||||
LDBL_DIG 10<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
The maximum number decimal digits (base-10) that can be represented without change
|
||||
after rounding.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
FLT_MIN_EXP<br>
|
||||
DBL_MIN_EXP<br>
|
||||
LDBL_MIN_EXP<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
The minimum negative integer value for an exponent in base FLT_RADIX.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
|
||||
FLT_MIN_10_EXP -37<br>
|
||||
DBL_MIN_10_EXP -37<br>
|
||||
LDBL_MIN_10_EXP -37<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
The minimum negative integer value for an exponent in base 10.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
|
||||
FLT_MAX_EXP<br>
|
||||
DBL_MAX_EXP<br>
|
||||
LDBL_MAX_EXP<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
The maximum integer value for an exponent in base FLT_RADIX.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
|
||||
FLT_MAX_10_EXP +37<br>
|
||||
DBL_MAX_10_EXP +37<br>
|
||||
LDBL_MAX_10_EXP +37<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
The maximum integer value for an exponent in base 10.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
|
||||
FLT_MAX 1E+37<br>
|
||||
DBL_MAX 1E+37<br>
|
||||
LDBL_MAX 1E+37<br>
|
||||
</b></code>
|
||||
</td><td>
|
||||
Maximum finite floating-point value.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
|
||||
FLT_EPSILON 1E-5<br>
|
||||
DBL_EPSILON 1E-9<br>
|
||||
LDBL_EPSILON 1E-9<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Least significant digit representable.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>
|
||||
|
||||
FLT_MIN 1E-37<br>
|
||||
DBL_MIN 1E-37<br>
|
||||
LDBL_MIN 1E-37<br>
|
||||
</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Minimum floating-point value.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.3.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.3 errno.h</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="2.5.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.5 limits.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
189
Ref-docs/c_lib_guide/2.5.html
Normal file
189
Ref-docs/c_lib_guide/2.5.html
Normal file
@@ -0,0 +1,189 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.5 limits.h
|
||||
</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="2.4.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.4 float.h</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="2.6.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.6 locale.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.5 limits.h</h1>
|
||||
<p>
|
||||
The limits header defines the characteristics of variable types.
|
||||
<p>
|
||||
<h2>2.5.1 Defined Values</h2>
|
||||
<p>
|
||||
The following values are defined with the <code><b>#define</b></code> directive. These values are
|
||||
implementation-specific, but may not be any lower than what is given here.
|
||||
<table border=1>
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<code><b>CHAR_BIT 8</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Number of bits in a byte.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>SCHAR_MIN -127</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Minimum value for a signed char.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>SCHAR_MAX +127</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for a signed char.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>UCHAR_MAX 255</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for an unsigned char.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>CHAR_MIN<br>
|
||||
CHAR_MAX</b></code>
|
||||
</td>
|
||||
<td>
|
||||
These define the minimum and maximum values for a char. If a char is being
|
||||
represented as a signed integer, then their values are the same as the signed char (<code><b>SCHAR</b></code>)
|
||||
values. Otherwise <code><b>CHAR_MIN</b></code> is 0 and <code><b>CHAR_MAX</b></code> is the same as <code><b>UCHAR_MAX</b></code>.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>MB_LEN_MAX 1</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum number of bytes in a multibyte character.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>SHRT_MIN -32767</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Minimum value for a short int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>SHRT_MAX +32767</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for a short int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>USHRT_MAX 65535</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for an unsigned short int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>INT_MIN -32767</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Minimum value for an int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>INT_MAX +32767</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for an int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>UINT_MAX 65535</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for an unsigned int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>LONG_MIN -2147483647</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Minimum value for a long int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>LONG_MAX +2147483647</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for a long int.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code><b>ULONG_MAX 4294967295</b></code>
|
||||
</td>
|
||||
<td>
|
||||
Maximum value for an unsigned long int.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.4.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.4 float.h</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="2.6.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.6 locale.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
285
Ref-docs/c_lib_guide/2.6.html
Normal file
285
Ref-docs/c_lib_guide/2.6.html
Normal file
@@ -0,0 +1,285 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.6 locale.h
|
||||
</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="2.5.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.5 limits.h</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="2.7.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.7 math.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1>2.6 locale.h</h1>
|
||||
<p>
|
||||
The locale header is useful for setting location specific information.
|
||||
<p>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
struct lconv
|
||||
</b></code></blockquote>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
NULL<br>
|
||||
LC_ALL<br>
|
||||
LC_COLLATE<br>
|
||||
LC_CTYPE<br>
|
||||
LC_MONETARY<br>
|
||||
LC_NUMERIC<br>
|
||||
LC_TIME<br>
|
||||
</b></code></blockquote>
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
localeconv();<br>
|
||||
setlocale();<br>
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
<a name="variables"></a>
|
||||
<h2>2.6.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
The <code><b>lconv</b></code> structure contains the following variables in any order. The use of this
|
||||
structure is described in <b>2.6.3 localeconv</b>.
|
||||
<blockquote><code><b>
|
||||
char *decimal_point;<br>
|
||||
char *thousands_sep;<br>
|
||||
char *grouping;<br>
|
||||
char *int_curr_symbol;<br>
|
||||
char *currency_symbol;<br>
|
||||
char *mon_decimal_point;<br>
|
||||
char *mon_thousands_sep;<br>
|
||||
char *mon_grouping;<br>
|
||||
char *positive_sign;<br>
|
||||
char *negative_sign;<br>
|
||||
char int_frac_digits;<br>
|
||||
char frac_digits;<br>
|
||||
char p_cs_precedes;<br>
|
||||
char p_sep_by_space;<br>
|
||||
char n_cs_precedes;<br>
|
||||
char n_sep_by_space;<br>
|
||||
char p_sign_posn;<br>
|
||||
char n_sign_posn;<br>
|
||||
</b></code></blockquote>
|
||||
The <b><code>LC_</code></b> macros are described in <b>2.6.2 setlocale</b>.
|
||||
<b><code>NULL</code></b> is the value of a null pointer constant.
|
||||
<p>
|
||||
<a name="setlocale"></a>
|
||||
<h2>2.6.2 setlocale</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
char *setlocale(int</b></code> <i>category</i><code><b>, const char *</b></code><i>locale</i><code><b>);
|
||||
</b></code></blockquote>
|
||||
Sets or reads location dependent information.
|
||||
<p>
|
||||
<i>category</i> can be one of the following:
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td><code><b>LC_ALL</b></code></td><td> Set everything.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>LC_COLLATE</b></code></td><td> Affects strcoll and strxfrm functions.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>LC_CTYPE</b></code></td><td> Affects all character functions.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>LC_MONETARY</b></code></td><td> Affects the monetary information provided by localeconv function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>LC_NUMERIC</b></code></td><td> Affects decimal-point formatting and the information provided by
|
||||
<code><b>localeconv</b></code> function.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><b>LC_TIME</b></code></td><td> Affects the strftime function.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
A value of "C" for locale sets the locale to the normal C translation environment settings
|
||||
(default). A null value ("") sets the native environment settings. A null pointer (NULL) causes
|
||||
setlocale to return a pointer to the string associated with this category for the current settings (no
|
||||
changes occur). All other values are implementation-specific.
|
||||
<p>
|
||||
After a successful set, <code><b>setlocale</b></code> returns a pointer to a string which represents the previous
|
||||
location setting. On failure it returns NULL.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<locale.h>
|
||||
#include<stdio.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char *old_locale;
|
||||
|
||||
old_locale=setlocale(LC_ALL,"C");
|
||||
printf("The preivous setting was %s.\n",old_locale);
|
||||
return 0;
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<a name="localeconv"></a>
|
||||
<h2>2.6.3 localeconv</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote><code><b>
|
||||
struct lconv *localeconv(void);
|
||||
</b></code></blockquote>
|
||||
Sets the structure <code><b>lconv</b></code> to represent the current location settings.
|
||||
<p>
|
||||
The string pointers in the structure may point to a null string ("") which indicates that the
|
||||
value is not available. The char types are nonnegative numbers. If the value is <code><b>CHAR_MAX</b></code>,
|
||||
then the value is not available.
|
||||
<p>
|
||||
<code><b>lconv</b></code> variables:
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td><code><b>char *decimal_point</b></code></td>
|
||||
<td> Decimal point character used for non-monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *thousands_sep</b></code></td>
|
||||
<td> Thousands place separator character used for non-monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *grouping</b></code></td>
|
||||
<td> A string that indicates the size of each group of digits in non-monetary quantities. Each
|
||||
character represents an integer value which designates the number of digits in the current group.
|
||||
A value of 0 means that the previous value is to be used for the rest of the groups.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *int_curr_symbol</b></code></td>
|
||||
<td> A string of the international currency symbols used. The first three characters are those
|
||||
specified by ISO 4217:1987 and the fourth is the character which separates the currency symbol
|
||||
from the monetary quantity.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *currency_symbol</b></code></td>
|
||||
<td> The local symbol used for currency.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *mon_decimal_point</b></code></td>
|
||||
<td> The decimal point character used for monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *mon_thousands_sep</b></code></td>
|
||||
<td> The thousands place grouping character used for monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *mon_grouping</b></code></td>
|
||||
<td> A string whose elements define the size of the grouping of digits in monetary values.
|
||||
Each character represents an integer value which designates the number of digits in the current
|
||||
group. A value of 0 means that the previous value is to be used for the rest of the groups.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *positive_sign</b></code></td>
|
||||
<td> The character used for positive monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char *negative_sign</b></code></td>
|
||||
<td> The character used for negative monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char int_frac_digits</b></code></td>
|
||||
<td> Number of digits to show after the decimal point in international monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char frac_digits</b></code></td>
|
||||
<td> Number of digits to show after the decimal point in monetary values.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char p_cs_precedes</b></code></td>
|
||||
<td> If equal to 1, then the <code><b>currency_symbol</b></code> appears before a positive monetary value. If
|
||||
equal to 0, then the <code><b>currency_symbol</b></code> appears after a positive monetary value.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char p_sep_by_space</b></code></td>
|
||||
<td> If equal to 1, then the <code><b>currency_symbol</b></code> is separated by a space from a positive monetary
|
||||
value. If equal to 0, then there is no space between the <code><b>currency_symbol</b></code> and a positive
|
||||
monetary value.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char n_cs_precedes</b></code></td>
|
||||
<td> If equal to 1, then the <code><b>currency_symbol</b></code> precedes a negative monetary value. If equal to
|
||||
0, then the <code><b>currency_symbol succeeds a negative monetary value.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char n_sep_by_space</b></code></td>
|
||||
<td> If equal to 1, then the <code><b>currency_symbol</b></code> is separated by a space from a negative monetary
|
||||
value. If equal to 0, then there is no space between the <code><b>currency_symbol</b></code> and a negative
|
||||
monetary value.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char p_sign_posn</b></code></td>
|
||||
<td> Represents the position of the <code><b>positive_sign</b></code> in a positive monetary value.
|
||||
</td></tr><tr>
|
||||
<td><code><b>char n_sign_posn</b></code></td>
|
||||
<td> Represents the position of the <code><b>negative_sign</b></code> in a negative monetary value.
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
The following values are used for <b><code>p_sign_posn</code></b> and <b><code>n_sign_posn</code></b>:
|
||||
<table border=0>
|
||||
<tr><td><code><b>0</b></code></td><td> Parentheses encapsulate the value and the currency_symbol.</td></tr>
|
||||
<tr><td><code><b>1</b></code></td><td> The sign precedes the value and currency_symbol.</td></tr>
|
||||
<tr><td><code><b>2</b></code></td><td> The sign succeeds the value and currency_symbol.</td></tr>
|
||||
<tr><td><code><b>3</b></code></td><td> The sign immediately precedes the value and currency_symbol.</td></tr>
|
||||
<tr><td><code><b>4</b></code></td><td> The sign immediately succeeds the value and currency_symbol.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
Example:<br>
|
||||
<blockquote><code><b><pre>
|
||||
|
||||
#include<locale.h>
|
||||
#include<stdio.h>
|
||||
int main(void)
|
||||
{
|
||||
struct lconv locale_structure;
|
||||
struct lconv *locale_ptr=&locale_structure;
|
||||
|
||||
locale_ptr=lcoaleconv();
|
||||
printf("Decimal point: %s",locale_ptr->decimal_point);
|
||||
printf("Thousands Separator: %s",locale_ptr->thousands_sep);
|
||||
printf("Grouping: %s",locale_ptr->grouping);
|
||||
printf("International Currency Symbol: %s",locale_ptr->int_curr_symbol);
|
||||
printf("Currency Symbol: %s",locale_ptr->currency_symbol);
|
||||
printf("Monetary Decimal Point: %s",locale_ptr->mon_decimal_point);
|
||||
printf("Monetary Thousands Separator: %s",locale_ptr->mon_thousands_sep);
|
||||
printf("Monetary Grouping: %s",locale_ptr->mon_grouping);
|
||||
printf("Monetary Positive Sign: %s",locale_ptr->positive_sign);
|
||||
printf("Monetary Negative Sign: %s",locale_ptr->negative_sign);
|
||||
printf("Monetary Intl Decimal Digits: %c",locale_ptr->int_frac_digits);
|
||||
printf("Monetary Decimal Digits: %c",locale_ptr->frac_digits);
|
||||
printf("Monetary + Precedes: %c",locale_ptr->p_cs_precedes);
|
||||
printf("Monetary + Space: %c",locale_ptr->p_sep_by_space);
|
||||
printf("Monetary - Precedes: %c",locale_ptr->n_cs_precedes);
|
||||
printf("Monetary - Space: %c",locale_ptr->n_sep_by_space);
|
||||
printf("Monetary + Sign Posn: %c",locale_ptr->p_sign_posn);
|
||||
printf("Monetary - Sign Posn: %c",locale_ptr->n_sign_posn);
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.5.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.5 limits.h</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="2.7.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.7 math.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
453
Ref-docs/c_lib_guide/2.7.html
Normal file
453
Ref-docs/c_lib_guide/2.7.html
Normal file
@@ -0,0 +1,453 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.7 math.h
|
||||
</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="2.6.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.6 locale.h</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="2.8.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.8 setjmp.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.7 math.h</h1>
|
||||
<p>
|
||||
The math header defines several mathematic functions.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote>
|
||||
<code><b>HUGE_VAL</b></code>
|
||||
</blockquote>
|
||||
<p>
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
acos();<br>
|
||||
asin();<br>
|
||||
atan();<br>
|
||||
atan2();<br>
|
||||
ceil();<br>
|
||||
cos();<br>
|
||||
cosh();<br>
|
||||
exp();<br>
|
||||
fabs();<br>
|
||||
floor();<br>
|
||||
fmod();<br>
|
||||
frexp();<br>
|
||||
ldexp();<br>
|
||||
log();<br>
|
||||
log10();<br>
|
||||
modf();<br>
|
||||
pow();<br>
|
||||
sin();<br>
|
||||
sinh();<br>
|
||||
sqrt();<br>
|
||||
tan();<br>
|
||||
tanh();<br>
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
<a name="variables"></a>
|
||||
<h2>2.7.1 Error Conditions</h2>
|
||||
<p>
|
||||
All math.h functions handle errors similarly.
|
||||
<p>
|
||||
In the case that the argument passed to the function exceeds the range of that function,
|
||||
then the variable <code><b>errno</b></code> is set to <code><b>EDOM</b></code>. The value that the function returns is implementation
|
||||
specific.
|
||||
<p>
|
||||
In the case that the value being returned is too large to be represented in a double, then
|
||||
the function returns the macro <code><b>HUGE_VAL</b></code>, and sets the variable <code><b>errno</b></code> to <code><b>ERANGE</b></code> to represent
|
||||
an overflow. If the value is too small to be represented in a double, then the function returns
|
||||
zero. In this case whether or not <code><b>errno</b></code> is set to <code><b>ERANGE</b></code> is implementation specific.
|
||||
<p>
|
||||
<code><b>errno</b></code>, <code><b>EDOM</b></code>, and <code><b>ERANGE</b></code> are defined in the errno.h header.
|
||||
<p>
|
||||
Note that in all cases when it is stated that there is no range limit, it is implied that the
|
||||
value is limited by the minimum and maximum values of type double.
|
||||
<p>
|
||||
<h2> 2.7.2 Trigonometric Functions</h2>
|
||||
<a name="acos"></a>
|
||||
<h2>2.7.2.1 acos</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double acos(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the arc cosine of <i>x</i> in radians.
|
||||
</blockquote>
|
||||
<p>
|
||||
Range:
|
||||
<blockquote>
|
||||
The value <i>x</i> must be within the range of -1 to +1 (inclusive). The returned value is in the
|
||||
range of 0 to pi (inclusive).
|
||||
</blockquote>
|
||||
<p>
|
||||
<a name="asin"></a>
|
||||
<h2>2.7.2.2 asin</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double asin(double</b></code> <i>x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the arc sine of <i>x</i> in radians.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The value of <i>x</i> must be within the range of -1 to +1 (inclusive). The returned value is in
|
||||
the range of -p/2 to +p/2 (inclusive).
|
||||
</blockquote>
|
||||
|
||||
<a name="atan"></a>
|
||||
<h2>2.7.2.3 atan</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double atan(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the arc tangent of <i>x</i> in radians.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The value of <i>x </i>has no range. The returned value is in the range of -p/2 to +p/2
|
||||
(inclusive).
|
||||
</blockquote>
|
||||
|
||||
<a name="atan2"></a>
|
||||
<h2>2.7.2.4 atan2</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double atan2(doubly</b></code><i> y</i><code><b>, double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the arc tangent in radians of <i>y/x</i> based on the signs of both values to determine
|
||||
the correct quadrant.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
Both <i>y</i> and <i>x</i> cannot be zero. The returned value is in the range of -p/2 to +p/2
|
||||
(inclusive).
|
||||
</blockquote>
|
||||
|
||||
<a name="cos"></a>
|
||||
<h2>2.7.2.5 cos</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double cos(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the cosine of a radian angle <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The value of <i>x</i> has no range. The returned value is in the range of -1 to +1 (inclusive).
|
||||
</blockquote>
|
||||
|
||||
<a name="cosh"></a>
|
||||
<h2>2.7.2.6 cosh</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double cosh(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
|
||||
Returns the hyperbolic cosine of <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="sin"></a>
|
||||
<h2>2.7.2.7 sin</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double sin(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the sine of a radian angle <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The value of <i>x</i> has no range. The returned value is in the range of -1 to +1 (inclusive).
|
||||
</blockquote>
|
||||
|
||||
<a name="sinh"></a>
|
||||
<h2>2.7.2.8 sinh</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double sinh(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the hyperbolic sine of <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="tan"></a>
|
||||
<h2>2.7.2.9 tan</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double tan(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the tangent of a radian angle <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="tanh"></a>
|
||||
<h2>2.7.2.10 tanh</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double tanh(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the hyperbolic tangent of <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The value of <i>x</i> has no range. The returned value is in the range of -1 to +1 (inclusive).
|
||||
</blockquote>
|
||||
<h2> 2.7.3 Exponential, Logarithmic, and Power Functions</h2>
|
||||
<a name="exp"></a>
|
||||
<h2>2.7.3.1 exp</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double exp(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the value of e raised to the <i>x</i>th power.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="frexp"></a>
|
||||
<h2>2.7.3.2 frexp</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double frexp(double</b></code><i> x</i><code><b>, int *</b></code><i>exponent</i><code><b>);</b></code>
|
||||
<p>
|
||||
The floating-point number <i>x</i> is broken up into a mantissa and exponent.<br>
|
||||
The returned value is the mantissa and the integer pointed to by <i>exponent</i> is the
|
||||
exponent. The resultant value is <tt>x=mantissa * 2^exponent</tt>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The mantissa is in the range of .5 (inclusive) to 1 (exclusive).
|
||||
</blockquote>
|
||||
|
||||
<a name="ldexp"></a>
|
||||
<h2>2.7.3.3 ldexp</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double ldexp(double</b></code><i> x</i><code><b>, int</b></code> <i>exponent</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns <i>x</i> multiplied by 2 raised to the power of <i>exponent</i>.<br>
|
||||
<tt>x*2^exponent</tt>
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="log"></a>
|
||||
<h2>2.7.3.4 log</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double log(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the natural logarithm (base-e logarithm) of <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
|
||||
<a name="log10"></a>
|
||||
<h2>2.7.3.5 log10</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double log10(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the common logarithm (base-10 logarithm) of <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="modf"></a>
|
||||
<h2>2.7.3.6 modf</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double modf(double</b></code><i> x</i><code><b>, double *</b></code><i>integer</i><code><b>);</b></code>
|
||||
<p>
|
||||
Breaks the floating-point number <i>x</i> into integer and fraction components.<br>
|
||||
The returned value is the fraction component (part after the decimal), and sets <i>integer</i> to
|
||||
the integer component.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="pow"></a>
|
||||
<h2>2.7.3.7 pow</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double pow(double</b></code><i> x</i><code><b>, double</b></code><i> y</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns <i>x</i> raised to the power of <i>y</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
<i>x</i> cannot be negative if <i>y</i> is a fractional value. <i>x</i> cannot be zero if <i>y</i> is less than or equal
|
||||
to zero.
|
||||
</blockquote>
|
||||
|
||||
<a name="sqrt"></a>
|
||||
<h2>2.7.3.8 sqrt</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double sqrt(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the square root of <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
The argument cannot be negative. The returned value is always positive.
|
||||
</blockquote>
|
||||
<h2> 2.7.4 Other Math Functions</h2>
|
||||
<a name="ceil"></a>
|
||||
<h2>2.7.4.1 ceil</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double ceil(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the smallest integer value greater than or equal to <i>x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="fabs"></a>
|
||||
<h2>2.7.4.2 fabs</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double fabs(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the absolute value of<i> x</i> (a negative value becomes positive, positive value is
|
||||
unchanged).
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument. The return value is always positive.
|
||||
</blockquote>
|
||||
|
||||
<a name="floor"></a>
|
||||
<h2>2.7.4.3 floor</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double floor(double</b></code><i> x</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the largest integer value less than or equal to<i> x</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the argument or return value.
|
||||
</blockquote>
|
||||
|
||||
<a name="fmod"></a>
|
||||
<h2>2.7.4.4 fmod</h2>
|
||||
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>double fmod(double</b></code><i> x</i><code><b>, double</b></code><i> y</i><code><b>);</b></code>
|
||||
<p>
|
||||
Returns the remainder of <i>x</i> divided by <i>y</i>.
|
||||
</blockquote>
|
||||
|
||||
Range:
|
||||
<blockquote>
|
||||
There is no range limit on the return value. If <i>y</i> is zero, then either a range error will
|
||||
occur or the function will return zero (implementation-defined).
|
||||
</blockquote>
|
||||
<hr>
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.6.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.6 locale.h</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="2.8.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.8 setjmp.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
136
Ref-docs/c_lib_guide/2.8.html
Normal file
136
Ref-docs/c_lib_guide/2.8.html
Normal file
@@ -0,0 +1,136 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.8 setjmp.h
|
||||
</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="2.7.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.7 math.h</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="2.9.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.9 signal.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.8 setjmp.h</h1>
|
||||
<p>
|
||||
The setjmp header is used for controlling low-level calls and returns to and from
|
||||
functions.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
setjmp();
|
||||
</b></code></blockquote>
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
longjmp();
|
||||
</b></code></blockquote>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
typedef jmp_buf
|
||||
</b></code></blockquote>
|
||||
<p>
|
||||
<a name="variables"></a>
|
||||
<h2>2.8.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
The variable type <code><b>jmp_buf</b></code> is an array type used for holding information for <code><b>setjmp</b></code> and
|
||||
<code><b>longjmp</b></code>.
|
||||
<p>
|
||||
<a name="setjmp"></a>
|
||||
<h2>2.8.2 setjmp</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>int setjmp(jmp_buf</b></code><i> environment</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
Saves the environment into the variable <i>environment</i>. If a non-zero value is returned,
|
||||
then this indicates that the point in the sourcecode was reached by a <b><code>longjmp</code></b>. Otherwise zero is
|
||||
returned indicating the environment has been saved.
|
||||
<p>
|
||||
<a name="longjmp"></a>
|
||||
<h2>2.8.3 longjmp</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>void longjmp(jmp_buf</b></code><i> environment</i><code><b>, int</b></code><i> value</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
Causes the environment to be restored from a <code><b>setjmp</b></code> call where the environment variable
|
||||
had been saved. It causes execution to goto the <code><b>setjmp</b></code> location as if <code><b>setjmp</b></code> had returned the
|
||||
value of the variable <i>value</i>. The variable <i>value</i> cannot be zero. However, if zero is passed, then
|
||||
1 is replaced. If the function where <code><b>setjmp</b></code> was called has terminated, then the results are
|
||||
undefined.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<setjmp.h>
|
||||
#include<stdio.h>
|
||||
|
||||
void some_function(jmp_buf);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int value;
|
||||
jmp_buf environment_buffer;
|
||||
|
||||
value=setjmp(environment_buffer);
|
||||
if(value!=0)
|
||||
{
|
||||
printf("Reached this point from a longjmp with value=%d.\n",value);
|
||||
exit(0);
|
||||
}
|
||||
printf("Calling function.\n");
|
||||
some_function(environment_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void some_function(jmp_buf env_buf)
|
||||
{
|
||||
longjmp(env_buf,5);
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
|
||||
The output from this program should be:<br>
|
||||
<pre>
|
||||
Calling function.
|
||||
Reached this point from a longjmp with value=5.
|
||||
</pre>
|
||||
<hr>
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.7.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.7 math.h</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="2.9.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.9 signal.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
170
Ref-docs/c_lib_guide/2.9.html
Normal file
170
Ref-docs/c_lib_guide/2.9.html
Normal file
@@ -0,0 +1,170 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--2.9 signal.h
|
||||
</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="2.8.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.8 setjmp.h</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="2.10.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.10 stdarg.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
|
||||
<h1> 2.9 signal.h</h1>
|
||||
<p>
|
||||
The signal header provides a means to handle signals reported during a program's
|
||||
execution.
|
||||
<p>
|
||||
Macros:
|
||||
<blockquote><code><b>
|
||||
SIG_DFL<br>
|
||||
SIG_ERR<br>
|
||||
SIG_IGN<br>
|
||||
SIGABRT<br>
|
||||
SIGFPE<br>
|
||||
SIGILL<br>
|
||||
SIGINT<br>
|
||||
SIGSEGV<br>
|
||||
SIGTERM<br>
|
||||
</b></code></blockquote>
|
||||
Functions:
|
||||
<blockquote><code><b>
|
||||
signal();<br>
|
||||
raise();<br>
|
||||
</b></code></blockquote>
|
||||
Variables:
|
||||
<blockquote><code><b>
|
||||
typedef sig_atomic_t
|
||||
</b></code></blockquote>
|
||||
|
||||
<a name="variables"></a>
|
||||
<h2>2.9.1 Variables and Definitions</h2>
|
||||
<p>
|
||||
The <code><b>sig_atomic_t</b></code> type is of type <code><b>int</b></code> and is used as a variable in a signal handler.
|
||||
The <code><b>SIG_</b></code> macros are used with the signal function to define signal functions.
|
||||
<table border=0>
|
||||
<tr><td><code><b> SIG_DFL</b></code></td><td> Default handler.</td></tr>
|
||||
<tr><td><code><b> SIG_ERR</b></code></td><td> Represents a signal error.</td></tr>
|
||||
<tr><td><code><b> SIG_IGN</b></code></td><td> Signal ignore.</td></tr>
|
||||
</table>
|
||||
<p>
|
||||
The <code><b>SIG</b></code> macros are used to represent a signal number in the following conditions:
|
||||
<table border=0>
|
||||
<tr><td><code><b> SIGABRT</b></code></td><td> Abnormal termination (generated by the abort function).</td></tr>
|
||||
<tr><td><code><b> SIGFPE</b></code></td><td> Floating-point error (error caused by division by zero, invalid operation, etc.). </td></tr>
|
||||
<tr><td><code><b> SIGILL</b></code></td><td> Illegal operation (instruction).</td></tr>
|
||||
<tr><td><code><b> SIGINT </b></code></td><td> Interactive attention signal (such as ctrl-C).</td></tr>
|
||||
<tr><td><code><b> SIGSEGV</b></code></td><td> Invalid access to storage (segment violation, memory violation).</td></tr>
|
||||
<tr><td><code><b> SIGTERM </b></code></td><td> Termination request.</td></tr>
|
||||
</table>
|
||||
<a name="signal"></a>
|
||||
<h2>2.9.2 signal</h2>
|
||||
<p>
|
||||
Declaration:
|
||||
<blockquote>
|
||||
<code><b>void (*signal(int</b></code><i> sig</i><code><b>, void (*</b></code><i>func</i><b><code>)(int)))(int);</b></code>
|
||||
</blockquote
|
||||
<p>
|
||||
Controls how a signal is handled. <i>sig</i> represents the signal number compatible with the
|
||||
<code><b>SIG</b></code> macros. <i>func</i> is the function to be called when the signal occurs. If func is <code><b>SIG_DFL</b></code>, then
|
||||
the default handler is called. If <i>func</i> is <code><b>SIG_IGN</b></code>, then the signal is ignored. If <i>func</i> points to a
|
||||
function, then when a signal is detected the default function is called (<code><b>SIG_DFL</b></code>), then the
|
||||
function is called. The function must take one argument of type <code><b>int</b></code> which represents the signal
|
||||
number. The function may terminate with <code><b>return</b></code>, <code><b>abort</b></code>, <code><b>exit</b></code>, or <code><b>longjmp</b></code>. When the function
|
||||
terminates execution resumes where it was interrupted (unless it was a <code><b>SIGFPE</b></code> signal in which
|
||||
case the result is undefined).
|
||||
<p>
|
||||
If the call to signal is successful, then it returns a pointer to the previous signal handler
|
||||
for the specified signal type. If the call fails, then <code><b>SIG_ERR</b></code> is returned and <code><b>errno</b></code> is set
|
||||
appropriately.
|
||||
<p>
|
||||
<a name="raise"></a>
|
||||
<h2>2.9.3 raise</h2>
|
||||
<p>
|
||||
Declaration
|
||||
<blockquote>
|
||||
<code><b>int raise(int </b></code><i>sig</i><code><b>);</b></code>
|
||||
</blockquote>
|
||||
Causes signal <i>sig</i> to be generated. The <i>sig</i> argument is compatible with the <code><b>SIG</b></code> macros.
|
||||
<p>
|
||||
If the call is successful, zero is returned. Otherwise a nonzero value is returned.
|
||||
<p>
|
||||
Example:
|
||||
<blockquote><code><b><pre>
|
||||
#include<signal.h>
|
||||
#include<stdio.h>
|
||||
|
||||
void catch_function(int);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
if(signal(SIGINT, catch_function)==SIG_ERR)
|
||||
{
|
||||
printf("An error occured while setting a signal handler.\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
printf("Raising the interactive attention signal.\n");
|
||||
if(raise(SIGINT)!=0)
|
||||
{
|
||||
printf("Error raising the signal.\n");
|
||||
exit(0);
|
||||
}
|
||||
printf("Exiting.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void catch_function(int signal)
|
||||
{
|
||||
printf("Interactive attention signal caught.\n");
|
||||
}
|
||||
</pre></b></code></blockquote>
|
||||
The output from the program should be (assuming no errors):<br>
|
||||
<pre>
|
||||
Raising the interactive attention signal.
|
||||
Interactive attention signal caught.
|
||||
Exiting.
|
||||
</pre>
|
||||
<hr>
|
||||
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="2.8.html">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
2.8 setjmp.h</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="2.10.html">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
2.10 stdarg.h</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
161
Ref-docs/c_lib_guide/a.html
Normal file
161
Ref-docs/c_lib_guide/a.html
Normal file
@@ -0,0 +1,161 @@
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--Appendix A ASCII Chart
|
||||
</title>
|
||||
<!-- Changed by: eric huss, 12-Mar-1997 -->
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF">
|
||||
<center>
|
||||
| <a href="index.html">Table of Contents</a> | <a href="index2.html">Index</a> |
|
||||
</center>
|
||||
<h1>Appendix A</h1>
|
||||
|
||||
<h2>ASCII Chart</h2>
|
||||
<table border=0>
|
||||
<tr><td>
|
||||
<table border=1>
|
||||
<tr><th>Decimal</th><th> Octal</th><th> Hex</th><th> Character</th></tr>
|
||||
<tr><td>0</td><td> 0</td><td> 00</td><td> NUL</td></tr>
|
||||
<tr><td>1</td><td> 1</td><td> 01</td><td> SOH</td></tr>
|
||||
<tr><td>2</td><td> 2</td><td> 02</td><td> STX</td></tr>
|
||||
<tr><td>3</td><td> 3</td><td> 03</td><td> ETX</td></tr>
|
||||
<tr><td>4</td><td> 4</td><td> 04</td><td> EOT</td></tr>
|
||||
<tr><td>5</td><td> 5</td><td> 05</td><td> ENQ</td></tr>
|
||||
<tr><td>6</td><td> 6</td><td> 06</td><td> ACK</td></tr>
|
||||
<tr><td>7</td><td> 7</td><td> 07</td><td> BEL</td></tr>
|
||||
<tr><td>8</td><td> 10</td><td> 08</td><td> BS</td></tr>
|
||||
<tr><td>9</td><td> 11</td><td> 09</td><td> HT</td></tr>
|
||||
<tr><td>10</td><td> 12</td><td> 0A</td><td> LF</td></tr>
|
||||
<tr><td>11</td><td> 13</td><td> 0B</td><td> VT</td></tr>
|
||||
<tr><td>12</td><td> 14</td><td> 0C</td><td> FF</td></tr>
|
||||
<tr><td>13</td><td> 15</td><td> 0D</td><td> CR</td></tr>
|
||||
<tr><td>14</td><td> 16</td><td> 0E</td><td> SO</td></tr>
|
||||
<tr><td>15</td><td> 17</td><td> 0F</td><td> SI</td></tr>
|
||||
<tr><td>16</td><td> 20</td><td> 10</td><td> DLE</td></tr>
|
||||
<tr><td>17</td><td> 21</td><td> 11</td><td> DC1</td></tr>
|
||||
<tr><td>18</td><td> 22</td><td> 12</td><td> DC2</td></tr>
|
||||
<tr><td>19</td><td> 23</td><td> 13</td><td> DC3</td></tr>
|
||||
<tr><td>20</td><td> 24</td><td> 14</td><td> DC4</td></tr>
|
||||
<tr><td>21</td><td> 25</td><td> 15</td><td> NAK</td></tr>
|
||||
<tr><td>22</td><td> 26</td><td> 16</td><td> SYM</td></tr>
|
||||
<tr><td>23</td><td> 27</td><td> 17</td><td> ETB</td></tr>
|
||||
<tr><td>24</td><td> 30</td><td> 18</td><td> CAN</td></tr>
|
||||
<tr><td>25</td><td> 31</td><td> 19</td><td> EM</td></tr>
|
||||
<tr><td>26</td><td> 32</td><td> 1A</td><td> SUB</td></tr>
|
||||
<tr><td>27</td><td> 33</td><td> 1B</td><td> ESC</td></tr>
|
||||
<tr><td>28</td><td> 34</td><td> 1C</td><td> FS</td></tr>
|
||||
<tr><td>29</td><td> 35</td><td> 1D</td><td> GS</td></tr>
|
||||
<tr><td>30</td><td> 36</td><td> 1E</td><td> RS</td></tr>
|
||||
<tr><td>31</td><td> 37</td><td> 1F</td><td> US</td></tr>
|
||||
<tr><td>32</td><td> 40</td><td> 20</td><td> SP</td></tr>
|
||||
<tr><td>33</td><td> 41</td><td> 21</td><td> !</td></tr>
|
||||
<tr><td>34</td><td> 42</td><td> 22</td><td> "</td></tr>
|
||||
<tr><td>35</td><td> 43</td><td> 23</td><td> #</td></tr>
|
||||
<tr><td>36</td><td> 44</td><td> 24</td><td> $</td></tr>
|
||||
<tr><td>37</td><td> 45</td><td> 25</td><td> %</td></tr>
|
||||
<tr><td>38</td><td> 46</td><td> 26</td><td> &</td></tr>
|
||||
<tr><td>39</td><td> 47</td><td> 27</td><td> ' </td></tr>
|
||||
<tr><td>40</td><td> 50</td><td> 28</td><td> (</td></tr>
|
||||
<tr><td>41</td><td> 51</td><td> 29</td><td> )</td></tr>
|
||||
<tr><td>42</td><td> 52</td><td> 2A</td><td> *</td></tr>
|
||||
<tr><td>43</td><td> 53</td><td> 2B</td><td> +</td></tr>
|
||||
<tr><td>44</td><td> 54</td><td> 2C</td><td> ,</td></tr>
|
||||
<tr><td>45</td><td> 55</td><td> 2D</td><td> -</td></tr>
|
||||
<tr><td>46</td><td> 56</td><td> 2E</td><td> .</td></tr>
|
||||
<tr><td>47</td><td> 57</td><td> 2F</td><td> /</td></tr>
|
||||
<tr><td>48</td><td> 60</td><td> 30</td><td> 0</td></tr>
|
||||
<tr><td>49</td><td> 61</td><td> 31</td><td> 1</td></tr>
|
||||
<tr><td>50</td><td> 62</td><td> 32</td><td> 2</td></tr>
|
||||
<tr><td>51</td><td> 63</td><td> 33</td><td> 3</td></tr>
|
||||
<tr><td>52</td><td> 64</td><td> 34</td><td> 4</td></tr>
|
||||
<tr><td>53</td><td> 65</td><td> 35</td><td> 5</td></tr>
|
||||
<tr><td>54</td><td> 66</td><td> 36</td><td> 6</td></tr>
|
||||
<tr><td>55</td><td> 67</td><td> 37</td><td> 7</td></tr>
|
||||
<tr><td>56</td><td> 70</td><td> 38</td><td> 8</td></tr>
|
||||
<tr><td>57</td><td> 71</td><td> 39</td><td> 9</td></tr>
|
||||
<tr><td>58</td><td> 72</td><td> 3A</td><td> :</td></tr>
|
||||
<tr><td>59</td><td> 73</td><td> 3B</td><td> ;</td></tr>
|
||||
<tr><td>60</td><td> 74</td><td> 3C</td><td> <</td></tr>
|
||||
<tr><td>61</td><td> 75</td><td> 3D</td><td> =</td></tr>
|
||||
<tr><td>62</td><td> 76</td><td> 3E</td><td> ></td></tr>
|
||||
<tr><td>63</td><td> 77</td><td> 3F</td><td> ?</td></tr>
|
||||
</table>
|
||||
</td><td>
|
||||
<table border=1>
|
||||
<tr><th>Decimal</th><th> Octal</th><th> Hex</th><th> Character</th></tr>
|
||||
<tr><td>64</td><td> 100</td><td> 40</td><td> @</td></tr>
|
||||
<tr><td>65</td><td> 101</td><td> 41</td><td> A</td></tr>
|
||||
<tr><td>66</td><td> 102</td><td> 42</td><td> B</td></tr>
|
||||
<tr><td>67</td><td> 103</td><td> 43</td><td> C</td></tr>
|
||||
<tr><td>68</td><td> 104</td><td> 44</td><td> D</td></tr>
|
||||
<tr><td>69</td><td> 105</td><td> 45</td><td> E</td></tr>
|
||||
<tr><td>70</td><td> 106</td><td> 46</td><td> F</td></tr>
|
||||
<tr><td>71</td><td> 107</td><td> 47</td><td> G</td></tr>
|
||||
<tr><td>72</td><td> 110</td><td> 48</td><td> H</td></tr>
|
||||
<tr><td>73</td><td> 111</td><td> 49</td><td> I</td></tr>
|
||||
<tr><td>74</td><td> 112</td><td> 4A</td><td> J</td></tr>
|
||||
<tr><td>75</td><td> 113</td><td> 4B</td><td> K</td></tr>
|
||||
<tr><td>76</td><td> 114</td><td> 4C</td><td> L</td></tr>
|
||||
<tr><td>77</td><td> 115</td><td> 4D</td><td> M</td></tr>
|
||||
<tr><td>78</td><td> 116</td><td> 4E</td><td> N</td></tr>
|
||||
<tr><td>79</td><td> 117</td><td> 4F</td><td> O</td></tr>
|
||||
<tr><td>80</td><td> 120</td><td> 50</td><td> P</td></tr>
|
||||
<tr><td>81</td><td> 121</td><td> 51</td><td> Q</td></tr>
|
||||
<tr><td>82</td><td> 122</td><td> 52</td><td> R</td></tr>
|
||||
<tr><td>83</td><td> 123</td><td> 53</td><td> S</td></tr>
|
||||
<tr><td>84</td><td> 124</td><td> 54</td><td> T</td></tr>
|
||||
<tr><td>85</td><td> 125</td><td> 55</td><td> U</td></tr>
|
||||
<tr><td>86</td><td> 126</td><td> 56</td><td> V</td></tr>
|
||||
<tr><td>87</td><td> 127</td><td> 57</td><td> W</td></tr>
|
||||
<tr><td>88</td><td> 130</td><td> 58</td><td> X</td></tr>
|
||||
<tr><td>89</td><td> 131</td><td> 59</td><td> Y</td></tr>
|
||||
<tr><td>90</td><td> 132</td><td> 5A</td><td> Z</td></tr>
|
||||
<tr><td>91</td><td> 133</td><td> 5B</td><td> [</td></tr>
|
||||
<tr><td>92</td><td> 134</td><td> 5C</td><td> \</td></tr>
|
||||
<tr><td>93</td><td> 135</td><td> 5D</td><td> ]</td></tr>
|
||||
<tr><td>94</td><td> 136</td><td> 5E</td><td> ^</td></tr>
|
||||
<tr><td>95</td><td> 137</td><td> 5F</td><td> _</td></tr>
|
||||
<tr><td>96</td><td> 140</td><td> 60</td><td> `</td></tr>
|
||||
<tr><td>97</td><td> 141</td><td> 61</td><td> a</td></tr>
|
||||
<tr><td>98</td><td> 142</td><td> 62</td><td> b</td></tr>
|
||||
<tr><td>99</td><td> 143</td><td> 63</td><td> c</td></tr>
|
||||
<tr><td>100</td><td> 144</td><td> 64</td><td> d</td></tr>
|
||||
<tr><td>101</td><td> 145</td><td> 65</td><td> e</td></tr>
|
||||
<tr><td>102</td><td> 146</td><td> 66</td><td> f</td></tr>
|
||||
<tr><td>103</td><td> 147</td><td> 67</td><td> g</td></tr>
|
||||
<tr><td>104</td><td> 150</td><td> 68</td><td> h</td></tr>
|
||||
<tr><td>105</td><td> 151</td><td> 69</td><td> i</td></tr>
|
||||
<tr><td>106</td><td> 152</td><td> 6A</td><td> j</td></tr>
|
||||
<tr><td>107</td><td> 153</td><td> 6B</td><td> k</td></tr>
|
||||
<tr><td>108</td><td> 154</td><td> 6C</td><td> l</td></tr>
|
||||
<tr><td>109</td><td> 155</td><td> 6D</td><td> m</td></tr>
|
||||
<tr><td>110</td><td> 156</td><td> 6E</td><td> n</td></tr>
|
||||
<tr><td>111</td><td> 157</td><td> 6F</td><td> o</td></tr>
|
||||
<tr><td>112</td><td> 160</td><td> 70</td><td> p</td></tr>
|
||||
<tr><td>113</td><td> 161</td><td> 71</td><td> q</td></tr>
|
||||
<tr><td>114</td><td> 162</td><td> 72</td><td> r</td></tr>
|
||||
<tr><td>115</td><td> 163</td><td> 73</td><td> s</td></tr>
|
||||
<tr><td>116</td><td> 164</td><td> 74</td><td> t</td></tr>
|
||||
<tr><td>117</td><td> 165</td><td> 75</td><td> u</td></tr>
|
||||
<tr><td>118</td><td> 166</td><td> 76</td><td> v</td></tr>
|
||||
<tr><td>119</td><td> 167</td><td> 77</td><td> w</td></tr>
|
||||
<tr><td>120</td><td> 170</td><td> 78</td><td> x</td></tr>
|
||||
<tr><td>121</td><td> 171</td><td> 79</td><td> y</td></tr>
|
||||
<tr><td>122</td><td> 172</td><td> 7A</td><td> z</td></tr>
|
||||
<tr><td>123</td><td> 173</td><td> 7B</td><td> {</td></tr>
|
||||
<tr><td>124</td><td> 174</td><td> 7C</td><td> |</td></tr>
|
||||
<tr><td>125</td><td> 175</td><td> 7D</td><td> }</td></tr>
|
||||
<tr><td>126</td><td> 176</td><td> 7E</td><td> ~</td></tr>
|
||||
<tr><td>127</td><td> 177</td><td> 7F</td><td> DEL</td></tr>
|
||||
</table>
|
||||
</td></tr></table>
|
||||
<hr>
|
||||
<center>
|
||||
| <a href="index.html">Table of Contents</a> | <a href="index2.html">Index</a> |
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
20
Ref-docs/c_lib_guide/bar.html
Normal file
20
Ref-docs/c_lib_guide/bar.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<center>
|
||||
<table border=0 width=100%>
|
||||
<tr>
|
||||
<td align=left width=20% valign=top>
|
||||
<a href="">
|
||||
<img src="left.gif" border=0>
|
||||
Previous Section<br>
|
||||
_</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="">
|
||||
Next Section
|
||||
<img src="right.gif" border=0><br>
|
||||
_</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
4346
Ref-docs/c_lib_guide/c_guide.txt
Normal file
4346
Ref-docs/c_lib_guide/c_guide.txt
Normal file
File diff suppressed because it is too large
Load Diff
248
Ref-docs/c_lib_guide/index.html
Normal file
248
Ref-docs/c_lib_guide/index.html
Normal file
@@ -0,0 +1,248 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
The C Library Reference Guide
|
||||
</title>
|
||||
<!-- Changed by: eric huss, 12-Mar-1997 -->
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF">
|
||||
<center>
|
||||
<h1>The C Library Reference Guide</h1>
|
||||
<i>by Eric Huss</i><br>
|
||||
© Copyright 1997 Eric Huss<br>
|
||||
<br>
|
||||
Release 1
|
||||
</center>
|
||||
<hr size=5>
|
||||
<pre>
|
||||
<b><a href="introduction.html">Introduction</a></b>
|
||||
|
||||
1. <b>Language</b>
|
||||
1.1 <a href="1.1.html">Characters</a>
|
||||
1.1.1 Trigraph Characters
|
||||
1.1.2 Escape Sequences
|
||||
1.1.3 Comments
|
||||
1.2 <a href="1.2.html">Identifiers</a>
|
||||
1.2.1 <a href="1.2.html#keywords">Keywords</a>
|
||||
1.2.2 <a href="1.2.html#variables">Variables</a>
|
||||
1.2.3 <a href="1.2.html#enum">Enumerated Tags</a>
|
||||
1.2.4 <a href="1.2.html#arrays">Arrays</a>
|
||||
1.2.5 <a href="1.2.html#struct">Structures and Unions</a>
|
||||
1.2.6 <a href="1.2.html#const">Constants</a>
|
||||
1.2.7 <a href="1.2.html#strings">Strings</a>
|
||||
1.2.8 <a href="1.2.html#sizeof">sizeof Keyword</a>
|
||||
1.3 <a href="1.3.html">Functions</a>
|
||||
1.3.1 Definition
|
||||
1.3.2 Program Startup
|
||||
1.4 <a href="1.4.html">References</a>
|
||||
1.4.1 Pointers and the Address Operator
|
||||
1.4.2 Typecasting
|
||||
1.5 <a href="1.5.html">Operators</a>
|
||||
1.5.1 Postfix
|
||||
1.5.2 Unary and Prefix
|
||||
1.5.3 Normal
|
||||
1.5.4 Boolean
|
||||
1.5.5 Assignment
|
||||
1.5.6 Precedence
|
||||
1.6 <a href="1.6.html">Statements</a>
|
||||
1.6.1 <a href="1.6.html#if">if</a>
|
||||
1.6.2 <a href="1.6.html#switch">switch</a>
|
||||
1.6.3 <a href="1.6.html#while">while</a>
|
||||
1.6.4 <a href="1.6.html#do">do</a>
|
||||
1.6.5 <a href="1.6.html#for">for</a>
|
||||
1.6.6 <a href="1.6.html#goto">goto</a>
|
||||
1.6.7 <a href="1.6.html#continue">continue</a>
|
||||
1.6.8 <a href="1.6.html#break">break</a>
|
||||
1.6.9 <a href="1.6.html#return">return</a>
|
||||
1.7 <a href="1.7.html">Preprocessing Directives</a>
|
||||
1.7.1 <a href="1.7.html#conditional">#if, #elif, #else, #endif</a>
|
||||
1.7.2 <a href="1.7.html#define">#define, #undef, #ifdef, #ifndef</a>
|
||||
1.7.3 <a href="1.7.html#include">#include</a>
|
||||
1.7.4 <a href="1.7.html#line">#line</a>
|
||||
1.7.5 <a href="1.7.html#error">#error</a>
|
||||
1.7.6 <a href="1.7.html#pragma">#pragma</a>
|
||||
1.7.7 <a href="1.7.html#macros">Predefined Macros</a>
|
||||
2. <b>Library</b>
|
||||
2.1 <a href="2.1.html">assert.h</a>
|
||||
2.1.1 assert
|
||||
2.2 <a href="2.2.html">ctype.h</a>
|
||||
2.2.1 is... Functions
|
||||
2.2.2 to... Functions
|
||||
2.3 <a href="2.3.html">errno.h</a>
|
||||
2.3.1 EDOM
|
||||
2.3.2 ERANGE
|
||||
2.3.3 errno
|
||||
2.4 <a href="2.4.html">float.h</a>
|
||||
2.4.1 Defined Values
|
||||
2.5 <a href="2.5.html">limits.h</a>
|
||||
2.5.1 Defined Values
|
||||
2.6 <a href="2.6.html">locale.h</a>
|
||||
2.6.1 Variables and Definitions
|
||||
2.6.2 setlocale
|
||||
2.6.3 localeconv
|
||||
2.7 <a href="2.7.html">math.h</a>
|
||||
2.7.1 Error Conditions
|
||||
2.7.2 Trigonometric Functions
|
||||
2.7.2.1 <a href="2.7.html#acos">acos</a>
|
||||
2.7.2.2 <a href="2.7.html#asin">asin</a>
|
||||
2.7.2.3 <a href="2.7.html#atan">atan</a>
|
||||
2.7.2.4 <a href="2.7.html#atan2">atan2</a>
|
||||
2.7.2.5 <a href="2.7.html#cos">cos</a>
|
||||
2.7.2.6 <a href="2.7.html#cosh">cosh</a>
|
||||
2.7.2.7 <a href="2.7.html#sin">sin</a>
|
||||
2.7.2.8 <a href="2.7.html#sinh">sinh</a>
|
||||
2.7.2.9 <a href="2.7.html#tan">tan</a>
|
||||
2.7.2.10 <a href="2.7.html#tanh">tanh</a>
|
||||
2.7.3 Exponential, Logarithmic, and Power Functions
|
||||
2.7.3.1 <a href="2.7.html#exp">exp</a>
|
||||
2.7.3.2 <a href="2.7.html#frexp">frexp</a>
|
||||
2.7.3.3 <a href="2.7.html#ldexp">ldexp</a>
|
||||
2.7.3.4 <a href="2.7.html#log">log</a>
|
||||
2.7.3.5 <a href="2.7.html#log10">log10</a>
|
||||
2.7.3.6 <a href="2.7.html#modf">modf</a>
|
||||
2.7.3.7 <a href="2.7.html#pow">pow</a>
|
||||
2.7.3.8 <a href="2.7.html#sqrt">sqrt</a>
|
||||
2.7.4 Other Math Functions
|
||||
2.7.4.1 <a href="2.7.html#ceil">ceil</a>
|
||||
2.7.4.2 <a href="2.7.html#fabs">fabs</a>
|
||||
2.7.4.3 <a href="2.7.html#floor">floor</a>
|
||||
2.7.4.4 <a href="2.7.html#fmod">fmod</a>
|
||||
2.8 <a href="2.8.html">setjmp.h</a>
|
||||
2.8.1 Variables and Definitions
|
||||
2.8.2 setjmp
|
||||
2.8.3 longjmp
|
||||
2.9 <a href="2.9.html">signal.h</a>
|
||||
2.9.1 Variables and Definitions
|
||||
2.9.2 signal
|
||||
2.9.3 raise
|
||||
2.10 <a href="2.10.html">stdarg.h</a>
|
||||
2.10.1 Variables and Definitions
|
||||
2.10.2 va_start
|
||||
2.10.3 va_arg
|
||||
2.10.4 va_end
|
||||
2.11 <a href="2.11.html">stddef.h</a>
|
||||
2.11.1 Variables and Definitions
|
||||
2.12 <a href="2.12.html">stdio.h</a>
|
||||
2.12.1 <a href="2.12.html#variables">Variables and Definitions</a>
|
||||
2.12.2 <a href="2.12.html#streams">Streams and Files</a>
|
||||
2.12.3 File Functions
|
||||
2.12.3.1 <a href="2.12.html#clearerr">clearerr</a>
|
||||
2.12.3.2 <a href="2.12.html#fclose">fclose</a>
|
||||
2.12.3.3 <a href="2.12.html#feof">feof</a>
|
||||
2.12.3.4 <a href="2.12.html#ferror">ferror</a>
|
||||
2.12.3.5 <a href="2.12.html#fflush">fflush</a>
|
||||
2.12.3.6 <a href="2.12.html#fgetpos">fgetpos</a>
|
||||
2.12.3.7 <a href="2.12.html#fopen">fopen</a>
|
||||
2.12.3.8 <a href="2.12.html#fread">fread</a>
|
||||
2.12.3.9 <a href="2.12.html#freopen">freopen</a>
|
||||
2.12.3.10 <a href="2.12.html#fseek">fseek</a>
|
||||
2.12.3.11 <a href="2.12.html#fsetpos">fsetpos</a>
|
||||
2.12.3.12 <a href="2.12.html#ftell">ftell</a>
|
||||
2.12.3.13 <a href="2.12.html#fwrite">fwrite</a>
|
||||
2.12.3.14 <a href="2.12.html#remove">remove</a>
|
||||
2.12.3.15 <a href="2.12.html#rename">rename</a>
|
||||
2.12.3.16 <a href="2.12.html#rewind">rewind</a>
|
||||
2.12.3.17 <a href="2.12.html#setbuf">setbuf</a>
|
||||
2.12.3.18 <a href="2.12.html#setvbuf">setvbuf</a>
|
||||
2.12.3.19 <a href="2.12.html#tmpfile">tmpfile</a>
|
||||
2.12.3.20 <a href="2.12.html#tmpnam">tmpnam</a>
|
||||
2.12.4 Formatted I/O Functions
|
||||
2.12.4.1 <a href="2.12.html#printf">...printf Functions</a>
|
||||
2.12.4.2 <a href="2.12.html#scanf">...scanf Functions</a>
|
||||
2.12.5 Character I/O Functions
|
||||
2.12.5.1 <a href="2.12.html#fgetc">fgetc</a>
|
||||
2.12.5.2 <a href="2.12.html#fgets">fgets</a>
|
||||
2.12.5.3 <a href="2.12.html#fputc">fputc</a>
|
||||
2.12.5.4 <a href="2.12.html#fputs">fputs</a>
|
||||
2.12.5.5 <a href="2.12.html#getc">getc</a>
|
||||
2.12.5.6 <a href="2.12.html#getchar">getchar</a>
|
||||
2.12.5.7 <a href="2.12.html#gets">gets</a>
|
||||
2.12.5.8 <a href="2.12.html#putc">putc</a>
|
||||
2.12.5.9 <a href="2.12.html#putchar">putchar</a>
|
||||
2.12.5.10 <a href="2.12.html#puts">puts</a>
|
||||
2.12.5.11 <a href="2.12.html#ungetc">ungetc</a>
|
||||
2.12.7 Error Functions
|
||||
2.12.7.1 <a href="2.12.html#perror">perror</a>
|
||||
2.13 <a href="2.13.html">stdlib.h</a>
|
||||
2.13.1 <a href="2.13.html#variables">Variables and Definitions</a>
|
||||
2.13.2 String Functions
|
||||
2.13.2.1 <a href="2.13.html#atof">atof</a>
|
||||
2.13.2.2 <a href="2.13.html#atoi">atoi</a>
|
||||
2.13.2.3 <a href="2.13.html#atol">atol</a>
|
||||
2.13.2.4 <a href="2.13.html#strtod">strtod</a>
|
||||
2.13.2.5 <a href="2.13.html#strtol">strtol</a>
|
||||
2.13.2.6 <a href="2.13.html#strtoul">strtoul</a>
|
||||
2.13.3 Memory Functions
|
||||
2.13.3.1 <a href="2.13.html#calloc">calloc</a>
|
||||
2.13.3.2 <a href="2.13.html#free">free</a>
|
||||
2.13.3.3 <a href="2.13.html#malloc">malloc</a>
|
||||
2.13.3.4 <a href="2.13.html#realloc">realloc</a>
|
||||
2.13.4 Environment Functions
|
||||
2.13.4.1 <a href="2.13.html#abort">abort</a>
|
||||
2.13.4.2 <a href="2.13.html#atexit">atexit</a>
|
||||
2.13.4.3 <a href="2.13.html#exit">exit</a>
|
||||
2.13.4.4 <a href="2.13.html#getenv">getenv</a>
|
||||
2.13.4.5 <a href="2.13.html#system">system</a>
|
||||
2.13.5 Searching and Sorting Functions
|
||||
2.13.5.1 <a href="2.13.html#bsearch">bsearch</a>
|
||||
2.13.5.2 <a href="2.13.html#qsort">qsort</a>
|
||||
2.13.6 Math Functions
|
||||
2.13.6.1 <a href="2.13.html#abs">abs</a>
|
||||
2.13.6.2 <a href="2.13.html#div">div</a>
|
||||
2.13.6.3 <a href="2.13.html#labs">labs</a>
|
||||
2.13.6.4 <a href="2.13.html#ldiv">ldiv</a>
|
||||
2.13.6.5 <a href="2.13.html#rand">rand</a>
|
||||
2.13.6.6 <a href="2.13.html#srand">srand</a>
|
||||
2.13.7 Multibyte Functions
|
||||
2.13.7.1 <a href="2.13.html#mblen">mblen</a>
|
||||
2.13.7.2 <a href="2.13.html#mbstowcs">mbstowcs</a>
|
||||
2.13.7.3 <a href="2.13.html#mbtowc">mbtowc</a>
|
||||
2.13.7.4 <a href="2.13.html#wcstombs">wcstombs</a>
|
||||
2.13.7.5 <a href="2.13.html#wctomb">wctomb</a>
|
||||
2.14 <a href="2.14.html">string.h</a>
|
||||
2.14.1 <a href="2.14.html#variables">Variables and Definitions</a>
|
||||
2.14.2 <a href="2.14.html#memchr">memchr</a>
|
||||
2.14.3 <a href="2.14.html#memcmp">memcmp</a>
|
||||
2.14.4 <a href="2.14.html#memcpy">memcpy</a>
|
||||
2.14.5 <a href="2.14.html#memmove">memmove</a>
|
||||
2.14.6 <a href="2.14.html#memset">memset</a>
|
||||
2.14.7 <a href="2.14.html#strcat">strcat</a>
|
||||
2.14.8 <a href="2.14.html#strncat">strncat</a>
|
||||
2.14.9 <a href="2.14.html#strchr">strchr</a>
|
||||
2.14.10 <a href="2.14.html#strcmp">strcmp</a>
|
||||
2.14.11 <a href="2.14.html#strncmp">strncmp</a>
|
||||
2.14.12 <a href="2.14.html#strcoll">strcoll</a>
|
||||
2.14.13 <a href="2.14.html#strcpy">strcpy</a>
|
||||
2.14.14 <a href="2.14.html#strncpy">strncpy</a>
|
||||
2.14.15 <a href="2.14.html#strcspn">strcspn</a>
|
||||
2.14.16 <a href="2.14.html#strerror">strerror</a>
|
||||
2.14.17 <a href="2.14.html#strlen">strlen</a>
|
||||
2.14.18 <a href="2.14.html#strpbrk">strpbrk</a>
|
||||
2.14.19 <a href="2.14.html#strrchr">strrchr</a>
|
||||
2.14.20 <a href="2.14.html#strspn">strspn</a>
|
||||
2.14.21 <a href="2.14.html#strstr">strstr</a>
|
||||
2.14.22 <a href="2.14.html#strtok">strtok</a>
|
||||
2.14.23 <a href="2.14.html#strxfrm">strxfrm</a>
|
||||
2.15 <a href="2.15.html">time.h</a>
|
||||
2.15.1 <a href="2.15.html#variables">Variables and Definitions</a>
|
||||
2.15.2 <a href="2.15.html#asctime">asctime</a>
|
||||
2.15.3 <a href="2.15.html#clock">clock</a>
|
||||
2.15.4 <a href="2.15.html#ctime">ctime</a>
|
||||
2.15.5 <a href="2.15.html#difftime">difftime</a>
|
||||
2.15.6 <a href="2.15.html#gmtime">gmtime</a>
|
||||
2.15.7 <a href="2.15.html#localtime">localtime</a>
|
||||
2.15.8 <a href="2.15.html#mktime">mktime</a>
|
||||
2.15.9 <a href="2.15.html#strftime">strftime</a>
|
||||
2.15.10 <a href="2.15.html#time">time</a>
|
||||
<b>Appendix A</b>
|
||||
<a href="a.html">ASCII Chart</a>
|
||||
<b>Index</b>
|
||||
<a href="index2.html">Index</a>
|
||||
</pre>
|
||||
<hr>
|
||||
<center>
|
||||
<font size=-1>Questions, comments, or error reports? Please send them to
|
||||
<a href="mailto:e-huss@uiuc.edu">Eric Huss</a>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
389
Ref-docs/c_lib_guide/index2.html
Normal file
389
Ref-docs/c_lib_guide/index2.html
Normal file
@@ -0,0 +1,389 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--Index
|
||||
</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF">
|
||||
<center>
|
||||
<h1>The C Library Reference Guide</h1>
|
||||
<h3>Index</h3>
|
||||
|
||||
[ <a href="#pound">#</a> |
|
||||
<a href="#underunder">__</a> |
|
||||
<a href="#under">_</a> |
|
||||
<a href="#a">A</a> |
|
||||
<a href="#b">B</a> |
|
||||
<a href="#c">C</a> |
|
||||
<a href="#d">D</a> |
|
||||
<a href="#e">E</a> |
|
||||
<a href="#f">F</a> |
|
||||
<a href="#g">G</a> |
|
||||
<a href="#h">H</a> |
|
||||
<a href="#i">I</a> |
|
||||
<a href="#j">J</a> |
|
||||
<a href="#l">L</a> |
|
||||
<a href="#m">M</a> |
|
||||
<a href="#n">N</a> |
|
||||
<a href="#o">O</a> |
|
||||
<a href="#p">P</a> |
|
||||
<a href="#q">Q</a> |
|
||||
<a href="#r">R</a> |
|
||||
<a href="#s">S</a> |
|
||||
<a href="#t">T</a> |
|
||||
<a href="#u">U</a> |
|
||||
<a href="#v">V</a> |
|
||||
<a href="#w">W</a>
|
||||
]<br>
|
||||
<a href="index.html">Table of Contents</a>
|
||||
</center>
|
||||
<hr>
|
||||
|
||||
<a name="pound"></a>
|
||||
#if <a href="1.7.html#conditional">Preprocessing Directives</a><br>
|
||||
#define <a href="1.7.html#define">Preprocessing Directives</a><br>
|
||||
#elif <a href="1.7.html#conditional">Preprocessing Directives</a><br>
|
||||
#else <a href="1.7.html#conditional">Preprocessing Directives</a><br>
|
||||
#endif <a href="1.7.html#conditional">Preprocessing Directives</a><br>
|
||||
#error <a href="1.7.html#error">Preprocessing Directives</a><br>
|
||||
#ifdef <a href="1.7.html#define">Preprocessing Directives</a><br>
|
||||
#ifndef <a href="1.7.html#define">Preprocessing Directives</a><br>
|
||||
#include <a href="1.7.html#include">Preprocessing Directives</a><br>
|
||||
#line <a href="1.7.html#line">Preprocessing Directives</a><br>
|
||||
#pragma <a href="1.7.html#pragma">Preprocessing Directives</a><br>
|
||||
#undef <a href="1.7.html#define">Preprocessing Directives</a><br>
|
||||
|
||||
<p>
|
||||
<a name="underunder"></a>
|
||||
__LINE__ <a href="1.7.html#macros">Preprocessing Directives</a><br>
|
||||
__FILE__ <a href="1.7.html#macros">Preprocessing Directives</a><br>
|
||||
__DATE__ <a href="1.7.html#macros">Preprocessing Directives</a><br>
|
||||
__TIME__ <a href="1.7.html#macros">Preprocessing Directives</a><br>
|
||||
__STDC__ <a href="1.7.html#macros">Preprocessing Directives</a><br>
|
||||
|
||||
<p>
|
||||
|
||||
<a name="under"></a>
|
||||
_IOFBF <a href="2.12.html#variables">stdio.h</a><br>
|
||||
_IOLBF <a href="2.12.html#variables">stdio.h</a><br>
|
||||
_IONBF <a href="2.12.html#variables">stdio.h</a><br>
|
||||
|
||||
<p>
|
||||
|
||||
<a name="a"></a>
|
||||
abort() <a href="2.13.html#abort">stdlib.h</a><br>
|
||||
abs() <a href="2.13.html#abs">stdlib.h</a><br>
|
||||
acos() <a href="2.7.html#acos">math.h</a><br>
|
||||
asctime() <a href="2.15.html#asctime">time.h</a><br>
|
||||
asin() <a href="2.7.html#asin">math.h</a><br>
|
||||
assert() <a href="2.1.html#assert">assert.h</a><br>
|
||||
atan() <a href="2.7.html#atan">math.h</a><br>
|
||||
atan2() <a href="2.7.html#atan2">math.h</a><br>
|
||||
atexit() <a href="2.13.html#atexit">stdlib.h</a><br>
|
||||
atof() <a href="2.13.html#atof">stdlib.h</a><br>
|
||||
atoi() <a href="2.13.html#atoi">stdlib.h</a><br>
|
||||
atol() <a href="2.13.html#atol">stdlib.h</a><br>
|
||||
auto <a href="1.2.html#variables">Identifiers</a><br>
|
||||
|
||||
<p>
|
||||
<a name="b"></a>
|
||||
break <a href="1.6.html#break">Statements</a><br>
|
||||
bsearch() <a href="2.13.html#bsearch">stdlib.h</a><br>
|
||||
BUFSIZ <a href="2.12.html#variables">stdio.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="c"></a>
|
||||
|
||||
calloc() <a href="2.13.html#calloc">stdlib.h</a><br>
|
||||
ceil() <a href="2.7.html#ceil">math.h</a><br>
|
||||
char <a href="1.2.html#variables">Identifiers</a><br>
|
||||
clearerr() <a href="2.12.html#clearerr">stdio.h</a><br>
|
||||
clock() <a href="2.15.html#clock">time.h</a><br>
|
||||
clock_t <a href="2.15.html#variables">time.h</a><br>
|
||||
CLOCKS_PER_SEC <a href="2.15.html#variables">time.h</a><br>
|
||||
const <a href="1.2.html#const">Identifiers</a><br>
|
||||
continue <a href="1.6.html#continue">Statements</a><br>
|
||||
cos() <a href="2.7.html#cos">math.h</a><br>
|
||||
cosh() <a href="2.7.html#cosh">math.h</a><br>
|
||||
ctime() <a href="2.15.html#ctime">time.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="d"></a>
|
||||
|
||||
difftime() <a href="2.15.html#difftime">time.h</a><br>
|
||||
div() <a href="2.13.html#div">stdlib.h</a><br>
|
||||
div_t <a href="2.13.html#variables">stdlib.h</a><br>
|
||||
do <a href="1.6.html#do">Statements</a><br>
|
||||
double <a href="1.2.html#variables">Identifiers</a><br>
|
||||
|
||||
<p>
|
||||
<a name="e"></a>
|
||||
|
||||
EDOM <a href="2.3.html#edom">errno.h</a><br>
|
||||
enum <a href="1.2.html#enum">Identifiers</a><br>
|
||||
EOF <a href="2.12.html#variables">stdio.h</a><br>
|
||||
ERANGE <a href="2.3.html#erange">errno.h</a><br>
|
||||
errno <a href="2.3.html#errno">errno.h</a><br>
|
||||
exit() <a href="2.13.html#exit">stdlib.h</a><br>
|
||||
EXIT_FAILURE <a href="2.13.html#variables">stdlib.h</a><br>
|
||||
EXIT_SUCCESS <a href="2.13.html#variables">stdlib.h</a><br>
|
||||
exp() <a href="2.7.html#exp">math.h</a><br>
|
||||
extern <a href="1.2.html#variables">Identifiers</a><br>
|
||||
|
||||
<p>
|
||||
<a name="f"></a>
|
||||
fabs() <a href="2.7.html#fabs">math.h</a><br>
|
||||
fclose() <a href="2.12.html#fclose">stdio.h</a><br>
|
||||
feof() <a href="2.12.html#feof">stdio.h</a><br>
|
||||
ferror() <a href="2.12.html#ferror">stdio.h</a><br>
|
||||
fflush() <a href="2.12.html#fflush">stdio.h</a><br>
|
||||
fgetc() <a href="2.12.html#fgetc">stdio.h</a><br>
|
||||
fgetpos() <a href="2.12.html#fgetpos">stdio.h</a><br>
|
||||
fgets() <a href="2.12.html#fgets">stdio.h</a><br>
|
||||
FILE <a href="2.12.html#variables">stdio.h</a><br>
|
||||
FILENAME_MAX <a href="2.12.html#variables">stdio.h</a><br>
|
||||
float <a href="1.2.html#variables">Identifiers</a><br>
|
||||
floor() <a href="2.7.html#floor">math.h</a><br>
|
||||
fmod() <a href="2.7.html#fmod">math.h</a><br>
|
||||
fopen() <a href="2.12.html#fopen">stdio.h</a><br>
|
||||
FOPEN_MAX <a href="2.12.html#variables">stdio.h</a><br>
|
||||
for <a href="1.6.html#for">Statements</a><br>
|
||||
fpos_t <a href="2.12.html#variables">stdio.h</a><br>
|
||||
fprintf() <a href="2.12.html#fprintf">stdio.h</a><br>
|
||||
fputc() <a href="2.12.html#fputc">stdio.h</a><br>
|
||||
fputs() <a href="2.12.html#fputs">stdio.h</a><br>
|
||||
fread() <a href="2.12.html#fread">stdio.h</a><br>
|
||||
free() <a href="2.13.html#free">stdlib.h</a><br>
|
||||
freopen() <a href="2.12.html#freopen">stdio.h</a><br>
|
||||
frexp() <a href="2.7.html#frexp">math.h</a><br>
|
||||
fscanf() <a href="2.12.html#fscanf">stdio.h</a><br>
|
||||
fseek() <a href="2.12.html#fseek">stdio.h</a><br>
|
||||
fsetpos() <a href="2.12.html#fsetpos">stdio.h</a><br>
|
||||
ftell() <a href="2.12.html#ftell">stdio.h</a><br>
|
||||
fwrite() <a href="2.12.html#fwrite">stdio.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="g"></a>
|
||||
|
||||
getc() <a href="2.12.html#getc">stdio.h</a><br>
|
||||
getchar() <a href="2.12.html#getchar">stdio.h</a><br>
|
||||
getenv() <a href="2.13.html#getenv">stdlib.h</a><br>
|
||||
gets() <a href="2.12.html#gets">stdio.h</a><br>
|
||||
gmtime() <a href="2.15.html#gmtime">time.h</a><br>
|
||||
goto <a href="1.6.html#goto">Statements</a><br>
|
||||
|
||||
<p>
|
||||
<a name="h"></a>
|
||||
|
||||
HUGE_VAL <a href="2.7.html#variables">math.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="i"></a>
|
||||
|
||||
if <a href="1.6.html#if">Statements</a><br>
|
||||
isalnum() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isalpha() <a href="2.2.html#is">ctype.h</a><br>
|
||||
iscntrl() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isdigit() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isgraph() <a href="2.2.html#is">ctype.h</a><br>
|
||||
islower() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isprint() <a href="2.2.html#is">ctype.h</a><br>
|
||||
ispunct() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isspace() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isupper() <a href="2.2.html#is">ctype.h</a><br>
|
||||
isxdigit() <a href="2.2.html#is">ctype.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="j"></a>
|
||||
|
||||
jmp_buf <a href="2.8.html#variables">setjmp.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="l"></a>
|
||||
|
||||
L_tmpnam <a href="2.12.html#variables">stdio.h</a><br>
|
||||
labs() <a href="2.13.html#labs">stdlib.h</a><br>
|
||||
LC_ALL <a href="2.6.html#variables">locale.h</a><br>
|
||||
LC_COLLATE <a href="2.6.html#variables">locale.h</a><br>
|
||||
LC_CTYPE <a href="2.6.html#variables">locale.h</a><br>
|
||||
LC_MONETARY <a href="2.6.html#variables">locale.h</a><br>
|
||||
LC_NUMERIC <a href="2.6.html#variables">locale.h</a><br>
|
||||
LC_TIME <a href="2.6.html#variables">locale.h</a><br>
|
||||
ldexp() <a href="2.7.html#ldexp">math.h</a><br>
|
||||
ldiv() <a href="2.13.html#ldiv">stdlib.h</a><br>
|
||||
ldiv_t <a href="2.13.html#variables">stdlib.h</a><br>
|
||||
linkage <a href="1.2.html#variables">Identifiers</a><br>
|
||||
localeconv() <a href="2.6.html#localeconv">locale.h</a><br>
|
||||
localtime() <a href="2.15.html#localtime">time.h</a><br>
|
||||
log() <a href="2.7.html#log">math.h</a><br>
|
||||
log10() <a href="2.7.html#log10">math.h</a><br>
|
||||
long <a href="1.2.html#variables">Identifiers</a><br>
|
||||
longjmp() <a href="2.8.html#longjmp">setjmp.h</a><br>
|
||||
<p>
|
||||
<a name="m"></a>
|
||||
|
||||
malloc() <a href="2.13.html#malloc">stdlib.h</a><br>
|
||||
MB_CUR_MAX <a href="2.13.html#variables">stdlib.h</a><br>
|
||||
mblen() <a href="2.13.html#mblen">stdlib.h</a><br>
|
||||
mbstowcs() <a href="2.13.html#mbstowcs">stdlib.h</a><br>
|
||||
mbtowc() <a href="2.13.html#mbtowc">stdlib.h</a><br>
|
||||
memchr() <a href="2.14.html#memchr">string.h</a><br>
|
||||
memcmp() <a href="2.14.html#memcmp">string.h</a><br>
|
||||
memcpy() <a href="2.14.html#memcpy">string.h</a><br>
|
||||
memmove() <a href="2.14.html#memmove">string.h</a><br>
|
||||
memset() <a href="2.14.html#memset">string.h</a><br>
|
||||
mktime() <a href="2.15.html#mktime">time.h</a><br>
|
||||
modf() <a href="2.7.html#modf">math.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="n"></a>
|
||||
|
||||
NDEBUG <a href="2.1.html#assert">assert.h</a><br>
|
||||
NULL <a href="2.15.html#variables">time.h</a> <a href="2.14.html#variables">string.h</a>
|
||||
<a href="2.13.html#variables">stdlib.h</a>
|
||||
<a href="2.12.html#variables">stdio.h</a>
|
||||
<a href="2.11.html#variables">stddef.h</a>
|
||||
<a href="2.6.html#variables">locale.h</a>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
<a name="o"></a>
|
||||
|
||||
offsetof() <a href="2.11.html#variables">stddef.h</a><br>
|
||||
|
||||
|
||||
<p>
|
||||
<a name="p"></a>
|
||||
|
||||
perror() <a href="2.12.html#perror">stdio.h</a><br>
|
||||
pow() <a href="2.7.html#pow">math.h</a><br>
|
||||
printf() <a href="2.12.html#printf">stdio.h</a><br>
|
||||
ptrdiff_t <a href="2.11.html#variables">stddef.h</a><br>
|
||||
putc() <a href="2.12.html#putc">stdio.h</a><br>
|
||||
putchar() <a href="2.12.html#putchar">stdio.h</a><br>
|
||||
puts() <a href="2.12.html#puts">stdio.h</a><br>
|
||||
<p>
|
||||
<a name="q"></a>
|
||||
|
||||
qsort() <a href="2.13.html#qsort">stdlib.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="r"></a>
|
||||
|
||||
raise() <a href="2.9.html#raise">signal.h</a><br>
|
||||
rand() <a href="2.13.html#rand">stdlib.h</a><br>
|
||||
RAND_MAX <a href="2.13.html#variables">stdlib.h</a><br>
|
||||
realloc() <a href="2.13.html#realloc">stdlib.h</a><br>
|
||||
register <a href="1.2.html#variables">Identifiers</a><br>
|
||||
remove() <a href="2.12.html#remove">stdio.h</a><br>
|
||||
rename() <a href="2.12.html#rename">stdio.h</a><br>
|
||||
return <a href="1.6.html#return">Statements</a><br>
|
||||
rewind() <a href="2.12.html#rewind">stdio.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="s"></a>
|
||||
|
||||
scanf() <a href="2.12.html#scanf">stdio.h</a><br>
|
||||
scope <a href="1.2.html#variables">Identifiers</a><br>
|
||||
SEEK_CUR <a href="2.12.html#variables">stdio.h</a><br>
|
||||
SEEK_END <a href="2.12.html#variables">stdio.h</a><br>
|
||||
SEEK_SET <a href="2.12.html#variables">stdio.h</a><br>
|
||||
setbuf() <a href="2.12.html#setbuf">stdio.h</a><br>
|
||||
setjmp() <a href="2.8.html#setjmp">setjmp.h</a><br>
|
||||
setlocale() <a href="2.6.html#setlocale">locale.h</a><br>
|
||||
setvbuf() <a href="2.12.html#setvbuf">stdio.h</a><br>
|
||||
short <a href="1.2.html#variables">Identifiers</a><br>
|
||||
sig_atomic_t <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIG_DFL <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIG_ERR <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIG_IGN <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIGABRT <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIGFPE <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIGILL <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIGINT <a href="2.9.html#variables">signal.h</a><br>
|
||||
signed <a href="1.2.html#variables">Identifiers</a><br>
|
||||
SIGSEGV <a href="2.9.html#variables">signal.h</a><br>
|
||||
SIGTERM <a href="2.9.html#variables">signal.h</a><br>
|
||||
signal() <a href="2.9.html#signal">signal.h</a><br>
|
||||
sin() <a href="2.7.html#sin">math.h</a><br>
|
||||
sinh() <a href="2.7.html#sinh">math.h</a><br>
|
||||
size_t <a href="2.15.html#variables">time.h</a> <a href="2.14.html#variables">string.h</a>
|
||||
<a href="2.13.html#variables">stdlib.h</a>
|
||||
<a href="2.12.html#variables">stdio.h</a>
|
||||
<a href="2.11.html#variables">stddef.h</a>
|
||||
<br>
|
||||
sizeof <a href="1.2.html#sizeof">Identifiers</a><br>
|
||||
sprintf() <a href="2.12.html#sprintf">stdio.h</a><br>
|
||||
sqrt() <a href="2.7.html#sqrt">math.h</a><br>
|
||||
srand() <a href="2.13.html#srand">stdlib.h</a><br>
|
||||
sscanf() <a href="2.12.html#sscanf">stdio.h</a><br>
|
||||
static <a href="1.2.html#variables">Identifiers</a><br>
|
||||
stderr <a href="2.12.html#variables">stdio.h</a><br>
|
||||
stdin <a href="2.12.html#variables">stdio.h</a><br>
|
||||
stdout <a href="2.12.html#variables">stdio.h</a><br>
|
||||
strcat() <a href="2.14.html#strcat">string.h</a><br>
|
||||
strncat() <a href="2.14.html#strncat">string.h</a><br>
|
||||
strchr() <a href="2.14.html#strchr">string.h</a><br>
|
||||
strcmp() <a href="2.14.html#strcmp">string.h</a><br>
|
||||
strncmp() <a href="2.14.html#strncmp">string.h</a><br>
|
||||
strcoll() <a href="2.14.html#strcoll">string.h</a><br>
|
||||
strcpy() <a href="2.14.html#strcpy">string.h</a><br>
|
||||
strncpy() <a href="2.14.html#strncpy">string.h</a><br>
|
||||
strcspn() <a href="2.14.html#strcspn">string.h</a><br>
|
||||
strerror() <a href="2.14.html#strerror">string.h</a><br>
|
||||
strftime() <a href="2.15.html#strftime">time.h</a><br>
|
||||
strlen() <a href="2.14.html#strlen">string.h</a><br>
|
||||
strpbrk() <a href="2.14.html#strpbrk">string.h</a><br>
|
||||
strrchr() <a href="2.14.html#strrchr">string.h</a><br>
|
||||
strspn() <a href="2.14.html#strspn">string.h</a><br>
|
||||
strstr() <a href="2.14.html#strstr">string.h</a><br>
|
||||
strtod() <a href="2.13.html#strtod">stdlib.h</a><br>
|
||||
strtok() <a href="2.14.html#strtok">string.h</a><br>
|
||||
strtol() <a href="2.13.html#strtol">stdlib.h</a><br>
|
||||
strtoul() <a href="2.13.html#strtoul">stdlib.h</a><br>
|
||||
struct <a href="1.2.html#struct">Indentifiers</a><br>
|
||||
strxfrm() <a href="2.14.html#strxfrm">string.h</a><br>
|
||||
switch <a href="1.6.html#switch">Statements</a><br>
|
||||
system() <a href="2.13.html#system">stdlib.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="t"></a>
|
||||
|
||||
tan() <a href="2.7.html#tan">math.h</a><br>
|
||||
tanh() <a href="2.7.html#tanh">math.h</a><br>
|
||||
time() <a href="2.15.html#time">time.h</a><br>
|
||||
tm <a href="2.15.html#variables">time.h</a><br>
|
||||
TMP_MAX <a href="2.12.html#variables">stdio.h</a><br>
|
||||
tmpfile() <a href="2.12.html#tmpfile">stdio.h</a><br>
|
||||
tmpnam() <a href="2.12.html#tmpnam">stdio.h</a><br>
|
||||
tolower() <a href="2.2.html#to">ctype.h</a><br>
|
||||
toupper() <a href="2.2.html#to">ctype.h</a><br>
|
||||
typedef <a href="1.2.html#variables">Identifiers</a><br>
|
||||
<p>
|
||||
<a name="u"></a>
|
||||
|
||||
ungetc() <a href="2.12.html#ungetc">stdio.h</a><br>
|
||||
unions <a href="1.2.html#struct">Identifiers</a><br>
|
||||
<p>
|
||||
<a name="v"></a>
|
||||
|
||||
va_arg() <a href="2.10.html#va_arg">stdarg.h</a><br>
|
||||
va_end() <a href="2.10.html#va_end">stdarg.h</a><br>
|
||||
va_list <a href="2.10.html#variables">stdarg.h</a><br>
|
||||
va_start() <a href="2.10.html#va_start">stdarg.h</a><br>
|
||||
vfprintf() <a href="2.12.html#vfprintf">stdio.h</a><br>
|
||||
void <a href="1.2.html#variables">Identifiers</a><br>
|
||||
vprintf() <a href="2.12.html#vprintf">stdio.h</a><br>
|
||||
vsprintf() <a href="2.12.html#vsprintf">stdio.h</a><br>
|
||||
|
||||
<p>
|
||||
<a name="w"></a>
|
||||
|
||||
wcstombs() <a href="2.13.html#wcstombs">stdlib.h</a><br>
|
||||
wctomb() <a href="2.13.html#wctomb">stdlib.h</a><br>
|
||||
wchar_t <a href="2.13.html#variables">stdlib.h</a>
|
||||
<a href="2.11.html#variables">stddef.h</a>
|
||||
<br>
|
||||
while <a href="1.6.html#while">Statements</a><br>
|
||||
</body>
|
||||
</html>
|
||||
33
Ref-docs/c_lib_guide/introduction.html
Normal file
33
Ref-docs/c_lib_guide/introduction.html
Normal file
@@ -0,0 +1,33 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
The C Library Reference Guide Introduction
|
||||
</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF">
|
||||
<center>
|
||||
<h1>Introduction</h1>
|
||||
</center>
|
||||
<p>
|
||||
Welcome to the C Library Reference Guide. This guide provides a useful look at the
|
||||
standard C programming language. In no way does this guide attempt to teach one how to
|
||||
program in C, nor will it attempt to provide the history of C or the various implementations of it.
|
||||
It is merely a handy reference to the standard C library. This guide is not a definitive look at the
|
||||
entire ANSI C standard. Some outdated information has been left out. It is simply a quick
|
||||
reference to the functions and syntax of the language. All efforts have been taken to make sure
|
||||
the information contained herein is correct, but no guarantees are made. Nearly all of the
|
||||
information was obtained from the official ANSI C Standard published in 1989 in the document
|
||||
ANSI X3.159-1989. The associated International Organization for Standardization document,
|
||||
ISO 9899-1990, is a near duplicate of the ANSI standard.
|
||||
<p>
|
||||
This guide is divided into two sections. The first part, "Language", is an analysis of the
|
||||
syntax and the environment. The second part, "Library", is a list of the functions available in the
|
||||
standard C library. These parts were designed to insure conformity among various
|
||||
implementations of the C language. Not all information from the ANSI standard is contained in
|
||||
this guide. Additional reference may be made to the actual ANSI publication.
|
||||
<hr>
|
||||
<center>
|
||||
<a href="index.html">Return to the Index</a>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
BIN
Ref-docs/c_lib_guide/left.gif
Normal file
BIN
Ref-docs/c_lib_guide/left.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 965 B |
BIN
Ref-docs/c_lib_guide/right.gif
Normal file
BIN
Ref-docs/c_lib_guide/right.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 962 B |
9
Ref-docs/c_lib_guide/template.html
Normal file
9
Ref-docs/c_lib_guide/template.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
C Guide--x.x blah
|
||||
</title>
|
||||
</head>
|
||||
<body text="#000000" bgcolor="#FFFFFF">
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user