[<a name="p48" href="#p48">page 48</a>] (<a href="#Contents">Contents</a>)
<a name="6.4" href="#6.4"><b> 6.4 Lexical elements</b></a>
- Syntax
+<b> Syntax</b>
1 token:
keyword
identifier
string-literal
punctuator
each non-white-space character that cannot be one of the above
- Constraints
+<b> Constraints</b>
2 Each preprocessing token that is converted to a token shall have the lexical form of a
keyword, an identifier, a constant, a string literal, or a punctuator.
- Semantics
+<b> Semantics</b>
3 A token is the minimal lexical element of the language in translation phases 7 and 8. The
categories of tokens are: keywords, identifiers, constants, string literals, and punctuators.
A preprocessing token is the minimal lexical element of the language in translation
(<a href="#6.5.3.1">6.5.3.1</a>), preprocessing directives (<a href="#6.10">6.10</a>), preprocessing numbers (<a href="#6.4.8">6.4.8</a>), string literals
(<a href="#6.4.5">6.4.5</a>).
<a name="6.4.1" href="#6.4.1"><b> 6.4.1 Keywords</b></a>
- Syntax
+<b> Syntax</b>
1 keyword: one of
auto enum restrict unsigned
break extern return void
do int switch
double long typedef
else register union
- Semantics
+<b> Semantics</b>
2 The above tokens (case sensitive) are reserved (in translation phases 7 and 8) for use as
keywords, and shall not be used otherwise. The keyword _Imaginary is reserved for
specifying imaginary types.59)
<a name="6.4.2" href="#6.4.2"><b> 6.4.2 Identifiers</b></a>
<a name="6.4.2.1" href="#6.4.2.1"><b> 6.4.2.1 General</b></a>
- Syntax
+<b> Syntax</b>
1 identifier:
identifier-nondigit
identifier identifier-nondigit
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
- Semantics
+<b> Semantics</b>
2 An identifier is a sequence of nondigit characters (including the underscore _, the
lowercase and uppercase Latin letters, and other characters) and digits, which designates
one or more entities as described in <a href="#6.2.1">6.2.1</a>. Lowercase and uppercase letters are distinct.
identifiers differ only in nonsignificant characters, the behavior is undefined.
Forward references: universal character names (<a href="#6.4.3">6.4.3</a>), macro replacement (<a href="#6.10.3">6.10.3</a>).
<a name="6.4.2.2" href="#6.4.2.2"><b> 6.4.2.2 Predefined identifiers</b></a>
- Semantics
+<b> Semantics</b>
1 The identifier __func__ shall be implicitly declared by the translator as if,
immediately following the opening brace of each function definition, the declaration
static const char __func__[] = "function-name";
[<a name="p52" href="#p52">page 52</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.3" href="#6.4.3"><b> 6.4.3 Universal character names</b></a>
- Syntax
+<b> Syntax</b>
1 universal-character-name:
\u hex-quad
\U hex-quad hex-quad
hex-quad:
hexadecimal-digit hexadecimal-digit
hexadecimal-digit hexadecimal-digit
- Constraints
+<b> Constraints</b>
2 A universal character name shall not specify a character whose short identifier is less than
00A0 other than 0024 ($), 0040 (@), or 0060 ('), nor one in the range D800 through
DFFF inclusive.62)
- Description
+<b> Description</b>
3 Universal character names may be used in identifiers, character constants, and string
literals to designate characters that are not in the basic character set.
- Semantics
+<b> Semantics</b>
4 The universal character name \Unnnnnnnn designates the character whose eight-digit
short identifier (as specified by ISO/IEC 10646) is nnnnnnnn.63) Similarly, the universal
character name \unnnn designates the character whose four-digit short identifier is nnnn
[<a name="p53" href="#p53">page 53</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.4" href="#6.4.4"><b> 6.4.4 Constants</b></a>
- Syntax
+<b> Syntax</b>
1 constant:
integer-constant
floating-constant
enumeration-constant
character-constant
- Constraints
+<b> Constraints</b>
2 Each constant shall have a type and the value of a constant shall be in the range of
representable values for its type.
- Semantics
+<b> Semantics</b>
3 Each constant has a type, determined by its form and value, as detailed later.
<a name="6.4.4.1" href="#6.4.4.1"><b> 6.4.4.1 Integer constants</b></a>
- Syntax
+<b> Syntax</b>
1 integer-constant:
decimal-constant integer-suffixopt
octal-constant integer-suffixopt
l L
long-long-suffix: one of
ll LL
- Description
+<b> Description</b>
2 An integer constant begins with a digit, but has no period or exponent part. It may have a
prefix that specifies its base and a suffix that specifies its type.
3 A decimal constant begins with a nonzero digit and consists of a sequence of decimal
digits 0 through 7 only. A hexadecimal constant consists of the prefix 0x or 0X followed
by a sequence of the decimal digits and the letters a (or A) through f (or F) with values
10 through 15 respectively.
- Semantics
+<b> Semantics</b>
4 The value of a decimal constant is computed base 10; that of an octal constant, base 8;
that of a hexadecimal constant, base 16. The lexically first digit is the most significant.
5 The type of an integer constant is the first of the corresponding list in which its value can
[<a name="p56" href="#p56">page 56</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.4.2" href="#6.4.4.2"><b> 6.4.4.2 Floating constants</b></a>
- Syntax
+<b> Syntax</b>
1 floating-constant:
decimal-floating-constant
hexadecimal-floating-constant
[<a name="p57" href="#p57">page 57</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 A floating constant has a significand part that may be followed by an exponent part and a
suffix that specifies its type. The components of the significand part may include a digit
sequence representing the whole-number part, followed by a period (.), followed by a
e, E, p, or P followed by an exponent consisting of an optionally signed digit sequence.
Either the whole-number part or the fraction part has to be present; for decimal floating
constants, either the period or the exponent part has to be present.
- Semantics
+<b> Semantics</b>
3 The significand part is interpreted as a (decimal or hexadecimal) rational number; the
digit sequence in the exponent part is interpreted as a decimal integer. For decimal
floating constants, the exponent indicates the power of 10 by which the significand part is
[<a name="p58" href="#p58">page 58</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.4.3" href="#6.4.4.3"><b> 6.4.4.3 Enumeration constants</b></a>
- Syntax
+<b> Syntax</b>
1 enumeration-constant:
identifier
- Semantics
+<b> Semantics</b>
2 An identifier declared as an enumeration constant has type int.
Forward references: enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>).
<a name="6.4.4.4" href="#6.4.4.4"><b> 6.4.4.4 Character constants</b></a>
- Syntax
+<b> Syntax</b>
1 character-constant:
' c-char-sequence '
L' c-char-sequence '
[<a name="p59" href="#p59">page 59</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 An integer character constant is a sequence of one or more multibyte characters enclosed
in single-quotes, as in 'x'. A wide character constant is the same, except prefixed by the
letter L. With a few exceptions detailed later, the elements of the sequence are any
[<a name="p60" href="#p60">page 60</a>] (<a href="#Contents">Contents</a>)
- Constraints
+<b> Constraints</b>
9 The value of an octal or hexadecimal escape sequence shall be in the range of
representable values for the type unsigned char for an integer character constant, or
the unsigned type corresponding to wchar_t for a wide character constant.
- Semantics
+<b> Semantics</b>
10 An integer character constant has type int. The value of an integer character constant
containing a single character that maps to a single-byte execution character is the
numerical value of the representation of the mapped character interpreted as an integer.
[<a name="p61" href="#p61">page 61</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.5" href="#6.4.5"><b> 6.4.5 String literals</b></a>
- Syntax
+<b> Syntax</b>
1 string-literal:
" s-char-sequenceopt "
L" s-char-sequenceopt "
any member of the source character set except
the double-quote ", backslash \, or new-line character
escape-sequence
- Description
+<b> Description</b>
2 A character string literal is a sequence of zero or more multibyte characters enclosed in
double-quotes, as in "xyz". A wide string literal is the same, except prefixed by the
letter L.
character constant, except that the single-quote ' is representable either by itself or by the
escape sequence \', but the double-quote " shall be represented by the escape sequence
\".
- Semantics
+<b> Semantics</b>
4 In translation phase 6, the multibyte character sequences specified by any sequence of
adjacent character and wide string literal tokens are concatenated into a single multibyte
character sequence. If any of the tokens are wide string literal tokens, the resulting
Forward references: common definitions <a href="#7.17"><stddef.h></a> (<a href="#7.17">7.17</a>), the mbstowcs
function (<a href="#7.20.8.1">7.20.8.1</a>).
<a name="6.4.6" href="#6.4.6"><b> 6.4.6 Punctuators</b></a>
- Syntax
+<b> Syntax</b>
1 punctuator: one of
[ ] ( ) { } . ->
++ -- & * + - ~ !
= *= /= %= += -= <<= >>= &= ^= |=
, # ##
<: :> <% %> %: %:%:
- Semantics
+<b> Semantics</b>
2 A punctuator is a symbol that has independent syntactic and semantic significance.
Depending on context, it may specify an operation to be performed (which in turn may
yield a value or a function designator, produce a side effect, or some combination thereof)
Forward references: expressions (<a href="#6.5">6.5</a>), declarations (<a href="#6.7">6.7</a>), preprocessing directives
(<a href="#6.10">6.10</a>), statements (<a href="#6.8">6.8</a>).
<a name="6.4.7" href="#6.4.7"><b> 6.4.7 Header names</b></a>
- Syntax
+<b> Syntax</b>
1 header-name:
< h-char-sequence >
" q-char-sequence "
q-char:
any member of the source character set except
the new-line character and "
- Semantics
+<b> Semantics</b>
2 The sequences in both forms of header names are mapped in an implementation-defined
manner to headers or external source file names as specified in <a href="#6.10.2">6.10.2</a>.
3 If the characters ', \, ", //, or /* occur in the sequence between the < and > delimiters,
Forward references: source file inclusion (<a href="#6.10.2">6.10.2</a>).
<a name="6.4.8" href="#6.4.8"><b> 6.4.8 Preprocessing numbers</b></a>
- Syntax
+<b> Syntax</b>
1 pp-number:
digit
. digit
pp-number p sign
pp-number P sign
pp-number .
- Description
+<b> Description</b>
2 A preprocessing number begins with a digit optionally preceded by a period (.) and may
be followed by valid identifier characters and the character sequences e+, e-, E+, E-,
p+, p-, P+, or P-.
3 Preprocessing number tokens lexically include all floating and integer constant tokens.
- Semantics
+<b> Semantics</b>
4 A preprocessing number does not have type or a value; it acquires both after a successful
conversion (as part of translation phase 7) to a floating constant token or an integer
constant token.
[<a name="p68" href="#p68">page 68</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.1" href="#6.5.1"><b> 6.5.1 Primary expressions</b></a>
- Syntax
+<b> Syntax</b>
1 primary-expression:
identifier
constant
string-literal
( expression )
- Semantics
+<b> Semantics</b>
2 An identifier is a primary expression, provided it has been declared as designating an
object (in which case it is an lvalue) or a function (in which case it is a function
designator).79)
designator, or a void expression.
Forward references: declarations (<a href="#6.7">6.7</a>).
<a name="6.5.2" href="#6.5.2"><b> 6.5.2 Postfix operators</b></a>
- Syntax
+<b> Syntax</b>
1 postfix-expression:
primary-expression
postfix-expression [ expression ]
assignment-expression
argument-expression-list , assignment-expression
<a name="6.5.2.1" href="#6.5.2.1"><b> 6.5.2.1 Array subscripting</b></a>
- Constraints
+<b> Constraints</b>
1 One of the expressions shall have type ''pointer to object type'', the other expression shall
have integer type, and the result has type ''type''.
- Semantics
+<b> Semantics</b>
2 A postfix expression followed by an expression in square brackets [] is a subscripted
designation of an element of an array object. The definition of the subscript operator []
is that E1[E2] is identical to (*((E1)+(E2))). Because of the conversion rules that
[<a name="p70" href="#p70">page 70</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.2.2" href="#6.5.2.2"><b> 6.5.2.2 Function calls</b></a>
- Constraints
+<b> Constraints</b>
1 The expression that denotes the called function80) shall have type pointer to function
returning void or returning an object type other than an array type.
2 If the expression that denotes the called function has a type that includes a prototype, the
number of arguments shall agree with the number of parameters. Each argument shall
have a type such that its value may be assigned to an object with the unqualified version
of the type of its corresponding parameter.
- Semantics
+<b> Semantics</b>
3 A postfix expression followed by parentheses () containing a possibly empty, comma-
separated list of expressions is a function call. The postfix expression denotes the called
function. The list of expressions specifies the arguments to the function.
Forward references: function declarators (including prototypes) (<a href="#6.7.5.3">6.7.5.3</a>), function
definitions (<a href="#6.9.1">6.9.1</a>), the return statement (<a href="#6.8.6.4">6.8.6.4</a>), simple assignment (<a href="#6.5.16.1">6.5.16.1</a>).
<a name="6.5.2.3" href="#6.5.2.3"><b> 6.5.2.3 Structure and union members</b></a>
- Constraints
+<b> Constraints</b>
1 The first operand of the . operator shall have a qualified or unqualified structure or union
type, and the second operand shall name a member of that type.
2 The first operand of the -> operator shall have type ''pointer to qualified or unqualified
[<a name="p72" href="#p72">page 72</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
3 A postfix expression followed by the . operator and an identifier designates a member of
a structure or union object. The value is that of the named member,82) and is an lvalue if
the first expression is an lvalue. If the first expression has qualified type, the result has
[<a name="p74" href="#p74">page 74</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.2.4" href="#6.5.2.4"><b> 6.5.2.4 Postfix increment and decrement operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the postfix increment or decrement operator shall have qualified or
unqualified real or pointer type and shall be a modifiable lvalue.
- Semantics
+<b> Semantics</b>
2 The result of the postfix ++ operator is the value of the operand. After the result is
obtained, the value of the operand is incremented. (That is, the value 1 of the appropriate
type is added to it.) See the discussions of additive operators and compound assignment
it).
Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), compound assignment (<a href="#6.5.16.2">6.5.16.2</a>).
<a name="6.5.2.5" href="#6.5.2.5"><b> 6.5.2.5 Compound literals</b></a>
- Constraints
+<b> Constraints</b>
1 The type name shall specify an object type or an array of unknown size, but not a variable
length array type.
2 No initializer shall attempt to provide a value for an object not contained within the entire
unnamed object specified by the compound literal.
3 If the compound literal occurs outside the body of a function, the initializer list shall
consist of constant expressions.
- Semantics
+<b> Semantics</b>
4 A postfix expression that consists of a parenthesized type name followed by a brace-
enclosed list of initializers is a compound literal. It provides an unnamed object whose
value is given by the initializer list.84)
[<a name="p77" href="#p77">page 77</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.3" href="#6.5.3"><b> 6.5.3 Unary operators</b></a>
- Syntax
+<b> Syntax</b>
1 unary-expression:
postfix-expression
++ unary-expression
unary-operator: one of
& * + - ~ !
<a name="6.5.3.1" href="#6.5.3.1"><b> 6.5.3.1 Prefix increment and decrement operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the prefix increment or decrement operator shall have qualified or
unqualified real or pointer type and shall be a modifiable lvalue.
- Semantics
+<b> Semantics</b>
2 The value of the operand of the prefix ++ operator is incremented. The result is the new
value of the operand after incrementation. The expression ++E is equivalent to (E+=1).
See the discussions of additive operators and compound assignment for information on
operand is decremented.
Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), compound assignment (<a href="#6.5.16.2">6.5.16.2</a>).
<a name="6.5.3.2" href="#6.5.3.2"><b> 6.5.3.2 Address and indirection operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the unary & operator shall be either a function designator, the result of a
[] or unary * operator, or an lvalue that designates an object that is not a bit-field and is
not declared with the register storage-class specifier.
2 The operand of the unary * operator shall have pointer type.
- Semantics
+<b> Semantics</b>
3 The unary & operator yields the address of its operand. If the operand has type ''type'',
the result has type ''pointer to type''. If the operand is the result of a unary * operator,
neither that operator nor the & operator is evaluated and the result is as if both were
Forward references: storage-class specifiers (<a href="#6.7.1">6.7.1</a>), structure and union specifiers
(<a href="#6.7.2.1">6.7.2.1</a>).
<a name="6.5.3.3" href="#6.5.3.3"><b> 6.5.3.3 Unary arithmetic operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the unary + or - operator shall have arithmetic type; of the ~ operator,
integer type; of the ! operator, scalar type.
- Semantics
+<b> Semantics</b>
2 The result of the unary + operator is the value of its (promoted) operand. The integer
promotions are performed on the operand, and the result has the promoted type.
3 The result of the unary - operator is the negative of its (promoted) operand. The integer
[<a name="p79" href="#p79">page 79</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.3.4" href="#6.5.3.4"><b> 6.5.3.4 The sizeof operator</b></a>
- Constraints
+<b> Constraints</b>
1 The sizeof operator shall not be applied to an expression that has function type or an
incomplete type, to the parenthesized name of such a type, or to an expression that
designates a bit-field member.
- Semantics
+<b> Semantics</b>
2 The sizeof operator yields the size (in bytes) of its operand, which may be an
expression or the parenthesized name of a type. The size is determined from the type of
the operand. The result is an integer. If the type of the operand is a variable length array
Forward references: common definitions <a href="#7.17"><stddef.h></a> (<a href="#7.17">7.17</a>), declarations (<a href="#6.7">6.7</a>),
structure and union specifiers (<a href="#6.7.2.1">6.7.2.1</a>), type names (<a href="#6.7.6">6.7.6</a>), array declarators (<a href="#6.7.5.2">6.7.5.2</a>).
<a name="6.5.4" href="#6.5.4"><b> 6.5.4 Cast operators</b></a>
- Syntax
+<b> Syntax</b>
1 cast-expression:
unary-expression
( type-name ) cast-expression
- Constraints
+<b> Constraints</b>
2 Unless the type name specifies a void type, the type name shall specify qualified or
unqualified scalar type and the operand shall have scalar type.
3 Conversions that involve pointers, other than where permitted by the constraints of
<a href="#6.5.16.1">6.5.16.1</a>, shall be specified by means of an explicit cast.
- Semantics
+<b> Semantics</b>
4 Preceding an expression by a parenthesized type name converts the value of the
expression to the named type. This construction is called a cast.89) A cast that specifies
no conversion has no effect on the type or value of an expression.
[<a name="p81" href="#p81">page 81</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.5" href="#6.5.5"><b> 6.5.5 Multiplicative operators</b></a>
- Syntax
+<b> Syntax</b>
1 multiplicative-expression:
cast-expression
multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
multiplicative-expression % cast-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have arithmetic type. The operands of the % operator shall
have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the binary * operator is the product of the operands.
5 The result of the / operator is the quotient from the division of the first operand by the
fractional part discarded.90) If the quotient a/b is representable, the expression
(a/b)*b + a%b shall equal a.
<a name="6.5.6" href="#6.5.6"><b> 6.5.6 Additive operators</b></a>
- Syntax
+<b> Syntax</b>
1 additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
- Constraints
+<b> Constraints</b>
2 For addition, either both operands shall have arithmetic type, or one operand shall be a
pointer to an object type and the other shall have integer type. (Incrementing is
equivalent to adding 1.)
types; or
-- the left operand is a pointer to an object type and the right operand has integer type.
(Decrementing is equivalent to subtracting 1.)
- Semantics
+<b> Semantics</b>
4 If both operands have arithmetic type, the usual arithmetic conversions are performed on
them.
5 The result of the binary + operator is the sum of the operands.
Forward references: array declarators (<a href="#6.7.5.2">6.7.5.2</a>), common definitions <a href="#7.17"><stddef.h></a>
(<a href="#7.17">7.17</a>).
<a name="6.5.7" href="#6.5.7"><b> 6.5.7 Bitwise shift operators</b></a>
- Syntax
+<b> Syntax</b>
1 shift-expression:
additive-expression
shift-expression << additive-expression
shift-expression >> additive-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The integer promotions are performed on each of the operands. The type of the result is
that of the promoted left operand. If the value of the right operand is negative or is
greater than or equal to the width of the promoted left operand, the behavior is undefined.
part of the quotient of E1 / 2E2 . If E1 has a signed type and a negative value, the
resulting value is implementation-defined.
<a name="6.5.8" href="#6.5.8"><b> 6.5.8 Relational operators</b></a>
- Syntax
+<b> Syntax</b>
1 relational-expression:
shift-expression
relational-expression < shift-expression
relational-expression > shift-expression
relational-expression <= shift-expression
relational-expression >= shift-expression
- Constraints
+<b> Constraints</b>
2 One of the following shall hold:
-- both operands have real type;
-- both operands are pointers to qualified or unqualified versions of compatible object
types; or
-- both operands are pointers to qualified or unqualified versions of compatible
incomplete types.
- Semantics
+<b> Semantics</b>
3 If both of the operands have arithmetic type, the usual arithmetic conversions are
performed.
4 For the purposes of these operators, a pointer to an object that is not an element of an
(greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is false.92)
The result has type int.
<a name="6.5.9" href="#6.5.9"><b> 6.5.9 Equality operators</b></a>
- Syntax
+<b> Syntax</b>
1 equality-expression:
relational-expression
equality-expression == relational-expression
equality-expression != relational-expression
- Constraints
+<b> Constraints</b>
2 One of the following shall hold:
-- both operands have arithmetic type;
-- both operands are pointers to qualified or unqualified versions of compatible types;
-- one operand is a pointer to an object or incomplete type and the other is a pointer to a
qualified or unqualified version of void; or
-- one operand is a pointer and the other is a null pointer constant.
- Semantics
+<b> Semantics</b>
3 The == (equal to) and != (not equal to) operators are analogous to the relational
operators except for their lower precedence.93) Each of the operators yields 1 if the
specified relation is true and 0 if it is false. The result has type int. For any pair of
array behaves the same as a pointer to the first element of an array of length one with the
type of the object as its element type.
<a name="6.5.10" href="#6.5.10"><b> 6.5.10 Bitwise AND operator</b></a>
- Syntax
+<b> Syntax</b>
1 AND-expression:
equality-expression
AND-expression & equality-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the binary & operator is the bitwise AND of the operands (that is, each bit in
the result is set if and only if each of the corresponding bits in the converted operands is
[<a name="p87" href="#p87">page 87</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.11" href="#6.5.11"><b> 6.5.11 Bitwise exclusive OR operator</b></a>
- Syntax
+<b> Syntax</b>
1 exclusive-OR-expression:
AND-expression
exclusive-OR-expression ^ AND-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the ^ operator is the bitwise exclusive OR of the operands (that is, each bit
in the result is set if and only if exactly one of the corresponding bits in the converted
operands is set).
<a name="6.5.12" href="#6.5.12"><b> 6.5.12 Bitwise inclusive OR operator</b></a>
- Syntax
+<b> Syntax</b>
1 inclusive-OR-expression:
exclusive-OR-expression
inclusive-OR-expression | exclusive-OR-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the | operator is the bitwise inclusive OR of the operands (that is, each bit in
the result is set if and only if at least one of the corresponding bits in the converted
[<a name="p88" href="#p88">page 88</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.13" href="#6.5.13"><b> 6.5.13 Logical AND operator</b></a>
- Syntax
+<b> Syntax</b>
1 logical-AND-expression:
inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have scalar type.
- Semantics
+<b> Semantics</b>
3 The && operator shall yield 1 if both of its operands compare unequal to 0; otherwise, it
yields 0. The result has type int.
4 Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation;
there is a sequence point after the evaluation of the first operand. If the first operand
compares equal to 0, the second operand is not evaluated.
<a name="6.5.14" href="#6.5.14"><b> 6.5.14 Logical OR operator</b></a>
- Syntax
+<b> Syntax</b>
1 logical-OR-expression:
logical-AND-expression
logical-OR-expression || logical-AND-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have scalar type.
- Semantics
+<b> Semantics</b>
3 The || operator shall yield 1 if either of its operands compare unequal to 0; otherwise, it
yields 0. The result has type int.
4 Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; there is
[<a name="p89" href="#p89">page 89</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.15" href="#6.5.15"><b> 6.5.15 Conditional operator</b></a>
- Syntax
+<b> Syntax</b>
1 conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
- Constraints
+<b> Constraints</b>
2 The first operand shall have scalar type.
3 One of the following shall hold for the second and third operands:
-- both operands have arithmetic type;
-- one operand is a pointer and the other is a null pointer constant; or
-- one operand is a pointer to an object or incomplete type and the other is a pointer to a
qualified or unqualified version of void.
- Semantics
+<b> Semantics</b>
4 The first operand is evaluated; there is a sequence point after its evaluation. The second
operand is evaluated only if the first compares unequal to 0; the third operand is evaluated
only if the first compares equal to 0; the result is the value of the second or third operand
vp ip void *
<a name="6.5.16" href="#6.5.16"><b> 6.5.16 Assignment operators</b></a>
- Syntax
+<b> Syntax</b>
1 assignment-expression:
conditional-expression
unary-expression assignment-operator assignment-expression
assignment-operator: one of
= *= /= %= += -= <<= >>= &= ^= |=
- Constraints
+<b> Constraints</b>
2 An assignment operator shall have a modifiable lvalue as its left operand.
- Semantics
+<b> Semantics</b>
3 An assignment operator stores a value in the object designated by the left operand. An
assignment expression has the value of the left operand after the assignment, but is not an
lvalue. The type of an assignment expression is the type of the left operand unless the
[<a name="p91" href="#p91">page 91</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.16.1" href="#6.5.16.1"><b> 6.5.16.1 Simple assignment</b></a>
- Constraints
+<b> Constraints</b>
1 One of the following shall hold:96)
-- the left operand has qualified or unqualified arithmetic type and the right has
arithmetic type;
the qualifiers of the type pointed to by the right;
-- the left operand is a pointer and the right is a null pointer constant; or
-- the left operand has type _Bool and the right is a pointer.
- Semantics
+<b> Semantics</b>
2 In simple assignment (=), the value of the right operand is converted to the type of the
assignment expression and replaces the value stored in the object designated by the left
operand.
value of the const object c.
<a name="6.5.16.2" href="#6.5.16.2"><b> 6.5.16.2 Compound assignment</b></a>
- Constraints
+<b> Constraints</b>
1 For the operators += and -= only, either the left operand shall be a pointer to an object
type and the right shall have integer type, or the left operand shall have qualified or
unqualified arithmetic type and the right shall have arithmetic type.
2 For the other operators, each operand shall have arithmetic type consistent with those
allowed by the corresponding binary operator.
- Semantics
+<b> Semantics</b>
3 A compound assignment of the form E1 op = E2 differs from the simple assignment
expression E1 = E1 op (E2) only in that the lvalue E1 is evaluated only once.
[<a name="p93" href="#p93">page 93</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.17" href="#6.5.17"><b> 6.5.17 Comma operator</b></a>
- Syntax
+<b> Syntax</b>
1 expression:
assignment-expression
expression , assignment-expression
- Semantics
+<b> Semantics</b>
2 The left operand of a comma operator is evaluated as a void expression; there is a
sequence point after its evaluation. Then the right operand is evaluated; the result has its
type and value.97) If an attempt is made to modify the result of a comma operator or to
[<a name="p94" href="#p94">page 94</a>] (<a href="#Contents">Contents</a>)
<a name="6.6" href="#6.6"><b> 6.6 Constant expressions</b></a>
- Syntax
+<b> Syntax</b>
1 constant-expression:
conditional-expression
- Description
+<b> Description</b>
2 A constant expression can be evaluated during translation rather than runtime, and
accordingly may be used in any place that a constant may be.
- Constraints
+<b> Constraints</b>
3 Constant expressions shall not contain assignment, increment, decrement, function-call,
or comma operators, except when they are contained within a subexpression that is not
evaluated.98)
4 Each constant expression shall evaluate to a constant that is in the range of representable
values for its type.
- Semantics
+<b> Semantics</b>
5 An expression that evaluates to a constant is required in several contexts. If a floating
expression is evaluated in the translation environment, the arithmetic precision and range
shall be at least as great as if the expression were being evaluated in the execution
[<a name="p96" href="#p96">page 96</a>] (<a href="#Contents">Contents</a>)
<a name="6.7" href="#6.7"><b> 6.7 Declarations</b></a>
- Syntax
+<b> Syntax</b>
1 declaration:
declaration-specifiers init-declarator-listopt ;
declaration-specifiers:
init-declarator:
declarator
declarator = initializer
- Constraints
+<b> Constraints</b>
2 A declaration shall declare at least a declarator (other than the parameters of a function or
the members of a structure or union), a tag, or the members of an enumeration.
3 If an identifier has no linkage, there shall be no more than one declaration of the identifier
for tags as specified in <a href="#6.7.2.3">6.7.2.3</a>.
4 All declarations in the same scope that refer to the same object or function shall specify
compatible types.
- Semantics
+<b> Semantics</b>
5 A declaration specifies the interpretation and attributes of a set of identifiers. A definition
of an identifier is a declaration for that identifier that:
-- for an object, causes storage to be reserved for that object;
Forward references: declarators (<a href="#6.7.5">6.7.5</a>), enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>), initialization
(<a href="#6.7.8">6.7.8</a>).
<a name="6.7.1" href="#6.7.1"><b> 6.7.1 Storage-class specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 storage-class-specifier:
typedef
extern
static
auto
register
- Constraints
+<b> Constraints</b>
2 At most, one storage-class specifier may be given in the declaration specifiers in a
declaration.102)
- Semantics
+<b> Semantics</b>
3 The typedef specifier is called a ''storage-class specifier'' for syntactic convenience
only; it is discussed in <a href="#6.7.7">6.7.7</a>. The meanings of the various linkages and storage durations
were discussed in <a href="#6.2.2">6.2.2</a> and <a href="#6.2.4">6.2.4</a>.
or union member objects.
Forward references: type definitions (<a href="#6.7.7">6.7.7</a>).
<a name="6.7.2" href="#6.7.2"><b> 6.7.2 Type specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 type-specifier:
void
char
struct-or-union-specifier *
enum-specifier
typedef-name
- Constraints
+<b> Constraints</b>
2 At least one type specifier shall be given in the declaration specifiers in each declaration,
and in the specifier-qualifier list in each struct declaration and type name. Each list of
type specifiers shall be one of the following sets (delimited by commas, when there is
-- typedef name
3 The type specifier _Complex shall not be used if the implementation does not provide
complex types.104)
- Semantics
+<b> Semantics</b>
4 Specifiers for structures, unions, and enumerations are discussed in <a href="#6.7.2.1">6.7.2.1</a> through
<a name="6.7.2.3" href="#6.7.2.3"><b> 6.7.2.3. Declarations of typedef names are discussed in 6.7.7. The characteristics of the</b></a>
other types are discussed in <a href="#6.2.5">6.2.5</a>.
[<a name="p100" href="#p100">page 100</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.2.1" href="#6.7.2.1"><b> 6.7.2.1 Structure and union specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 struct-or-union-specifier:
struct-or-union identifieropt { struct-declaration-list }
struct-or-union identifier
struct-declarator:
declarator
declaratoropt : constant-expression
- Constraints
+<b> Constraints</b>
2 A structure or union shall not contain a member with incomplete or function type (hence,
a structure shall not contain an instance of itself, but may contain a pointer to an instance
of itself), except that the last member of a structure with more than one named member
[<a name="p101" href="#p101">page 101</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
5 As discussed in <a href="#6.2.5">6.2.5</a>, a structure is a type consisting of a sequence of members, whose
storage is allocated in an ordered sequence, and a union is a type consisting of a sequence
of members whose storage overlap.
[<a name="p104" href="#p104">page 104</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.2.2" href="#6.7.2.2"><b> 6.7.2.2 Enumeration specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 enum-specifier:
enum identifieropt { enumerator-list }
enum identifieropt { enumerator-list , }
enumerator:
enumeration-constant
enumeration-constant = constant-expression
- Constraints
+<b> Constraints</b>
2 The expression that defines the value of an enumeration constant shall be an integer
constant expression that has a value representable as an int.
- Semantics
+<b> Semantics</b>
3 The identifiers in an enumerator list are declared as constants that have type int and
may appear wherever such are permitted.109) An enumerator with = defines its
enumeration constant as the value of the constant expression. If the first enumerator has
Forward references: tags (<a href="#6.7.2.3">6.7.2.3</a>).
<a name="6.7.2.3" href="#6.7.2.3"><b> 6.7.2.3 Tags</b></a>
- Constraints
+<b> Constraints</b>
1 A specific type shall have its content defined at most once.
2 Where two declarations that use the same tag declare the same type, they shall both use
the same choice of struct, union, or enum.
3 A type specifier of the form
enum identifier
without an enumerator list shall only appear after the type it specifies is complete.
- Semantics
+<b> Semantics</b>
4 All declarations of structure, union, or enumerated types that have the same scope and
use the same tag declare the same type. The type is incomplete111) until the closing brace
of the list defining the content, and complete thereafter.
Forward references: declarators (<a href="#6.7.5">6.7.5</a>), array declarators (<a href="#6.7.5.2">6.7.5.2</a>), type definitions
(<a href="#6.7.7">6.7.7</a>).
<a name="6.7.3" href="#6.7.3"><b> 6.7.3 Type qualifiers</b></a>
- Syntax
+<b> Syntax</b>
1 type-qualifier:
const
restrict
volatile
- Constraints
+<b> Constraints</b>
2 Types other than pointer types derived from object or incomplete types shall not be
restrict-qualified.
- Semantics
+<b> Semantics</b>
3 The properties associated with qualified types are meaningful only for expressions that
are lvalues.114)
4 If the same qualifier appears more than once in the same specifier-qualifier-list, either
}
<a name="6.7.4" href="#6.7.4"><b> 6.7.4 Function specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 function-specifier:
inline
- Constraints
+<b> Constraints</b>
2 Function specifiers shall be used only in the declaration of an identifier for a function.
3 An inline definition of a function with external linkage shall not contain a definition of a
modifiable object with static storage duration, and shall not contain a reference to an
identifier with internal linkage.
4 In a hosted environment, the inline function specifier shall not appear in a declaration
of main.
- Semantics
+<b> Semantics</b>
5 A function declared with an inline function specifier is an inline function. The
function specifier may appear more than once; the behavior is the same as if it appeared
only once. Making a function an inline function suggests that calls to the function be as
[<a name="p113" href="#p113">page 113</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.5" href="#6.7.5"><b> 6.7.5 Declarators</b></a>
- Syntax
+<b> Syntax</b>
1 declarator:
pointeropt direct-declarator
direct-declarator:
identifier-list:
identifier
identifier-list , identifier
- Semantics
+<b> Semantics</b>
2 Each declarator declares one identifier, and asserts that when an operand of the same
form as the declarator appears in an expression, it designates a function or object with the
scope, storage duration, and type indicated by the declaration specifiers.
directly or via one or more typedefs.
Forward references: array declarators (<a href="#6.7.5.2">6.7.5.2</a>), type definitions (<a href="#6.7.7">6.7.7</a>).
<a name="6.7.5.1" href="#6.7.5.1"><b> 6.7.5.1 Pointer declarators</b></a>
- Semantics
+<b> Semantics</b>
1 If, in the declaration ''T D1'', D1 has the form
* type-qualifier-listopt D
and the type specified for ident in the declaration ''T D'' is ''derived-declarator-type-list
declares constant_ptr as an object that has type ''const-qualified pointer to int''.
<a name="6.7.5.2" href="#6.7.5.2"><b> 6.7.5.2 Array declarators</b></a>
- Constraints
+<b> Constraints</b>
1 In addition to optional type qualifiers and the keyword static, the [ and ] may delimit
an expression or *. If they delimit an expression (which specifies the size of an array), the
expression shall have an integer type. If the expression is a constant expression, it shall
2 An ordinary identifier (as defined in <a href="#6.2.3">6.2.3</a>) that has a variably modified type shall have
either block scope and no linkage or function prototype scope. If an identifier is declared
to be an object with static storage duration, it shall not have a variable length array type.
- Semantics
+<b> Semantics</b>
3 If, in the declaration ''T D1'', D1 has one of the forms:
D[ type-qualifier-listopt assignment-expressionopt ]
D[ static type-qualifier-listopt assignment-expression ]
Forward references: function declarators (<a href="#6.7.5.3">6.7.5.3</a>), function definitions (<a href="#6.9.1">6.9.1</a>),
initialization (<a href="#6.7.8">6.7.8</a>).
<a name="6.7.5.3" href="#6.7.5.3"><b> 6.7.5.3 Function declarators (including prototypes)</b></a>
- Constraints
+<b> Constraints</b>
1 A function declarator shall not specify a return type that is a function type or an array
type.
2 The only storage-class specifier that shall occur in a parameter declaration is register.
shall be empty.
4 After adjustment, the parameters in a parameter type list in a function declarator that is
part of a definition of that function shall not have incomplete type.
- Semantics
+<b> Semantics</b>
5 If, in the declaration ''T D1'', D1 has the form
D( parameter-type-list )
or
[<a name="p121" href="#p121">page 121</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.6" href="#6.7.6"><b> 6.7.6 Type names</b></a>
- Syntax
+<b> Syntax</b>
1 type-name:
specifier-qualifier-list abstract-declaratoropt
abstract-declarator:
assignment-expression ]
direct-abstract-declaratoropt [ * ]
direct-abstract-declaratoropt ( parameter-type-listopt )
- Semantics
+<b> Semantics</b>
2 In several contexts, it is necessary to specify a type. This is accomplished using a type
name, which is syntactically a declaration for a function or an object of that type that
omits the identifier.128)
[<a name="p122" href="#p122">page 122</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.7" href="#6.7.7"><b> 6.7.7 Type definitions</b></a>
- Syntax
+<b> Syntax</b>
1 typedef-name:
identifier
- Constraints
+<b> Constraints</b>
2 If a typedef name specifies a variably modified type then it shall have block scope.
- Semantics
+<b> Semantics</b>
3 In a declaration whose storage-class specifier is typedef, each declarator defines an
identifier to be a typedef name that denotes the type specified for the identifier in the way
described in <a href="#6.7.5">6.7.5</a>. Any array size expressions associated with variable length array
[<a name="p124" href="#p124">page 124</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.8" href="#6.7.8"><b> 6.7.8 Initialization</b></a>
- Syntax
+<b> Syntax</b>
1 initializer:
assignment-expression
{ initializer-list }
designator:
[ constant-expression ]
. identifier
- Constraints
+<b> Constraints</b>
2 No initializer shall attempt to provide a value for an object not contained within the entity
being initialized.
3 The type of the entity to be initialized shall be an array of unknown size or an object type
identifier shall be the name of a member of that type.
[<a name="p125" href="#p125">page 125</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
8 An initializer specifies the initial value stored in an object.
9 Except where explicitly stated otherwise, for the purposes of this subclause unnamed
members of objects of structure and union type do not participate in initialization.
[<a name="p130" href="#p130">page 130</a>] (<a href="#Contents">Contents</a>)
<a name="6.8" href="#6.8"><b> 6.8 Statements and blocks</b></a>
- Syntax
+<b> Syntax</b>
1 statement:
labeled-statement
compound-statement
selection-statement
iteration-statement
jump-statement
- Semantics
+<b> Semantics</b>
2 A statement specifies an action to be performed. Except as indicated, statements are
executed in sequence.
3 A block allows a set of declarations and statements to be grouped into one syntactic unit.
Forward references: expression and null statements (<a href="#6.8.3">6.8.3</a>), selection statements
(<a href="#6.8.4">6.8.4</a>), iteration statements (<a href="#6.8.5">6.8.5</a>), the return statement (<a href="#6.8.6.4">6.8.6.4</a>).
<a name="6.8.1" href="#6.8.1"><b> 6.8.1 Labeled statements</b></a>
- Syntax
+<b> Syntax</b>
1 labeled-statement:
identifier : statement
case constant-expression : statement
default : statement
- Constraints
+<b> Constraints</b>
2 A case or default label shall appear only in a switch statement. Further
constraints on such labels are discussed under the switch statement.
[<a name="p131" href="#p131">page 131</a>] (<a href="#Contents">Contents</a>)
3 Label names shall be unique within a function.
- Semantics
+<b> Semantics</b>
4 Any statement may be preceded by a prefix that declares an identifier as a label name.
Labels in themselves do not alter the flow of control, which continues unimpeded across
them.
Forward references: the goto statement (<a href="#6.8.6.1">6.8.6.1</a>), the switch statement (<a href="#6.8.4.2">6.8.4.2</a>).
<a name="6.8.2" href="#6.8.2"><b> 6.8.2 Compound statement</b></a>
- Syntax
+<b> Syntax</b>
1 compound-statement:
{ block-item-listopt }
block-item-list:
block-item:
declaration
statement
- Semantics
+<b> Semantics</b>
2 A compound statement is a block.
<a name="6.8.3" href="#6.8.3"><b> 6.8.3 Expression and null statements</b></a>
- Syntax
+<b> Syntax</b>
1 expression-statement:
expressionopt ;
- Semantics
+<b> Semantics</b>
2 The expression in an expression statement is evaluated as a void expression for its side
effects.134)
3 A null statement (consisting of just a semicolon) performs no operations.
Forward references: iteration statements (<a href="#6.8.5">6.8.5</a>).
<a name="6.8.4" href="#6.8.4"><b> 6.8.4 Selection statements</b></a>
- Syntax
+<b> Syntax</b>
1 selection-statement:
if ( expression ) statement
if ( expression ) statement else statement
switch ( expression ) statement
- Semantics
+<b> Semantics</b>
2 A selection statement selects among a set of statements depending on the value of a
controlling expression.
3 A selection statement is a block whose scope is a strict subset of the scope of its
enclosing block. Each associated substatement is also a block whose scope is a strict
subset of the scope of the selection statement.
<a name="6.8.4.1" href="#6.8.4.1"><b> 6.8.4.1 The if statement</b></a>
- Constraints
+<b> Constraints</b>
1 The controlling expression of an if statement shall have scalar type.
- Semantics
+<b> Semantics</b>
2 In both forms, the first substatement is executed if the expression compares unequal to 0.
In the else form, the second substatement is executed if the expression compares equal
3 An else is associated with the lexically nearest preceding if that is allowed by the
syntax.
<a name="6.8.4.2" href="#6.8.4.2"><b> 6.8.4.2 The switch statement</b></a>
- Constraints
+<b> Constraints</b>
1 The controlling expression of a switch statement shall have integer type.
2 If a switch statement has an associated case or default label within the scope of an
identifier with a variably modified type, the entire switch statement shall be within the
(Any enclosed switch statement may have a default label or case constant
expressions with values that duplicate case constant expressions in the enclosing
switch statement.)
- Semantics
+<b> Semantics</b>
4 A switch statement causes control to jump to, into, or past the statement that is the
switch body, depending on the value of a controlling expression, and on the presence of a
default label and the values of any case labels on or in the switch body. A case or
access an indeterminate value. Similarly, the call to the function f cannot be reached.
<a name="6.8.5" href="#6.8.5"><b> 6.8.5 Iteration statements</b></a>
- Syntax
+<b> Syntax</b>
1 iteration-statement:
while ( expression ) statement
do statement while ( expression ) ;
for ( expressionopt ; expressionopt ; expressionopt ) statement
for ( declaration expressionopt ; expressionopt ) statement
- Constraints
+<b> Constraints</b>
2 The controlling expression of an iteration statement shall have scalar type.
3 The declaration part of a for statement shall only declare identifiers for objects having
storage class auto or register.
- Semantics
+<b> Semantics</b>
4 An iteration statement causes a statement called the loop body to be executed repeatedly
until the controlling expression compares equal to 0. The repetition occurs regardless of
whether the loop body is entered from the iteration statement or by a jump.136)
2 Both clause-1 and expression-3 can be omitted. An omitted expression-2 is replaced by a
nonzero constant.
<a name="6.8.6" href="#6.8.6"><b> 6.8.6 Jump statements</b></a>
- Syntax
+<b> Syntax</b>
1 jump-statement:
goto identifier ;
continue ;
break ;
return expressionopt ;
- Semantics
+<b> Semantics</b>
2 A jump statement causes an unconditional jump to another place.
[<a name="p136" href="#p136">page 136</a>] (<a href="#Contents">Contents</a>)
<a name="6.8.6.1" href="#6.8.6.1"><b> 6.8.6.1 The goto statement</b></a>
- Constraints
+<b> Constraints</b>
1 The identifier in a goto statement shall name a label located somewhere in the enclosing
function. A goto statement shall not jump from outside the scope of an identifier having
a variably modified type to inside the scope of that identifier.
- Semantics
+<b> Semantics</b>
2 A goto statement causes an unconditional jump to the statement prefixed by the named
label in the enclosing function.
3 EXAMPLE 1 It is sometimes convenient to jump into the middle of a complicated set of statements. The
goto lab4; // invalid: going INTO scope of VLA.
<a name="6.8.6.2" href="#6.8.6.2"><b> 6.8.6.2 The continue statement</b></a>
- Constraints
+<b> Constraints</b>
1 A continue statement shall appear only in or as a loop body.
- Semantics
+<b> Semantics</b>
2 A continue statement causes a jump to the loop-continuation portion of the smallest
enclosing iteration statement; that is, to the end of the loop body. More precisely, in each
of the statements
unless the continue statement shown is in an enclosed iteration statement (in which
case it is interpreted within that statement), it is equivalent to goto contin;.138)
<a name="6.8.6.3" href="#6.8.6.3"><b> 6.8.6.3 The break statement</b></a>
- Constraints
+<b> Constraints</b>
1 A break statement shall appear only in or as a switch body or loop body.
- Semantics
+<b> Semantics</b>
2 A break statement terminates execution of the smallest enclosing switch or iteration
statement.
[<a name="p138" href="#p138">page 138</a>] (<a href="#Contents">Contents</a>)
<a name="6.8.6.4" href="#6.8.6.4"><b> 6.8.6.4 The return statement</b></a>
- Constraints
+<b> Constraints</b>
1 A return statement with an expression shall not appear in a function whose return type
is void. A return statement without an expression shall only appear in a function
whose return type is void.
- Semantics
+<b> Semantics</b>
2 A return statement terminates execution of the current function and returns control to
its caller. A function may have any number of return statements.
3 If a return statement with an expression is executed, the value of the expression is
[<a name="p139" href="#p139">page 139</a>] (<a href="#Contents">Contents</a>)
<a name="6.9" href="#6.9"><b> 6.9 External definitions</b></a>
- Syntax
+<b> Syntax</b>
1 translation-unit:
external-declaration
translation-unit external-declaration
external-declaration:
function-definition
declaration
- Constraints
+<b> Constraints</b>
2 The storage-class specifiers auto and register shall not appear in the declaration
specifiers in an external declaration.
3 There shall be no more than one external definition for each identifier declared with
linkage is used in an expression (other than as a part of the operand of a sizeof
operator whose result is an integer constant), there shall be exactly one external definition
for the identifier in the translation unit.
- Semantics
+<b> Semantics</b>
4 As discussed in <a href="#5.1.1.1">5.1.1.1</a>, the unit of program text after preprocessing is a translation unit,
which consists of a sequence of external declarations. These are described as ''external''
because they appear outside any function (and hence have file scope). As discussed in
[<a name="p140" href="#p140">page 140</a>] (<a href="#Contents">Contents</a>)
<a name="6.9.1" href="#6.9.1"><b> 6.9.1 Function definitions</b></a>
- Syntax
+<b> Syntax</b>
1 function-definition:
declaration-specifiers declarator declaration-listopt compound-statement
declaration-list:
declaration
declaration-list declaration
- Constraints
+<b> Constraints</b>
2 The identifier declared in a function definition (which is the name of the function) shall
have a function type, as specified by the declarator portion of the function definition.141)
3 The return type of a function shall be void or an object type other than array type.
[<a name="p141" href="#p141">page 141</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
7 The declarator in a function definition specifies the name of the function being defined
and the identifiers of its parameters. If the declarator includes a parameter type list, the
list also specifies the types of all the parameters; such a declarator also serves as a
}
<a name="6.9.2" href="#6.9.2"><b> 6.9.2 External object definitions</b></a>
- Semantics
+<b> Semantics</b>
1 If the declaration of an identifier for an object has file scope and an initializer, the
declaration is an external definition for the identifier.
2 A declaration of an identifier for an object that has file scope without an initializer, and
[<a name="p144" href="#p144">page 144</a>] (<a href="#Contents">Contents</a>)
<a name="6.10" href="#6.10"><b> 6.10 Preprocessing directives</b></a>
- Syntax
+<b> Syntax</b>
1 preprocessing-file:
groupopt
group:
pp-tokens preprocessing-token
new-line:
the new-line character
- Description
+<b> Description</b>
2 A preprocessing directive consists of a sequence of preprocessing tokens that satisfies the
following constraints: The first token in the sequence is a # preprocessing token that (at
the start of translation phase 4) is either the first character in the source file (optionally
4 When in a group that is skipped (<a href="#6.10.1">6.10.1</a>), the directive syntax is relaxed to allow any
sequence of preprocessing tokens to occur between the directive name and the following
new-line character.
- Constraints
+<b> Constraints</b>
5 The only white-space characters that shall appear between preprocessing tokens within a
preprocessing directive (from just after the introducing # preprocessing token through
just before the terminating new-line character) are space and horizontal-tab (including
spaces that have replaced comments or possibly other white-space characters in
translation phase 3).
- Semantics
+<b> Semantics</b>
6 The implementation can process and skip sections of source files conditionally, include
other source files, and replace macros. These capabilities are called preprocessing,
because conceptually they occur before translation of the resulting translation unit.
replaced.
<a name="6.10.1" href="#6.10.1"><b> 6.10.1 Conditional inclusion</b></a>
- Constraints
+<b> Constraints</b>
1 The expression that controls conditional inclusion shall be an integer constant expression
except that: it shall not contain a cast; identifiers (including those lexically identical to
keywords) are interpreted as described below;144) and it may contain unary operator
2 Each preprocessing token that remains (in the list of preprocessing tokens that will
become the controlling expression) after all macro replacements have occurred shall be in
the lexical form of a token (<a href="#6.4">6.4</a>).
- Semantics
+<b> Semantics</b>
3 Preprocessing directives of the forms
# if constant-expression new-line groupopt
# elif constant-expression new-line groupopt
Forward references: macro replacement (<a href="#6.10.3">6.10.3</a>), source file inclusion (<a href="#6.10.2">6.10.2</a>), largest
integer types (<a href="#7.18.1.5">7.18.1.5</a>).
<a name="6.10.2" href="#6.10.2"><b> 6.10.2 Source file inclusion</b></a>
- Constraints
+<b> Constraints</b>
1 A #include directive shall identify a header or source file that can be processed by the
implementation.
- Semantics
+<b> Semantics</b>
2 A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identified uniquely by
Forward references: macro replacement (<a href="#6.10.3">6.10.3</a>).
<a name="6.10.3" href="#6.10.3"><b> 6.10.3 Macro replacement</b></a>
- Constraints
+<b> Constraints</b>
1 Two replacement lists are identical if and only if the preprocessing tokens in both have
the same number, ordering, spelling, and white-space separation, where all white-space
separations are considered identical.
macro that uses the ellipsis notation in the parameters.
6 A parameter identifier in a function-like macro shall be uniquely declared within its
scope.
- Semantics
+<b> Semantics</b>
7 The identifier immediately following the define is called the macro name. There is one
name space for macro names. Any white-space characters preceding or following the
replacement list of preprocessing tokens are not considered part of the replacement list
were a parameter, and the variable arguments shall form the preprocessing tokens used to
replace it.
<a name="6.10.3.2" href="#6.10.3.2"><b> 6.10.3.2 The # operator</b></a>
- Constraints
+<b> Constraints</b>
1 Each # preprocessing token in the replacement list for a function-like macro shall be
followed by a parameter as the next preprocessing token in the replacement list.
- Semantics
+<b> Semantics</b>
2 If, in the replacement list, a parameter is immediately preceded by a # preprocessing
token, both are replaced by a single character string literal preprocessing token that
contains the spelling of the preprocessing token sequence for the corresponding
[<a name="p153" href="#p153">page 153</a>] (<a href="#Contents">Contents</a>)
<a name="6.10.3.3" href="#6.10.3.3"><b> 6.10.3.3 The ## operator</b></a>
- Constraints
+<b> Constraints</b>
1 A ## preprocessing token shall not occur at the beginning or at the end of a replacement
list for either form of macro definition.
- Semantics
+<b> Semantics</b>
2 If, in the replacement list of a function-like macro, a parameter is immediately preceded
or followed by a ## preprocessing token, the parameter is replaced by the corresponding
argument's preprocessing token sequence; however, if an argument consists of no
printf("x is %d but y is %d", x, y));
<a name="6.10.4" href="#6.10.4"><b> 6.10.4 Line control</b></a>
- Constraints
+<b> Constraints</b>
1 The string literal of a #line directive, if present, shall be a character string literal.
- Semantics
+<b> Semantics</b>
2 The line number of the current source line is one greater than the number of new-line
characters read or introduced in translation phase 1 (<a href="#5.1.1.2">5.1.1.2</a>) while processing the source
file to the current token.
[<a name="p158" href="#p158">page 158</a>] (<a href="#Contents">Contents</a>)
<a name="6.10.5" href="#6.10.5"><b> 6.10.5 Error directive</b></a>
- Semantics
+<b> Semantics</b>
1 A preprocessing directive of the form
# error pp-tokensopt new-line
causes the implementation to produce a diagnostic message that includes the specified
sequence of preprocessing tokens.
<a name="6.10.6" href="#6.10.6"><b> 6.10.6 Pragma directive</b></a>
- Semantics
+<b> Semantics</b>
1 A preprocessing directive of the form
# pragma pp-tokensopt new-line
where the preprocessing token STDC does not immediately follow pragma in the
[<a name="p159" href="#p159">page 159</a>] (<a href="#Contents">Contents</a>)
<a name="6.10.7" href="#6.10.7"><b> 6.10.7 Null directive</b></a>
- Semantics
+<b> Semantics</b>
1 A preprocessing directive of the form
# new-line
has no effect.
in any standard header.
Forward references: the asctime function (<a href="#7.23.3.1">7.23.3.1</a>), standard headers (<a href="#7.1.2">7.1.2</a>).
<a name="6.10.9" href="#6.10.9"><b> 6.10.9 Pragma operator</b></a>
- Semantics
+<b> Semantics</b>
1 A unary operator expression of the form:
_Pragma ( string-literal )
is processed as follows: The string literal is destringized by deleting the L prefix, if
undefined.
<a name="7.2.1" href="#7.2.1"><b> 7.2.1 Program diagnostics</b></a>
<a name="7.2.1.1" href="#7.2.1.1"><b> 7.2.1.1 The assert macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.2"><assert.h></a>
void assert(scalar expression);
- Description
+<b> Description</b>
2 The assert macro puts diagnostic tests into programs; it expands to a void expression.
When it is executed, if expression (which shall have a scalar type) is false (that is,
compares equal to 0), the assert macro writes information about the particular call that
the preprocessing macros __FILE__ and __LINE__ and of the identifier
__func__) on the standard error stream in an implementation-defined format.165) It
then calls the abort function.
- Returns
+<b> Returns</b>
3 The assert macro returns no value.
Forward references: the abort function (<a href="#7.20.4.1">7.20.4.1</a>).
the finite endpoint of the cut along the negative real axis approaches the cut from above,
so the cut maps to the positive imaginary axis.
<a name="7.3.4" href="#7.3.4"><b> 7.3.4 The CX_LIMITED_RANGE pragma</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
#pragma STDC CX_LIMITED_RANGE on-off-switch
- Description
+<b> Description</b>
2 The usual mathematical formulas for complex multiply, divide, and absolute value are
problematic because of their treatment of infinities and because of undue overflow and
underflow. The CX_LIMITED_RANGE pragma can be used to inform the
undefined. The default state for the pragma is ''off''.
<a name="7.3.5" href="#7.3.5"><b> 7.3.5 Trigonometric functions</b></a>
<a name="7.3.5.1" href="#7.3.5.1"><b> 7.3.5.1 The cacos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cacos(double complex z);
float complex cacosf(float complex z);
long double complex cacosl(long double complex z);
- Description
+<b> Description</b>
2 The cacos functions compute the complex arc cosine of z, with branch cuts outside the
interval [-1, +1] along the real axis.
- Returns
+<b> Returns</b>
3 The cacos functions return the complex arc cosine value, in the range of a strip
mathematically unbounded along the imaginary axis and in the interval [0, pi ] along the
real axis.
<a name="7.3.5.2" href="#7.3.5.2"><b> 7.3.5.2 The casin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex casin(double complex z);
float complex casinf(float complex z);
long double complex casinl(long double complex z);
- Description
+<b> Description</b>
2 The casin functions compute the complex arc sine of z, with branch cuts outside the
interval [-1, +1] along the real axis.
- Returns
+<b> Returns</b>
3 The casin functions return the complex arc sine value, in the range of a strip
mathematically unbounded along the imaginary axis and in the interval [-pi /2, +pi /2]
along the real axis.
[<a name="p172" href="#p172">page 172</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.5.3" href="#7.3.5.3"><b> 7.3.5.3 The catan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex catan(double complex z);
float complex catanf(float complex z);
long double complex catanl(long double complex z);
- Description
+<b> Description</b>
2 The catan functions compute the complex arc tangent of z, with branch cuts outside the
interval [-i, +i] along the imaginary axis.
- Returns
+<b> Returns</b>
3 The catan functions return the complex arc tangent value, in the range of a strip
mathematically unbounded along the imaginary axis and in the interval [-pi /2, +pi /2]
along the real axis.
<a name="7.3.5.4" href="#7.3.5.4"><b> 7.3.5.4 The ccos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ccos(double complex z);
float complex ccosf(float complex z);
long double complex ccosl(long double complex z);
- Description
+<b> Description</b>
2 The ccos functions compute the complex cosine of z.
- Returns
+<b> Returns</b>
3 The ccos functions return the complex cosine value.
<a name="7.3.5.5" href="#7.3.5.5"><b> 7.3.5.5 The csin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex csin(double complex z);
float complex csinf(float complex z);
long double complex csinl(long double complex z);
- Description
+<b> Description</b>
2 The csin functions compute the complex sine of z.
- Returns
+<b> Returns</b>
3 The csin functions return the complex sine value.
[<a name="p173" href="#p173">page 173</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.5.6" href="#7.3.5.6"><b> 7.3.5.6 The ctan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ctan(double complex z);
float complex ctanf(float complex z);
long double complex ctanl(long double complex z);
- Description
+<b> Description</b>
2 The ctan functions compute the complex tangent of z.
- Returns
+<b> Returns</b>
3 The ctan functions return the complex tangent value.
<a name="7.3.6" href="#7.3.6"><b> 7.3.6 Hyperbolic functions</b></a>
<a name="7.3.6.1" href="#7.3.6.1"><b> 7.3.6.1 The cacosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cacosh(double complex z);
float complex cacoshf(float complex z);
long double complex cacoshl(long double complex z);
- Description
+<b> Description</b>
2 The cacosh functions compute the complex arc hyperbolic cosine of z, with a branch
cut at values less than 1 along the real axis.
- Returns
+<b> Returns</b>
3 The cacosh functions return the complex arc hyperbolic cosine value, in the range of a
half-strip of non-negative values along the real axis and in the interval [-ipi , +ipi ] along
the imaginary axis.
<a name="7.3.6.2" href="#7.3.6.2"><b> 7.3.6.2 The casinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex casinh(double complex z);
float complex casinhf(float complex z);
long double complex casinhl(long double complex z);
- Description
+<b> Description</b>
2 The casinh functions compute the complex arc hyperbolic sine of z, with branch cuts
outside the interval [-i, +i] along the imaginary axis.
[<a name="p174" href="#p174">page 174</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The casinh functions return the complex arc hyperbolic sine value, in the range of a
strip mathematically unbounded along the real axis and in the interval [-ipi /2, +ipi /2]
along the imaginary axis.
<a name="7.3.6.3" href="#7.3.6.3"><b> 7.3.6.3 The catanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex catanh(double complex z);
float complex catanhf(float complex z);
long double complex catanhl(long double complex z);
- Description
+<b> Description</b>
2 The catanh functions compute the complex arc hyperbolic tangent of z, with branch
cuts outside the interval [-1, +1] along the real axis.
- Returns
+<b> Returns</b>
3 The catanh functions return the complex arc hyperbolic tangent value, in the range of a
strip mathematically unbounded along the real axis and in the interval [-ipi /2, +ipi /2]
along the imaginary axis.
<a name="7.3.6.4" href="#7.3.6.4"><b> 7.3.6.4 The ccosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ccosh(double complex z);
float complex ccoshf(float complex z);
long double complex ccoshl(long double complex z);
- Description
+<b> Description</b>
2 The ccosh functions compute the complex hyperbolic cosine of z.
- Returns
+<b> Returns</b>
3 The ccosh functions return the complex hyperbolic cosine value.
<a name="7.3.6.5" href="#7.3.6.5"><b> 7.3.6.5 The csinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex csinh(double complex z);
float complex csinhf(float complex z);
[<a name="p175" href="#p175">page 175</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The csinh functions compute the complex hyperbolic sine of z.
- Returns
+<b> Returns</b>
3 The csinh functions return the complex hyperbolic sine value.
<a name="7.3.6.6" href="#7.3.6.6"><b> 7.3.6.6 The ctanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ctanh(double complex z);
float complex ctanhf(float complex z);
long double complex ctanhl(long double complex z);
- Description
+<b> Description</b>
2 The ctanh functions compute the complex hyperbolic tangent of z.
- Returns
+<b> Returns</b>
3 The ctanh functions return the complex hyperbolic tangent value.
<a name="7.3.7" href="#7.3.7"><b> 7.3.7 Exponential and logarithmic functions</b></a>
<a name="7.3.7.1" href="#7.3.7.1"><b> 7.3.7.1 The cexp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cexp(double complex z);
float complex cexpf(float complex z);
long double complex cexpl(long double complex z);
- Description
+<b> Description</b>
2 The cexp functions compute the complex base-e exponential of z.
- Returns
+<b> Returns</b>
3 The cexp functions return the complex base-e exponential value.
<a name="7.3.7.2" href="#7.3.7.2"><b> 7.3.7.2 The clog functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex clog(double complex z);
float complex clogf(float complex z);
[<a name="p176" href="#p176">page 176</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The clog functions compute the complex natural (base-e) logarithm of z, with a branch
cut along the negative real axis.
- Returns
+<b> Returns</b>
3 The clog functions return the complex natural logarithm value, in the range of a strip
mathematically unbounded along the real axis and in the interval [-ipi , +ipi ] along the
imaginary axis.
<a name="7.3.8" href="#7.3.8"><b> 7.3.8 Power and absolute-value functions</b></a>
<a name="7.3.8.1" href="#7.3.8.1"><b> 7.3.8.1 The cabs functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double cabs(double complex z);
float cabsf(float complex z);
long double cabsl(long double complex z);
- Description
+<b> Description</b>
2 The cabs functions compute the complex absolute value (also called norm, modulus, or
magnitude) of z.
- Returns
+<b> Returns</b>
3 The cabs functions return the complex absolute value.
<a name="7.3.8.2" href="#7.3.8.2"><b> 7.3.8.2 The cpow functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cpow(double complex x, double complex y);
float complex cpowf(float complex x, float complex y);
long double complex cpowl(long double complex x,
long double complex y);
- Description
+<b> Description</b>
2 The cpow functions compute the complex power function xy , with a branch cut for the
first parameter along the negative real axis.
- Returns
+<b> Returns</b>
3 The cpow functions return the complex power function value.
[<a name="p177" href="#p177">page 177</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.8.3" href="#7.3.8.3"><b> 7.3.8.3 The csqrt functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex csqrt(double complex z);
float complex csqrtf(float complex z);
long double complex csqrtl(long double complex z);
- Description
+<b> Description</b>
2 The csqrt functions compute the complex square root of z, with a branch cut along the
negative real axis.
- Returns
+<b> Returns</b>
3 The csqrt functions return the complex square root value, in the range of the right half-
plane (including the imaginary axis).
<a name="7.3.9" href="#7.3.9"><b> 7.3.9 Manipulation functions</b></a>
<a name="7.3.9.1" href="#7.3.9.1"><b> 7.3.9.1 The carg functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double carg(double complex z);
float cargf(float complex z);
long double cargl(long double complex z);
- Description
+<b> Description</b>
2 The carg functions compute the argument (also called phase angle) of z, with a branch
cut along the negative real axis.
- Returns
+<b> Returns</b>
3 The carg functions return the value of the argument in the interval [-pi , +pi ].
<a name="7.3.9.2" href="#7.3.9.2"><b> 7.3.9.2 The cimag functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double cimag(double complex z);
float cimagf(float complex z);
[<a name="p178" href="#p178">page 178</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The cimag functions compute the imaginary part of z.170)
- Returns
+<b> Returns</b>
3 The cimag functions return the imaginary part value (as a real).
<a name="7.3.9.3" href="#7.3.9.3"><b> 7.3.9.3 The conj functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex conj(double complex z);
float complex conjf(float complex z);
long double complex conjl(long double complex z);
- Description
+<b> Description</b>
2 The conj functions compute the complex conjugate of z, by reversing the sign of its
imaginary part.
- Returns
+<b> Returns</b>
3 The conj functions return the complex conjugate value.
<a name="7.3.9.4" href="#7.3.9.4"><b> 7.3.9.4 The cproj functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cproj(double complex z);
float complex cprojf(float complex z);
long double complex cprojl(long double complex z);
- Description
+<b> Description</b>
2 The cproj functions compute a projection of z onto the Riemann sphere: z projects to
z except that all complex infinities (even those with one infinite part and one NaN part)
project to positive infinity on the real axis. If z has an infinite part, then cproj(z) is
equivalent to
INFINITY + I * copysign(0.0, cimag(z))
- Returns
+<b> Returns</b>
3 The cproj functions return the value of the projection onto the Riemann sphere.
[<a name="p179" href="#p179">page 179</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.9.5" href="#7.3.9.5"><b> 7.3.9.5 The creal functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double creal(double complex z);
float crealf(float complex z);
long double creall(long double complex z);
- Description
+<b> Description</b>
2 The creal functions compute the real part of z.171)
- Returns
+<b> Returns</b>
3 The creal functions return the real part value.
1 The functions in this subclause return nonzero (true) if and only if the value of the
argument c conforms to that in the description of the function.
<a name="7.4.1.1" href="#7.4.1.1"><b> 7.4.1.1 The isalnum function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isalnum(int c);
- Description
+<b> Description</b>
2 The isalnum function tests for any character for which isalpha or isdigit is true.
<a name="7.4.1.2" href="#7.4.1.2"><b> 7.4.1.2 The isalpha function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isalpha(int c);
- Description
+<b> Description</b>
2 The isalpha function tests for any character for which isupper or islower is true,
or any character that is one of a locale-specific set of alphabetic characters for which
none of iscntrl, isdigit, ispunct, or isspace is true.174) In the "C" locale,
isalpha returns true only for the characters for which isupper or islower is true.
<a name="7.4.1.3" href="#7.4.1.3"><b> 7.4.1.3 The isblank function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isblank(int c);
- Description
+<b> Description</b>
2 The isblank function tests for any character that is a standard blank character or is one
of a locale-specific set of characters for which isspace is true and that is used to
separate words within a line of text. The standard blank characters are the following:
space (' '), and horizontal tab ('\t'). In the "C" locale, isblank returns true only
for the standard blank characters.
<a name="7.4.1.4" href="#7.4.1.4"><b> 7.4.1.4 The iscntrl function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int iscntrl(int c);
- Description
+<b> Description</b>
2 The iscntrl function tests for any control character.
<a name="7.4.1.5" href="#7.4.1.5"><b> 7.4.1.5 The isdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isdigit(int c);
- Description
+<b> Description</b>
2 The isdigit function tests for any decimal-digit character (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.4.1.6" href="#7.4.1.6"><b> 7.4.1.6 The isgraph function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isgraph(int c);
[<a name="p182" href="#p182">page 182</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The isgraph function tests for any printing character except space (' ').
<a name="7.4.1.7" href="#7.4.1.7"><b> 7.4.1.7 The islower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int islower(int c);
- Description
+<b> Description</b>
2 The islower function tests for any character that is a lowercase letter or is one of a
locale-specific set of characters for which none of iscntrl, isdigit, ispunct, or
isspace is true. In the "C" locale, islower returns true only for the lowercase
letters (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.4.1.8" href="#7.4.1.8"><b> 7.4.1.8 The isprint function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isprint(int c);
- Description
+<b> Description</b>
2 The isprint function tests for any printing character including space (' ').
<a name="7.4.1.9" href="#7.4.1.9"><b> 7.4.1.9 The ispunct function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int ispunct(int c);
- Description
+<b> Description</b>
2 The ispunct function tests for any printing character that is one of a locale-specific set
of punctuation characters for which neither isspace nor isalnum is true. In the "C"
locale, ispunct returns true for every printing character for which neither isspace
nor isalnum is true.
<a name="7.4.1.10" href="#7.4.1.10"><b> 7.4.1.10 The isspace function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isspace(int c);
- Description
+<b> Description</b>
2 The isspace function tests for any character that is a standard white-space character or
is one of a locale-specific set of characters for which isalnum is false. The standard
('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). In the
"C" locale, isspace returns true only for the standard white-space characters.
<a name="7.4.1.11" href="#7.4.1.11"><b> 7.4.1.11 The isupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isupper(int c);
- Description
+<b> Description</b>
2 The isupper function tests for any character that is an uppercase letter or is one of a
locale-specific set of characters for which none of iscntrl, isdigit, ispunct, or
isspace is true. In the "C" locale, isupper returns true only for the uppercase
letters (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.4.1.12" href="#7.4.1.12"><b> 7.4.1.12 The isxdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isxdigit(int c);
- Description
+<b> Description</b>
2 The isxdigit function tests for any hexadecimal-digit character (as defined in <a href="#6.4.4.1">6.4.4.1</a>).
<a name="7.4.2" href="#7.4.2"><b> 7.4.2 Character case mapping functions</b></a>
<a name="7.4.2.1" href="#7.4.2.1"><b> 7.4.2.1 The tolower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int tolower(int c);
- Description
+<b> Description</b>
2 The tolower function converts an uppercase letter to a corresponding lowercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a character for which isupper is true and there are one or more
corresponding characters, as specified by the current locale, for which islower is true,
the tolower function returns one of the corresponding characters (always the same one
[<a name="p184" href="#p184">page 184</a>] (<a href="#Contents">Contents</a>)
<a name="7.4.2.2" href="#7.4.2.2"><b> 7.4.2.2 The toupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int toupper(int c);
- Description
+<b> Description</b>
2 The toupper function converts a lowercase letter to a corresponding uppercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a character for which islower is true and there are one or more
corresponding characters, as specified by the current locale, for which isupper is true,
the toupper function returns one of the corresponding characters (always the same one
FE_ and an uppercase letter, and having type ''pointer to const-qualified fenv_t'', may
also be specified by the implementation.
<a name="7.6.1" href="#7.6.1"><b> 7.6.1 The FENV_ACCESS pragma</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
#pragma STDC FENV_ACCESS on-off-switch
- Description
+<b> Description</b>
2 The FENV_ACCESS pragma provides a means to inform the implementation when a
program might access the floating-point environment to test floating-point status flags or
run under non-default floating-point control modes.184) The pragma shall occur either
FE_OVERFLOW | FE_INEXACT. For other argument values the behavior of these
functions is undefined.
<a name="7.6.2.1" href="#7.6.2.1"><b> 7.6.2.1 The feclearexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feclearexcept(int excepts);
- Description
+<b> Description</b>
2 The feclearexcept function attempts to clear the supported floating-point exceptions
represented by its argument.
- Returns
+<b> Returns</b>
3 The feclearexcept function returns zero if the excepts argument is zero or if all
the specified exceptions were successfully cleared. Otherwise, it returns a nonzero value.
[<a name="p190" href="#p190">page 190</a>] (<a href="#Contents">Contents</a>)
<a name="7.6.2.2" href="#7.6.2.2"><b> 7.6.2.2 The fegetexceptflag function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fegetexceptflag(fexcept_t *flagp,
int excepts);
- Description
+<b> Description</b>
2 The fegetexceptflag function attempts to store an implementation-defined
representation of the states of the floating-point status flags indicated by the argument
excepts in the object pointed to by the argument flagp.
- Returns
+<b> Returns</b>
3 The fegetexceptflag function returns zero if the representation was successfully
stored. Otherwise, it returns a nonzero value.
<a name="7.6.2.3" href="#7.6.2.3"><b> 7.6.2.3 The feraiseexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feraiseexcept(int excepts);
- Description
+<b> Description</b>
2 The feraiseexcept function attempts to raise the supported floating-point exceptions
represented by its argument.187) The order in which these floating-point exceptions are
raised is unspecified, except as stated in <a href="#F.7.6">F.7.6</a>. Whether the feraiseexcept function
additionally raises the ''inexact'' floating-point exception whenever it raises the
''overflow'' or ''underflow'' floating-point exception is implementation-defined.
- Returns
+<b> Returns</b>
3 The feraiseexcept function returns zero if the excepts argument is zero or if all
the specified exceptions were successfully raised. Otherwise, it returns a nonzero value.
[<a name="p191" href="#p191">page 191</a>] (<a href="#Contents">Contents</a>)
<a name="7.6.2.4" href="#7.6.2.4"><b> 7.6.2.4 The fesetexceptflag function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fesetexceptflag(const fexcept_t *flagp,
int excepts);
- Description
+<b> Description</b>
2 The fesetexceptflag function attempts to set the floating-point status flags
indicated by the argument excepts to the states stored in the object pointed to by
flagp. The value of *flagp shall have been set by a previous call to
fegetexceptflag whose second argument represented at least those floating-point
exceptions represented by the argument excepts. This function does not raise floating-
point exceptions, but only sets the state of the flags.
- Returns
+<b> Returns</b>
3 The fesetexceptflag function returns zero if the excepts argument is zero or if
all the specified flags were successfully set to the appropriate state. Otherwise, it returns
a nonzero value.
<a name="7.6.2.5" href="#7.6.2.5"><b> 7.6.2.5 The fetestexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fetestexcept(int excepts);
- Description
+<b> Description</b>
2 The fetestexcept function determines which of a specified subset of the floating-
point exception flags are currently set. The excepts argument specifies the floating-
point status flags to be queried.188)
- Returns
+<b> Returns</b>
3 The fetestexcept function returns the value of the bitwise OR of the floating-point
exception macros corresponding to the currently set floating-point exceptions included in
excepts.
1 The fegetround and fesetround functions provide control of rounding direction
modes.
<a name="7.6.3.1" href="#7.6.3.1"><b> 7.6.3.1 The fegetround function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fegetround(void);
- Description
+<b> Description</b>
2 The fegetround function gets the current rounding direction.
- Returns
+<b> Returns</b>
3 The fegetround function returns the value of the rounding direction macro
representing the current rounding direction or a negative value if there is no such
rounding direction macro or the current rounding direction is not determinable.
<a name="7.6.3.2" href="#7.6.3.2"><b> 7.6.3.2 The fesetround function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fesetround(int round);
- Description
+<b> Description</b>
2 The fesetround function establishes the rounding direction represented by its
argument round. If the argument is not equal to the value of a rounding direction macro,
the rounding direction is not changed.
- Returns
+<b> Returns</b>
3 The fesetround function returns zero if and only if the requested rounding direction
was established.
1 The functions in this section manage the floating-point environment -- status flags and
control modes -- as one entity.
<a name="7.6.4.1" href="#7.6.4.1"><b> 7.6.4.1 The fegetenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fegetenv(fenv_t *envp);
- Description
+<b> Description</b>
2 The fegetenv function attempts to store the current floating-point environment in the
object pointed to by envp.
- Returns
+<b> Returns</b>
3 The fegetenv function returns zero if the environment was successfully stored.
Otherwise, it returns a nonzero value.
<a name="7.6.4.2" href="#7.6.4.2"><b> 7.6.4.2 The feholdexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feholdexcept(fenv_t *envp);
- Description
+<b> Description</b>
2 The feholdexcept function saves the current floating-point environment in the object
pointed to by envp, clears the floating-point status flags, and then installs a non-stop
(continue on floating-point exceptions) mode, if available, for all floating-point
[<a name="p194" href="#p194">page 194</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The feholdexcept function returns zero if and only if non-stop floating-point
exception handling was successfully installed.
<a name="7.6.4.3" href="#7.6.4.3"><b> 7.6.4.3 The fesetenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fesetenv(const fenv_t *envp);
- Description
+<b> Description</b>
2 The fesetenv function attempts to establish the floating-point environment represented
by the object pointed to by envp. The argument envp shall point to an object set by a
call to fegetenv or feholdexcept, or equal a floating-point environment macro.
Note that fesetenv merely installs the state of the floating-point status flags
represented through its argument, and does not raise these floating-point exceptions.
- Returns
+<b> Returns</b>
3 The fesetenv function returns zero if the environment was successfully established.
Otherwise, it returns a nonzero value.
<a name="7.6.4.4" href="#7.6.4.4"><b> 7.6.4.4 The feupdateenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feupdateenv(const fenv_t *envp);
- Description
+<b> Description</b>
2 The feupdateenv function attempts to save the currently raised floating-point
exceptions in its automatic storage, install the floating-point environment represented by
the object pointed to by envp, and then raise the saved floating-point exceptions. The
argument envp shall point to an object set by a call to feholdexcept or fegetenv,
or equal a floating-point environment macro.
- Returns
+<b> Returns</b>
3 The feupdateenv function returns zero if all the actions were successfully carried out.
Otherwise, it returns a nonzero value.
<a name="7.8.2" href="#7.8.2"><b> 7.8.2 Functions for greatest-width integer types</b></a>
<a name="7.8.2.1" href="#7.8.2.1"><b> 7.8.2.1 The imaxabs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.8"><inttypes.h></a>
intmax_t imaxabs(intmax_t j);
- Description
+<b> Description</b>
2 The imaxabs function computes the absolute value of an integer j. If the result cannot
be represented, the behavior is undefined.193)
[<a name="p199" href="#p199">page 199</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The imaxabs function returns the absolute value.
<a name="7.8.2.2" href="#7.8.2.2"><b> 7.8.2.2 The imaxdiv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.8"><inttypes.h></a>
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
- Description
+<b> Description</b>
2 The imaxdiv function computes numer / denom and numer % denom in a single
operation.
- Returns
+<b> Returns</b>
3 The imaxdiv function returns a structure of type imaxdiv_t comprising both the
quotient and the remainder. The structure shall contain (in either order) the members
quot (the quotient) and rem (the remainder), each of which has type intmax_t. If
either part of the result cannot be represented, the behavior is undefined.
<a name="7.8.2.3" href="#7.8.2.3"><b> 7.8.2.3 The strtoimax and strtoumax functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.8"><inttypes.h></a>
intmax_t strtoimax(const char * restrict nptr,
char ** restrict endptr, int base);
uintmax_t strtoumax(const char * restrict nptr,
char ** restrict endptr, int base);
- Description
+<b> Description</b>
2 The strtoimax and strtoumax functions are equivalent to the strtol, strtoll,
strtoul, and strtoull functions, except that the initial portion of the string is
converted to intmax_t and uintmax_t representation, respectively.
- Returns
+<b> Returns</b>
3 The strtoimax and strtoumax functions return the converted value, if any. If no
conversion could be performed, zero is returned. If the correct value is outside the range
of representable values, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned
[<a name="p200" href="#p200">page 200</a>] (<a href="#Contents">Contents</a>)
<a name="7.8.2.4" href="#7.8.2.4"><b> 7.8.2.4 The wcstoimax and wcstoumax functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stddef.h></a> // for wchar_t
#include <a href="#7.8"><inttypes.h></a>
intmax_t wcstoimax(const wchar_t * restrict nptr,
wchar_t ** restrict endptr, int base);
uintmax_t wcstoumax(const wchar_t * restrict nptr,
wchar_t ** restrict endptr, int base);
- Description
+<b> Description</b>
2 The wcstoimax and wcstoumax functions are equivalent to the wcstol, wcstoll,
wcstoul, and wcstoull functions except that the initial portion of the wide string is
converted to intmax_t and uintmax_t representation, respectively.
- Returns
+<b> Returns</b>
3 The wcstoimax function returns the converted value, if any. If no conversion could be
performed, zero is returned. If the correct value is outside the range of representable
values, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned (according to the
implementation.
<a name="7.11.1" href="#7.11.1"><b> 7.11.1 Locale control</b></a>
<a name="7.11.1.1" href="#7.11.1.1"><b> 7.11.1.1 The setlocale function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.11"><locale.h></a>
char *setlocale(int category, const char *locale);
- Description
+<b> Description</b>
2 The setlocale function selects the appropriate portion of the program's locale as
specified by the category and locale arguments. The setlocale function may be
used to change or query the program's entire current locale or portions thereof. The value
setlocale(LC_ALL, "C");
is executed.
5 The implementation shall behave as if no library function calls the setlocale function.
- Returns
+<b> Returns</b>
6 If a pointer to a string is given for locale and the selection can be honored, the
setlocale function returns a pointer to the string associated with the specified
category for the new locale. If the selection cannot be honored, the setlocale
strftime function (<a href="#7.23.3.5">7.23.3.5</a>), the strxfrm function (<a href="#7.21.4.5">7.21.4.5</a>).
<a name="7.11.2" href="#7.11.2"><b> 7.11.2 Numeric formatting convention inquiry</b></a>
<a name="7.11.2.1" href="#7.11.2.1"><b> 7.11.2.1 The localeconv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.11"><locale.h></a>
struct lconv *localeconv(void);
- Description
+<b> Description</b>
2 The localeconv function sets the components of an object with type struct lconv
with values appropriate for the formatting of numeric quantities (monetary and otherwise)
according to the rules of the current locale.
7 The implementation shall behave as if no library function calls the localeconv
function.
- Returns
+<b> Returns</b>
8 The localeconv function returns a pointer to the filled-in object. The structure
pointed to by the return value shall not be modified by the program, but may be
overwritten by a subsequent call to the localeconv function. In addition, calls to the
math_errhandling & MATH_ERREXCEPT is nonzero, whether the ''underflow''
floating-point exception is raised is implementation-defined.
<a name="7.12.2" href="#7.12.2"><b> 7.12.2 The FP_CONTRACT pragma</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
#pragma STDC FP_CONTRACT on-off-switch
- Description
+<b> Description</b>
2 The FP_CONTRACT pragma can be used to allow (if the state is ''on'') or disallow (if the
state is ''off'') the implementation to contract expressions (<a href="#6.5">6.5</a>). Each pragma can occur
either outside external declarations or preceding all explicit declarations and statements
1 In the synopses in this subclause, real-floating indicates that the argument shall be an
expression of real floating type.
<a name="7.12.3.1" href="#7.12.3.1"><b> 7.12.3.1 The fpclassify macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int fpclassify(real-floating x);
- Description
+<b> Description</b>
2 The fpclassify macro classifies its argument value as NaN, infinite, normal,
subnormal, zero, or into another implementation-defined category. First, an argument
represented in a format wider than its semantic type is converted to its semantic type.
Then classification is based on the type of the argument.205)
- Returns
+<b> Returns</b>
3 The fpclassify macro returns the value of the number classification macro
appropriate to the value of its argument.
4 EXAMPLE The fpclassify macro might be implemented in terms of ordinary functions as
__fpclassifyl(x))
<a name="7.12.3.2" href="#7.12.3.2"><b> 7.12.3.2 The isfinite macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isfinite(real-floating x);
- Description
+<b> Description</b>
2 The isfinite macro determines whether its argument has a finite value (zero,
subnormal, or normal, and not infinite or NaN). First, an argument represented in a
format wider than its semantic type is converted to its semantic type. Then determination
[<a name="p216" href="#p216">page 216</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The isfinite macro returns a nonzero value if and only if its argument has a finite
value.
<a name="7.12.3.3" href="#7.12.3.3"><b> 7.12.3.3 The isinf macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isinf(real-floating x);
- Description
+<b> Description</b>
2 The isinf macro determines whether its argument value is an infinity (positive or
negative). First, an argument represented in a format wider than its semantic type is
converted to its semantic type. Then determination is based on the type of the argument.
- Returns
+<b> Returns</b>
3 The isinf macro returns a nonzero value if and only if its argument has an infinite
value.
<a name="7.12.3.4" href="#7.12.3.4"><b> 7.12.3.4 The isnan macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isnan(real-floating x);
- Description
+<b> Description</b>
2 The isnan macro determines whether its argument value is a NaN. First, an argument
represented in a format wider than its semantic type is converted to its semantic type.
Then determination is based on the type of the argument.206)
- Returns
+<b> Returns</b>
3 The isnan macro returns a nonzero value if and only if its argument has a NaN value.
<a name="7.12.3.5" href="#7.12.3.5"><b> 7.12.3.5 The isnormal macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isnormal(real-floating x);
[<a name="p217" href="#p217">page 217</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The isnormal macro determines whether its argument value is normal (neither zero,
subnormal, infinite, nor NaN). First, an argument represented in a format wider than its
semantic type is converted to its semantic type. Then determination is based on the type
of the argument.
- Returns
+<b> Returns</b>
3 The isnormal macro returns a nonzero value if and only if its argument has a normal
value.
<a name="7.12.3.6" href="#7.12.3.6"><b> 7.12.3.6 The signbit macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int signbit(real-floating x);
- Description
+<b> Description</b>
2 The signbit macro determines whether the sign of its argument value is negative.207)
- Returns
+<b> Returns</b>
3 The signbit macro returns a nonzero value if and only if the sign of its argument value
is negative.
<a name="7.12.4" href="#7.12.4"><b> 7.12.4 Trigonometric functions</b></a>
<a name="7.12.4.1" href="#7.12.4.1"><b> 7.12.4.1 The acos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double acos(double x);
float acosf(float x);
long double acosl(long double x);
- Description
+<b> Description</b>
2 The acos functions compute the principal value of the arc cosine of x. A domain error
occurs for arguments not in the interval [-1, +1].
- Returns
+<b> Returns</b>
3 The acos functions return arccos x in the interval [0, pi ] radians.
[<a name="p218" href="#p218">page 218</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.4.2" href="#7.12.4.2"><b> 7.12.4.2 The asin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double asin(double x);
float asinf(float x);
long double asinl(long double x);
- Description
+<b> Description</b>
2 The asin functions compute the principal value of the arc sine of x. A domain error
occurs for arguments not in the interval [-1, +1].
- Returns
+<b> Returns</b>
3 The asin functions return arcsin x in the interval [-pi /2, +pi /2] radians.
<a name="7.12.4.3" href="#7.12.4.3"><b> 7.12.4.3 The atan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double atan(double x);
float atanf(float x);
long double atanl(long double x);
- Description
+<b> Description</b>
2 The atan functions compute the principal value of the arc tangent of x.
- Returns
+<b> Returns</b>
3 The atan functions return arctan x in the interval [-pi /2, +pi /2] radians.
<a name="7.12.4.4" href="#7.12.4.4"><b> 7.12.4.4 The atan2 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double atan2(double y, double x);
float atan2f(float y, float x);
long double atan2l(long double y, long double x);
- Description
+<b> Description</b>
2 The atan2 functions compute the value of the arc tangent of y/x, using the signs of both
arguments to determine the quadrant of the return value. A domain error may occur if
both arguments are zero.
- Returns
+<b> Returns</b>
3 The atan2 functions return arctan y/x in the interval [-pi , +pi ] radians.
[<a name="p219" href="#p219">page 219</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.4.5" href="#7.12.4.5"><b> 7.12.4.5 The cos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double cos(double x);
float cosf(float x);
long double cosl(long double x);
- Description
+<b> Description</b>
2 The cos functions compute the cosine of x (measured in radians).
- Returns
+<b> Returns</b>
3 The cos functions return cos x.
<a name="7.12.4.6" href="#7.12.4.6"><b> 7.12.4.6 The sin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double sin(double x);
float sinf(float x);
long double sinl(long double x);
- Description
+<b> Description</b>
2 The sin functions compute the sine of x (measured in radians).
- Returns
+<b> Returns</b>
3 The sin functions return sin x.
<a name="7.12.4.7" href="#7.12.4.7"><b> 7.12.4.7 The tan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double tan(double x);
float tanf(float x);
long double tanl(long double x);
- Description
+<b> Description</b>
2 The tan functions return the tangent of x (measured in radians).
- Returns
+<b> Returns</b>
3 The tan functions return tan x.
<a name="7.12.5" href="#7.12.5"><b> 7.12.5 Hyperbolic functions</b></a>
<a name="7.12.5.1" href="#7.12.5.1"><b> 7.12.5.1 The acosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double acosh(double x);
float acoshf(float x);
long double acoshl(long double x);
- Description
+<b> Description</b>
2 The acosh functions compute the (nonnegative) arc hyperbolic cosine of x. A domain
error occurs for arguments less than 1.
- Returns
+<b> Returns</b>
3 The acosh functions return arcosh x in the interval [0, +(inf)].
<a name="7.12.5.2" href="#7.12.5.2"><b> 7.12.5.2 The asinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double asinh(double x);
float asinhf(float x);
long double asinhl(long double x);
- Description
+<b> Description</b>
2 The asinh functions compute the arc hyperbolic sine of x.
- Returns
+<b> Returns</b>
3 The asinh functions return arsinh x.
<a name="7.12.5.3" href="#7.12.5.3"><b> 7.12.5.3 The atanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double atanh(double x);
float atanhf(float x);
long double atanhl(long double x);
- Description
+<b> Description</b>
2 The atanh functions compute the arc hyperbolic tangent of x. A domain error occurs
for arguments not in the interval [-1, +1]. A range error may occur if the argument
equals -1 or +1.
[<a name="p221" href="#p221">page 221</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The atanh functions return artanh x.
<a name="7.12.5.4" href="#7.12.5.4"><b> 7.12.5.4 The cosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double cosh(double x);
float coshf(float x);
long double coshl(long double x);
- Description
+<b> Description</b>
2 The cosh functions compute the hyperbolic cosine of x. A range error occurs if the
magnitude of x is too large.
- Returns
+<b> Returns</b>
3 The cosh functions return cosh x.
<a name="7.12.5.5" href="#7.12.5.5"><b> 7.12.5.5 The sinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double sinh(double x);
float sinhf(float x);
long double sinhl(long double x);
- Description
+<b> Description</b>
2 The sinh functions compute the hyperbolic sine of x. A range error occurs if the
magnitude of x is too large.
- Returns
+<b> Returns</b>
3 The sinh functions return sinh x.
<a name="7.12.5.6" href="#7.12.5.6"><b> 7.12.5.6 The tanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double tanh(double x);
float tanhf(float x);
long double tanhl(long double x);
- Description
+<b> Description</b>
2 The tanh functions compute the hyperbolic tangent of x.
[<a name="p222" href="#p222">page 222</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The tanh functions return tanh x.
<a name="7.12.6" href="#7.12.6"><b> 7.12.6 Exponential and logarithmic functions</b></a>
<a name="7.12.6.1" href="#7.12.6.1"><b> 7.12.6.1 The exp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double exp(double x);
float expf(float x);
long double expl(long double x);
- Description
+<b> Description</b>
2 The exp functions compute the base-e exponential of x. A range error occurs if the
magnitude of x is too large.
- Returns
+<b> Returns</b>
3 The exp functions return ex .
<a name="7.12.6.2" href="#7.12.6.2"><b> 7.12.6.2 The exp2 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double exp2(double x);
float exp2f(float x);
long double exp2l(long double x);
- Description
+<b> Description</b>
2 The exp2 functions compute the base-2 exponential of x. A range error occurs if the
magnitude of x is too large.
- Returns
+<b> Returns</b>
3 The exp2 functions return 2x .
<a name="7.12.6.3" href="#7.12.6.3"><b> 7.12.6.3 The expm1 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double expm1(double x);
float expm1f(float x);
[<a name="p223" href="#p223">page 223</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The expm1 functions compute the base-e exponential of the argument, minus 1. A range
error occurs if x is too large.208)
- Returns
+<b> Returns</b>
3 The expm1 functions return ex - 1.
<a name="7.12.6.4" href="#7.12.6.4"><b> 7.12.6.4 The frexp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double frexp(double value, int *exp);
float frexpf(float value, int *exp);
long double frexpl(long double value, int *exp);
- Description
+<b> Description</b>
2 The frexp functions break a floating-point number into a normalized fraction and an
integral power of 2. They store the integer in the int object pointed to by exp.
- Returns
+<b> Returns</b>
3 If value is not a floating-point number, the results are unspecified. Otherwise, the
frexp functions return the value x, such that x has a magnitude in the interval [1/2, 1) or
zero, and value equals x x 2*exp . If value is zero, both parts of the result are zero.
<a name="7.12.6.5" href="#7.12.6.5"><b> 7.12.6.5 The ilogb functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int ilogb(double x);
int ilogbf(float x);
int ilogbl(long double x);
- Description
+<b> Description</b>
2 The ilogb functions extract the exponent of x as a signed int value. If x is zero they
compute the value FP_ILOGB0; if x is infinite they compute the value INT_MAX; if x is
a NaN they compute the value FP_ILOGBNAN; otherwise, they are equivalent to calling
[<a name="p224" href="#p224">page 224</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The ilogb functions return the exponent of x as a signed int value.
Forward references: the logb functions (<a href="#7.12.6.11">7.12.6.11</a>).
<a name="7.12.6.6" href="#7.12.6.6"><b> 7.12.6.6 The ldexp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
long double ldexpl(long double x, int exp);
- Description
+<b> Description</b>
2 The ldexp functions multiply a floating-point number by an integral power of 2. A
range error may occur.
- Returns
+<b> Returns</b>
3 The ldexp functions return x x 2exp .
<a name="7.12.6.7" href="#7.12.6.7"><b> 7.12.6.7 The log functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log(double x);
float logf(float x);
long double logl(long double x);
- Description
+<b> Description</b>
2 The log functions compute the base-e (natural) logarithm of x. A domain error occurs if
the argument is negative. A range error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The log functions return loge x.
<a name="7.12.6.8" href="#7.12.6.8"><b> 7.12.6.8 The log10 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log10(double x);
float log10f(float x);
[<a name="p225" href="#p225">page 225</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The log10 functions compute the base-10 (common) logarithm of x. A domain error
occurs if the argument is negative. A range error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The log10 functions return log10 x.
<a name="7.12.6.9" href="#7.12.6.9"><b> 7.12.6.9 The log1p functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log1p(double x);
float log1pf(float x);
long double log1pl(long double x);
- Description
+<b> Description</b>
2 The log1p functions compute the base-e (natural) logarithm of 1 plus the argument.209)
A domain error occurs if the argument is less than -1. A range error may occur if the
argument equals -1.
- Returns
+<b> Returns</b>
3 The log1p functions return loge (1 + x).
<a name="7.12.6.10" href="#7.12.6.10"><b> 7.12.6.10 The log2 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log2(double x);
float log2f(float x);
long double log2l(long double x);
- Description
+<b> Description</b>
2 The log2 functions compute the base-2 logarithm of x. A domain error occurs if the
argument is less than zero. A range error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The log2 functions return log2 x.
[<a name="p226" href="#p226">page 226</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.6.11" href="#7.12.6.11"><b> 7.12.6.11 The logb functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double logb(double x);
float logbf(float x);
long double logbl(long double x);
- Description
+<b> Description</b>
2 The logb functions extract the exponent of x, as a signed integer value in floating-point
format. If x is subnormal it is treated as though it were normalized; thus, for positive
finite x,
1 <= x x FLT_RADIX-logb(x) < FLT_RADIX
A domain error or range error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The logb functions return the signed exponent of x.
<a name="7.12.6.12" href="#7.12.6.12"><b> 7.12.6.12 The modf functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double modf(double value, double *iptr);
float modff(float value, float *iptr);
long double modfl(long double value, long double *iptr);
- Description
+<b> Description</b>
2 The modf functions break the argument value into integral and fractional parts, each of
which has the same type and sign as the argument. They store the integral part (in
floating-point format) in the object pointed to by iptr.
- Returns
+<b> Returns</b>
3 The modf functions return the signed fractional part of value.
[<a name="p227" href="#p227">page 227</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.6.13" href="#7.12.6.13"><b> 7.12.6.13 The scalbn and scalbln functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double scalbn(double x, int n);
float scalbnf(float x, int n);
double scalbln(double x, long int n);
float scalblnf(float x, long int n);
long double scalblnl(long double x, long int n);
- Description
+<b> Description</b>
2 The scalbn and scalbln functions compute x x FLT_RADIXn efficiently, not
normally by computing FLT_RADIXn explicitly. A range error may occur.
- Returns
+<b> Returns</b>
3 The scalbn and scalbln functions return x x FLT_RADIXn .
<a name="7.12.7" href="#7.12.7"><b> 7.12.7 Power and absolute-value functions</b></a>
<a name="7.12.7.1" href="#7.12.7.1"><b> 7.12.7.1 The cbrt functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double cbrt(double x);
float cbrtf(float x);
long double cbrtl(long double x);
- Description
+<b> Description</b>
2 The cbrt functions compute the real cube root of x.
- Returns
+<b> Returns</b>
3 The cbrt functions return x1/3 .
<a name="7.12.7.2" href="#7.12.7.2"><b> 7.12.7.2 The fabs functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fabs(double x);
float fabsf(float x);
long double fabsl(long double x);
- Description
+<b> Description</b>
2 The fabs functions compute the absolute value of a floating-point number x.
[<a name="p228" href="#p228">page 228</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The fabs functions return | x |.
<a name="7.12.7.3" href="#7.12.7.3"><b> 7.12.7.3 The hypot functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double hypot(double x, double y);
float hypotf(float x, float y);
long double hypotl(long double x, long double y);
- Description
+<b> Description</b>
2 The hypot functions compute the square root of the sum of the squares of x and y,
without undue overflow or underflow. A range error may occur.
3 Returns
???
???????????????
<a name="7.12.7.4" href="#7.12.7.4"><b> 7.12.7.4 The pow functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
- Description
+<b> Description</b>
2 The pow functions compute x raised to the power y. A domain error occurs if x is finite
and negative and y is finite and not an integer value. A range error may occur. A domain
error may occur if x is zero and y is zero. A domain error or range error may occur if x
is zero and y is less than zero.
- Returns
+<b> Returns</b>
3 The pow functions return xy .
<a name="7.12.7.5" href="#7.12.7.5"><b> 7.12.7.5 The sqrt functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double sqrt(double x);
float sqrtf(float x);
[<a name="p229" href="#p229">page 229</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The sqrt functions compute the nonnegative square root of x. A domain error occurs if
the argument is less than zero.
- Returns
+<b> Returns</b>
3 The sqrt functions return sqrt:x.
???
???
<a name="7.12.8" href="#7.12.8"><b> 7.12.8 Error and gamma functions</b></a>
<a name="7.12.8.1" href="#7.12.8.1"><b> 7.12.8.1 The erf functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double erf(double x);
float erff(float x);
long double erfl(long double x);
- Description
+<b> Description</b>
2 The erf functions compute the error function of x.
- Returns
+<b> Returns</b>
2 x
(integral)
3
??? 0
<a name="7.12.8.2" href="#7.12.8.2"><b> 7.12.8.2 The erfc functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double erfc(double x);
float erfcf(float x);
long double erfcl(long double x);
- Description
+<b> Description</b>
2 The erfc functions compute the complementary error function of x. A range error
occurs if x is too large.
- Returns
+<b> Returns</b>
2 (inf)
(integral)
3
[<a name="p230" href="#p230">page 230</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.8.3" href="#7.12.8.3"><b> 7.12.8.3 The lgamma functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
- Description
+<b> Description</b>
2 The lgamma functions compute the natural logarithm of the absolute value of gamma of
x. A range error occurs if x is too large. A range error may occur if x is a negative
integer or zero.
- Returns
+<b> Returns</b>
3 The lgamma functions return loge | (Gamma)(x) |.
<a name="7.12.8.4" href="#7.12.8.4"><b> 7.12.8.4 The tgamma functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);
- Description
+<b> Description</b>
2 The tgamma functions compute the gamma function of x. A domain error or range error
may occur if x is a negative integer or zero. A range error may occur if the magnitude of
x is too large or too small.
- Returns
+<b> Returns</b>
3 The tgamma functions return (Gamma)(x).
<a name="7.12.9" href="#7.12.9"><b> 7.12.9 Nearest integer functions</b></a>
<a name="7.12.9.1" href="#7.12.9.1"><b> 7.12.9.1 The ceil functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double ceil(double x);
float ceilf(float x);
long double ceill(long double x);
- Description
+<b> Description</b>
2 The ceil functions compute the smallest integer value not less than x.
[<a name="p231" href="#p231">page 231</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The ceil functions return ???x???, expressed as a floating-point number.
<a name="7.12.9.2" href="#7.12.9.2"><b> 7.12.9.2 The floor functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double floor(double x);
float floorf(float x);
long double floorl(long double x);
- Description
+<b> Description</b>
2 The floor functions compute the largest integer value not greater than x.
- Returns
+<b> Returns</b>
3 The floor functions return ???x???, expressed as a floating-point number.
<a name="7.12.9.3" href="#7.12.9.3"><b> 7.12.9.3 The nearbyint functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nearbyint(double x);
float nearbyintf(float x);
long double nearbyintl(long double x);
- Description
+<b> Description</b>
2 The nearbyint functions round their argument to an integer value in floating-point
format, using the current rounding direction and without raising the ''inexact'' floating-
point exception.
- Returns
+<b> Returns</b>
3 The nearbyint functions return the rounded integer value.
<a name="7.12.9.4" href="#7.12.9.4"><b> 7.12.9.4 The rint functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double rint(double x);
float rintf(float x);
long double rintl(long double x);
- Description
+<b> Description</b>
2 The rint functions differ from the nearbyint functions (<a href="#7.12.9.3">7.12.9.3</a>) only in that the
rint functions may raise the ''inexact'' floating-point exception if the result differs in
value from the argument.
[<a name="p232" href="#p232">page 232</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The rint functions return the rounded integer value.
<a name="7.12.9.5" href="#7.12.9.5"><b> 7.12.9.5 The lrint and llrint functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
long int lrint(double x);
long int lrintf(float x);
long long int llrint(double x);
long long int llrintf(float x);
long long int llrintl(long double x);
- Description
+<b> Description</b>
2 The lrint and llrint functions round their argument to the nearest integer value,
rounding according to the current rounding direction. If the rounded value is outside the
range of the return type, the numeric result is unspecified and a domain error or range
error may occur. *
- Returns
+<b> Returns</b>
3 The lrint and llrint functions return the rounded integer value.
<a name="7.12.9.6" href="#7.12.9.6"><b> 7.12.9.6 The round functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double round(double x);
float roundf(float x);
long double roundl(long double x);
- Description
+<b> Description</b>
2 The round functions round their argument to the nearest integer value in floating-point
format, rounding halfway cases away from zero, regardless of the current rounding
direction.
- Returns
+<b> Returns</b>
3 The round functions return the rounded integer value.
[<a name="p233" href="#p233">page 233</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.9.7" href="#7.12.9.7"><b> 7.12.9.7 The lround and llround functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
long int lround(double x);
long int lroundf(float x);
long long int llround(double x);
long long int llroundf(float x);
long long int llroundl(long double x);
- Description
+<b> Description</b>
2 The lround and llround functions round their argument to the nearest integer value,
rounding halfway cases away from zero, regardless of the current rounding direction. If
the rounded value is outside the range of the return type, the numeric result is unspecified
and a domain error or range error may occur.
- Returns
+<b> Returns</b>
3 The lround and llround functions return the rounded integer value.
<a name="7.12.9.8" href="#7.12.9.8"><b> 7.12.9.8 The trunc functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double trunc(double x);
float truncf(float x);
long double truncl(long double x);
- Description
+<b> Description</b>
2 The trunc functions round their argument to the integer value, in floating format,
nearest to but no larger in magnitude than the argument.
- Returns
+<b> Returns</b>
3 The trunc functions return the truncated integer value.
<a name="7.12.10" href="#7.12.10"><b> 7.12.10 Remainder functions</b></a>
<a name="7.12.10.1" href="#7.12.10.1"><b> 7.12.10.1 The fmod functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fmod(double x, double y);
float fmodf(float x, float y);
long double fmodl(long double x, long double y);
- Description
+<b> Description</b>
2 The fmod functions compute the floating-point remainder of x/y.
- Returns
+<b> Returns</b>
3 The fmod functions return the value x - ny, for some integer n such that, if y is nonzero,
the result has the same sign as x and magnitude less than the magnitude of y. If y is zero,
whether a domain error occurs or the fmod functions return zero is implementation-
defined.
<a name="7.12.10.2" href="#7.12.10.2"><b> 7.12.10.2 The remainder functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double remainder(double x, double y);
float remainderf(float x, float y);
long double remainderl(long double x, long double y);
- Description
+<b> Description</b>
2 The remainder functions compute the remainder x REM y required by IEC 60559.210)
- Returns
+<b> Returns</b>
3 The remainder functions return x REM y. If y is zero, whether a domain error occurs
or the functions return zero is implementation defined.
[<a name="p235" href="#p235">page 235</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.10.3" href="#7.12.10.3"><b> 7.12.10.3 The remquo functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double remquo(double x, double y, int *quo);
float remquof(float x, float y, int *quo);
long double remquol(long double x, long double y,
int *quo);
- Description
+<b> Description</b>
2 The remquo functions compute the same remainder as the remainder functions. In
the object pointed to by quo they store a value whose sign is the sign of x/y and whose
magnitude is congruent modulo 2n to the magnitude of the integral quotient of x/y, where
n is an implementation-defined integer greater than or equal to 3.
- Returns
+<b> Returns</b>
3 The remquo functions return x REM y. If y is zero, the value stored in the object
pointed to by quo is unspecified and whether a domain error occurs or the functions
return zero is implementation defined.
<a name="7.12.11" href="#7.12.11"><b> 7.12.11 Manipulation functions</b></a>
<a name="7.12.11.1" href="#7.12.11.1"><b> 7.12.11.1 The copysign functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double copysign(double x, double y);
float copysignf(float x, float y);
long double copysignl(long double x, long double y);
- Description
+<b> Description</b>
2 The copysign functions produce a value with the magnitude of x and the sign of y.
They produce a NaN (with the sign of y) if x is a NaN. On implementations that
represent a signed zero but do not treat negative zero consistently in arithmetic
operations, the copysign functions regard the sign of zero as positive.
- Returns
+<b> Returns</b>
3 The copysign functions return a value with the magnitude of x and the sign of y.
[<a name="p236" href="#p236">page 236</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.11.2" href="#7.12.11.2"><b> 7.12.11.2 The nan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nan(const char *tagp);
float nanf(const char *tagp);
long double nanl(const char *tagp);
- Description
+<b> Description</b>
2 The call nan("n-char-sequence") is equivalent to strtod("NAN(n-char-
sequence)", (char**) NULL); the call nan("") is equivalent to
strtod("NAN()", (char**) NULL). If tagp does not point to an n-char
sequence or an empty string, the call is equivalent to strtod("NAN", (char**)
NULL). Calls to nanf and nanl are equivalent to the corresponding calls to strtof
and strtold.
- Returns
+<b> Returns</b>
3 The nan functions return a quiet NaN, if available, with content indicated through tagp.
If the implementation does not support quiet NaNs, the functions return zero.
Forward references: the strtod, strtof, and strtold functions (<a href="#7.20.1.3">7.20.1.3</a>).
<a name="7.12.11.3" href="#7.12.11.3"><b> 7.12.11.3 The nextafter functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nextafter(double x, double y);
float nextafterf(float x, float y);
long double nextafterl(long double x, long double y);
- Description
+<b> Description</b>
2 The nextafter functions determine the next representable value, in the type of the
function, after x in the direction of y, where x and y are first converted to the type of the
function.211) The nextafter functions return y if x equals y. A range error may occur
if the magnitude of x is the largest finite value representable in the type and the result is
infinite or not representable in the type.
- Returns
+<b> Returns</b>
3 The nextafter functions return the next representable value in the specified format
after x in the direction of y.
[<a name="p237" href="#p237">page 237</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.11.4" href="#7.12.11.4"><b> 7.12.11.4 The nexttoward functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nexttoward(double x, long double y);
float nexttowardf(float x, long double y);
long double nexttowardl(long double x, long double y);
- Description
+<b> Description</b>
2 The nexttoward functions are equivalent to the nextafter functions except that the
second parameter has type long double and the functions return y converted to the
type of the function if x equals y.212)
<a name="7.12.12" href="#7.12.12"><b> 7.12.12 Maximum, minimum, and positive difference functions</b></a>
<a name="7.12.12.1" href="#7.12.12.1"><b> 7.12.12.1 The fdim functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fdim(double x, double y);
float fdimf(float x, float y);
long double fdiml(long double x, long double y);
- Description
+<b> Description</b>
2 The fdim functions determine the positive difference between their arguments:
???x - y if x > y
???
???+0 if x <= y
A range error may occur.
- Returns
+<b> Returns</b>
3 The fdim functions return the positive difference value.
<a name="7.12.12.2" href="#7.12.12.2"><b> 7.12.12.2 The fmax functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fmax(double x, double y);
float fmaxf(float x, float y);
[<a name="p238" href="#p238">page 238</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The fmax functions determine the maximum numeric value of their arguments.213)
- Returns
+<b> Returns</b>
3 The fmax functions return the maximum numeric value of their arguments.
<a name="7.12.12.3" href="#7.12.12.3"><b> 7.12.12.3 The fmin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fmin(double x, double y);
float fminf(float x, float y);
long double fminl(long double x, long double y);
- Description
+<b> Description</b>
2 The fmin functions determine the minimum numeric value of their arguments.214)
- Returns
+<b> Returns</b>
3 The fmin functions return the minimum numeric value of their arguments.
<a name="7.12.13" href="#7.12.13"><b> 7.12.13 Floating multiply-add</b></a>
<a name="7.12.13.1" href="#7.12.13.1"><b> 7.12.13.1 The fma functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
long double fmal(long double x, long double y,
long double z);
- Description
+<b> Description</b>
2 The fma functions compute (x x y) + z, rounded as one ternary operation: they compute
the value (as if) to infinite precision and round once to the result format, according to the
current rounding mode. A range error may occur.
- Returns
+<b> Returns</b>
3 The fma functions return (x x y) + z, rounded as one ternary operation.
the synopses in this subclause, real-floating indicates that the argument shall be an
expression of real floating type.
<a name="7.12.14.1" href="#7.12.14.1"><b> 7.12.14.1 The isgreater macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isgreater(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isgreater macro determines whether its first argument is greater than its second
argument. The value of isgreater(x, y) is always equal to (x) > (y); however,
unlike (x) > (y), isgreater(x, y) does not raise the ''invalid'' floating-point
exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The isgreater macro returns the value of (x) > (y).
<a name="7.12.14.2" href="#7.12.14.2"><b> 7.12.14.2 The isgreaterequal macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isgreaterequal(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isgreaterequal macro determines whether its first argument is greater than or
equal to its second argument. The value of isgreaterequal(x, y) is always equal
to (x) >= (y); however, unlike (x) >= (y), isgreaterequal(x, y) does
[<a name="p240" href="#p240">page 240</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The isgreaterequal macro returns the value of (x) >= (y).
<a name="7.12.14.3" href="#7.12.14.3"><b> 7.12.14.3 The isless macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isless(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isless macro determines whether its first argument is less than its second
argument. The value of isless(x, y) is always equal to (x) < (y); however,
unlike (x) < (y), isless(x, y) does not raise the ''invalid'' floating-point
exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The isless macro returns the value of (x) < (y).
<a name="7.12.14.4" href="#7.12.14.4"><b> 7.12.14.4 The islessequal macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int islessequal(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The islessequal macro determines whether its first argument is less than or equal to
its second argument. The value of islessequal(x, y) is always equal to
(x) <= (y); however, unlike (x) <= (y), islessequal(x, y) does not raise
the ''invalid'' floating-point exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The islessequal macro returns the value of (x) <= (y).
<a name="7.12.14.5" href="#7.12.14.5"><b> 7.12.14.5 The islessgreater macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int islessgreater(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The islessgreater macro determines whether its first argument is less than or
greater than its second argument. The islessgreater(x, y) macro is similar to
(x) < (y) || (x) > (y); however, islessgreater(x, y) does not raise
and y twice).
[<a name="p241" href="#p241">page 241</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The islessgreater macro returns the value of (x) < (y) || (x) > (y).
<a name="7.12.14.6" href="#7.12.14.6"><b> 7.12.14.6 The isunordered macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isunordered(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isunordered macro determines whether its arguments are unordered.
- Returns
+<b> Returns</b>
3 The isunordered macro returns 1 if its arguments are unordered and 0 otherwise.
program defines an external identifier with the name setjmp, the behavior is undefined.
<a name="7.13.1" href="#7.13.1"><b> 7.13.1 Save calling environment</b></a>
<a name="7.13.1.1" href="#7.13.1.1"><b> 7.13.1.1 The setjmp macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.13"><setjmp.h></a>
int setjmp(jmp_buf env);
- Description
+<b> Description</b>
2 The setjmp macro saves its calling environment in its jmp_buf argument for later use
by the longjmp function.
- Returns
+<b> Returns</b>
3 If the return is from a direct invocation, the setjmp macro returns the value zero. If the
return is from a call to the longjmp function, the setjmp macro returns a nonzero
value.
5 If the invocation appears in any other context, the behavior is undefined.
<a name="7.13.2" href="#7.13.2"><b> 7.13.2 Restore calling environment</b></a>
<a name="7.13.2.1" href="#7.13.2.1"><b> 7.13.2.1 The longjmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.13"><setjmp.h></a>
void longjmp(jmp_buf env, int val);
- Description
+<b> Description</b>
2 The longjmp function restores the environment saved by the most recent invocation of
the setjmp macro in the same invocation of the program with the corresponding
jmp_buf argument. If there has been no such invocation, or if the function containing
invocation of the corresponding setjmp macro that do not have volatile-qualified type
and have been changed between the setjmp invocation and longjmp call are
indeterminate.
- Returns
+<b> Returns</b>
4 After longjmp is completed, program execution continues as if the corresponding
invocation of the setjmp macro had just returned the value specified by val. The
longjmp function cannot cause the setjmp macro to return the value 0; if val is 0,
<a name="7.14.1" href="#7.14.1"><b> 7.14.1 Specify signal handling</b></a>
<a name="7.14.1.1" href="#7.14.1.1"><b> 7.14.1.1 The signal function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.14"><signal.h></a>
void (*signal(int sig, void (*func)(int)))(int);
- Description
+<b> Description</b>
2 The signal function chooses one of three ways in which receipt of the signal number
sig is to be subsequently handled. If the value of func is SIG_DFL, default handling
for that signal will occur. If the value of func is SIG_IGN, the signal will be ignored.
signal(sig, SIG_DFL);
is executed for all other signals defined by the implementation.
7 The implementation shall behave as if no library function calls the signal function.
- Returns
+<b> Returns</b>
8 If the request can be honored, the signal function returns the value of func for the
most recent successful call to signal for the specified signal sig. Otherwise, a value of
SIG_ERR is returned and a positive value is stored in errno.
_Exit function (<a href="#7.20.4.4">7.20.4.4</a>).
<a name="7.14.2" href="#7.14.2"><b> 7.14.2 Send signal</b></a>
<a name="7.14.2.1" href="#7.14.2.1"><b> 7.14.2.1 The raise function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.14"><signal.h></a>
int raise(int sig);
- Description
+<b> Description</b>
2 The raise function carries out the actions described in <a href="#7.14.1.1">7.14.1.1</a> for the signal sig. If a
signal handler is called, the raise function shall not return until after the signal handler
does.
- Returns
+<b> Returns</b>
3 The raise function returns zero if successful, nonzero if unsuccessful.
shall be matched by a corresponding invocation of the va_end macro in the same
function.
<a name="7.15.1.1" href="#7.15.1.1"><b> 7.15.1.1 The va_arg macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
type va_arg(va_list ap, type);
- Description
+<b> Description</b>
2 The va_arg macro expands to an expression that has the specified type and the value of
the next argument in the call. The parameter ap shall have been initialized by the
va_start or va_copy macro (without an intervening invocation of the va_end
-- one type is a signed integer type, the other type is the corresponding unsigned integer
type, and the value is representable in both types;
-- one type is pointer to void and the other is a pointer to a character type.
- Returns
+<b> Returns</b>
3 The first invocation of the va_arg macro after that of the va_start macro returns the
value of the argument after that specified by parmN . Successive invocations return the
values of the remaining arguments in succession.
<a name="7.15.1.2" href="#7.15.1.2"><b> 7.15.1.2 The va_copy macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
void va_copy(va_list dest, va_list src);
- Description
+<b> Description</b>
2 The va_copy macro initializes dest as a copy of src, as if the va_start macro had
been applied to dest followed by the same sequence of uses of the va_arg macro as
had previously been used to reach the present state of src. Neither the va_copy nor
va_start macro shall be invoked to reinitialize dest without an intervening
invocation of the va_end macro for the same dest.
- Returns
+<b> Returns</b>
3 The va_copy macro returns no value.
<a name="7.15.1.3" href="#7.15.1.3"><b> 7.15.1.3 The va_end macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
void va_end(va_list ap);
- Description
+<b> Description</b>
2 The va_end macro facilitates a normal return from the function whose variable
argument list was referred to by the expansion of the va_start macro, or the function
containing the expansion of the va_copy macro, that initialized the va_list ap. The
by the va_start or va_copy macro). If there is no corresponding invocation of the
va_start or va_copy macro, or if the va_end macro is not invoked before the
return, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The va_end macro returns no value.
<a name="7.15.1.4" href="#7.15.1.4"><b> 7.15.1.4 The va_start macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
void va_start(va_list ap, parmN);
- Description
+<b> Description</b>
2 The va_start macro shall be invoked before any access to the unnamed arguments.
3 The va_start macro initializes ap for subsequent use by the va_arg and va_end
macros. Neither the va_start nor va_copy macro shall be invoked to reinitialize ap
parmN is declared with the register storage class, with a function or array type, or
with a type that is not compatible with the type that results after application of the default
argument promotions, the behavior is undefined.
- Returns
+<b> Returns</b>
5 The va_start macro returns no value.
6 EXAMPLE 1 The function f1 gathers into an array a list of arguments that are pointers to strings (but not
more than MAXARGS arguments), then passes the array as a single argument to function f2. The number of
(<a href="#7.24.6.3.2">7.24.6.3.2</a>), the wcrtomb function (<a href="#7.24.6.3.3">7.24.6.3.3</a>).
<a name="7.19.4" href="#7.19.4"><b> 7.19.4 Operations on files</b></a>
<a name="7.19.4.1" href="#7.19.4.1"><b> 7.19.4.1 The remove function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int remove(const char *filename);
- Description
+<b> Description</b>
2 The remove function causes the file whose name is the string pointed to by filename
to be no longer accessible by that name. A subsequent attempt to open that file using that
name will fail, unless it is created anew. If the file is open, the behavior of the remove
function is implementation-defined.
- Returns
+<b> Returns</b>
3 The remove function returns zero if the operation succeeds, nonzero if it fails.
<a name="7.19.4.2" href="#7.19.4.2"><b> 7.19.4.2 The rename function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int rename(const char *old, const char *new);
- Description
+<b> Description</b>
2 The rename function causes the file whose name is the string pointed to by old to be
henceforth known by the name given by the string pointed to by new. The file named
old is no longer accessible by that name. If a file named by the string pointed to by new
[<a name="p268" href="#p268">page 268</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The rename function returns zero if the operation succeeds, nonzero if it fails,235) in
which case if the file existed previously it is still known by its original name.
<a name="7.19.4.3" href="#7.19.4.3"><b> 7.19.4.3 The tmpfile function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
FILE *tmpfile(void);
- Description
+<b> Description</b>
2 The tmpfile function creates a temporary binary file that is different from any other
existing file and that will automatically be removed when it is closed or at program
termination. If the program terminates abnormally, whether an open temporary file is
program (this limit may be shared with tmpnam) and there should be no limit on the
number simultaneously open other than this limit and any limit on the number of open
files (FOPEN_MAX).
- Returns
+<b> Returns</b>
4 The tmpfile function returns a pointer to the stream of the file that it created. If the file
cannot be created, the tmpfile function returns a null pointer.
Forward references: the fopen function (<a href="#7.19.5.3">7.19.5.3</a>).
<a name="7.19.4.4" href="#7.19.4.4"><b> 7.19.4.4 The tmpnam function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
char *tmpnam(char *s);
- Description
+<b> Description</b>
2 The tmpnam function generates a string that is a valid file name and that is not the same
as the name of an existing file.236) The function is potentially capable of generating
and thus not be suitable return values.
3 The tmpnam function generates a different string each time it is called.
4 The implementation shall behave as if no library function calls the tmpnam function.
- Returns
+<b> Returns</b>
5 If no suitable string can be generated, the tmpnam function returns a null pointer.
Otherwise, if the argument is a null pointer, the tmpnam function leaves its result in an
internal static object and returns a pointer to that object (subsequent calls to the tmpnam
6 The value of the macro TMP_MAX shall be at least 25.
<a name="7.19.5" href="#7.19.5"><b> 7.19.5 File access functions</b></a>
<a name="7.19.5.1" href="#7.19.5.1"><b> 7.19.5.1 The fclose function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fclose(FILE *stream);
- Description
+<b> Description</b>
2 A successful call to the fclose function causes the stream pointed to by stream to be
flushed and the associated file to be closed. Any unwritten buffered data for the stream
are delivered to the host environment to be written to the file; any unread buffered data
are discarded. Whether or not the call succeeds, the stream is disassociated from the file
and any buffer set by the setbuf or setvbuf function is disassociated from the stream
(and deallocated if it was automatically allocated).
- Returns
+<b> Returns</b>
3 The fclose function returns zero if the stream was successfully closed, or EOF if any
errors were detected.
<a name="7.19.5.2" href="#7.19.5.2"><b> 7.19.5.2 The fflush function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fflush(FILE *stream);
[<a name="p270" href="#p270">page 270</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 If stream points to an output stream or an update stream in which the most recent
operation was not input, the fflush function causes any unwritten data for that stream
to be delivered to the host environment to be written to the file; otherwise, the behavior is
undefined.
3 If stream is a null pointer, the fflush function performs this flushing action on all
streams for which the behavior is defined above.
- Returns
+<b> Returns</b>
4 The fflush function sets the error indicator for the stream and returns EOF if a write
error occurs, otherwise it returns zero.
Forward references: the fopen function (<a href="#7.19.5.3">7.19.5.3</a>).
<a name="7.19.5.3" href="#7.19.5.3"><b> 7.19.5.3 The fopen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
FILE *fopen(const char * restrict filename,
const char * restrict mode);
- Description
+<b> Description</b>
2 The fopen function opens the file whose name is the string pointed to by filename,
and associates a stream with it.
3 The argument mode points to a string. If the string is one of the following, the file is
binary stream in some implementations.
7 When opened, a stream is fully buffered if and only if it can be determined not to refer to
an interactive device. The error and end-of-file indicators for the stream are cleared.
- Returns
+<b> Returns</b>
8 The fopen function returns a pointer to the object controlling the stream. If the open
operation fails, fopen returns a null pointer.
Forward references: file positioning functions (<a href="#7.19.9">7.19.9</a>).
<a name="7.19.5.4" href="#7.19.5.4"><b> 7.19.5.4 The freopen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
FILE *freopen(const char * restrict filename,
const char * restrict mode,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The freopen function opens the file whose name is the string pointed to by filename
and associates the stream pointed to by stream with it. The mode argument is used just
4 The freopen function first attempts to close any file that is associated with the specified
stream. Failure to close the file is ignored. The error and end-of-file indicators for the
stream are cleared.
- Returns
+<b> Returns</b>
5 The freopen function returns a null pointer if the open operation fails. Otherwise,
freopen returns the value of stream.
<a name="7.19.5.5" href="#7.19.5.5"><b> 7.19.5.5 The setbuf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
void setbuf(FILE * restrict stream,
char * restrict buf);
- Description
+<b> Description</b>
2 Except that it returns no value, the setbuf function is equivalent to the setvbuf
function invoked with the values _IOFBF for mode and BUFSIZ for size, or (if buf
is a null pointer), with the value _IONBF for mode.
- Returns
+<b> Returns</b>
3 The setbuf function returns no value.
Forward references: the setvbuf function (<a href="#7.19.5.6">7.19.5.6</a>).
<a name="7.19.5.6" href="#7.19.5.6"><b> 7.19.5.6 The setvbuf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int setvbuf(FILE * restrict stream,
char * restrict buf,
[<a name="p273" href="#p273">page 273</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The setvbuf function may be used only after the stream pointed to by stream has
been associated with an open file and before any other operation (other than an
unsuccessful call to setvbuf) is performed on the stream. The argument mode
specifies the size of the array; otherwise, size may determine the size of a buffer
allocated by the setvbuf function. The contents of the array at any time are
indeterminate.
- Returns
+<b> Returns</b>
3 The setvbuf function returns zero on success, or nonzero if an invalid value is given
for mode or if the request cannot be honored.
<a name="7.19.6" href="#7.19.6"><b> 7.19.6 Formatted input/output functions</b></a>
1 The formatted input/output functions shall behave as if there is a sequence point after the
actions associated with each specifier.240)
<a name="7.19.6.1" href="#7.19.6.1"><b> 7.19.6.1 The fprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fprintf(FILE * restrict stream,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The fprintf function writes output to the stream pointed to by stream, under control
of the string pointed to by format that specifies how subsequent arguments are
converted for output. If there are insufficient arguments for the format, the behavior is
adjacent decimal strings L < U, both having DECIMAL_DIG significant digits; the value
of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that
the error should have a correct sign for the current rounding direction.
- Returns
+<b> Returns</b>
14 The fprintf function returns the number of characters transmitted, or a negative value
if an output or encoding error occurred.
Environmental limits
Forward references: conversion state (<a href="#7.24.6">7.24.6</a>), the wcrtomb function (<a href="#7.24.6.3.3">7.24.6.3.3</a>).
<a name="7.19.6.2" href="#7.19.6.2"><b> 7.19.6.2 The fscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fscanf(FILE * restrict stream,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The fscanf function reads input from the stream pointed to by stream, under control
of the string pointed to by format that specifies the admissible input sequences and how
they are to be converted for assignment, using subsequent arguments as pointers to the
15 Trailing white space (including new-line characters) is left unread unless matched by a
directive. The success of literal matches and suppressed assignments is not directly
determinable other than via the %n directive.
- Returns
+<b> Returns</b>
16 The fscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the function returns the number of input items
assigned, which can be fewer than provided for, or even zero, in the event of an early
[<a name="p289" href="#p289">page 289</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.6.3" href="#7.19.6.3"><b> 7.19.6.3 The printf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int printf(const char * restrict format, ...);
- Description
+<b> Description</b>
2 The printf function is equivalent to fprintf with the argument stdout interposed
before the arguments to printf.
- Returns
+<b> Returns</b>
3 The printf function returns the number of characters transmitted, or a negative value if
an output or encoding error occurred.
<a name="7.19.6.4" href="#7.19.6.4"><b> 7.19.6.4 The scanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int scanf(const char * restrict format, ...);
- Description
+<b> Description</b>
2 The scanf function is equivalent to fscanf with the argument stdin interposed
before the arguments to scanf.
- Returns
+<b> Returns</b>
3 The scanf function returns the value of the macro EOF if an input failure occurs before
any conversion. Otherwise, the scanf function returns the number of input items
assigned, which can be fewer than provided for, or even zero, in the event of an early
matching failure.
<a name="7.19.6.5" href="#7.19.6.5"><b> 7.19.6.5 The snprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int snprintf(char * restrict s, size_t n,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The snprintf function is equivalent to fprintf, except that the output is written into
an array (specified by argument s) rather than to a stream. If n is zero, nothing is written,
and s may be a null pointer. Otherwise, output characters beyond the n-1st are
[<a name="p290" href="#p290">page 290</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The snprintf function returns the number of characters that would have been written
had n been sufficiently large, not counting the terminating null character, or a negative
value if an encoding error occurred. Thus, the null-terminated output has been
completely written if and only if the returned value is nonnegative and less than n.
<a name="7.19.6.6" href="#7.19.6.6"><b> 7.19.6.6 The sprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int sprintf(char * restrict s,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The sprintf function is equivalent to fprintf, except that the output is written into
an array (specified by the argument s) rather than to a stream. A null character is written
at the end of the characters written; it is not counted as part of the returned value. If
copying takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The sprintf function returns the number of characters written in the array, not
counting the terminating null character, or a negative value if an encoding error occurred.
<a name="7.19.6.7" href="#7.19.6.7"><b> 7.19.6.7 The sscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int sscanf(const char * restrict s,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The sscanf function is equivalent to fscanf, except that input is obtained from a
string (specified by the argument s) rather than from a stream. Reaching the end of the
string is equivalent to encountering end-of-file for the fscanf function. If copying
takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The sscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the sscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
[<a name="p291" href="#p291">page 291</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.6.8" href="#7.19.6.8"><b> 7.19.6.8 The vfprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vfprintf(FILE * restrict stream,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfprintf function is equivalent to fprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfprintf function does not invoke the
va_end macro.254)
- Returns
+<b> Returns</b>
3 The vfprintf function returns the number of characters transmitted, or a negative
value if an output or encoding error occurred.
4 EXAMPLE The following shows the use of the vfprintf function in a general error-reporting routine.
[<a name="p292" href="#p292">page 292</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.6.9" href="#7.19.6.9"><b> 7.19.6.9 The vfscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vfscanf(FILE * restrict stream,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfscanf function is equivalent to fscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfscanf function does not invoke the
va_end macro.254)
- Returns
+<b> Returns</b>
3 The vfscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the vfscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
early matching failure.
<a name="7.19.6.10" href="#7.19.6.10"><b> 7.19.6.10 The vprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vprintf(const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vprintf function is equivalent to printf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vprintf function does not invoke the
va_end macro.254)
- Returns
+<b> Returns</b>
3 The vprintf function returns the number of characters transmitted, or a negative value
if an output or encoding error occurred.
[<a name="p293" href="#p293">page 293</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.6.11" href="#7.19.6.11"><b> 7.19.6.11 The vscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vscanf(const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vscanf function is equivalent to scanf, with the variable argument list replaced
by arg, which shall have been initialized by the va_start macro (and possibly
subsequent va_arg calls). The vscanf function does not invoke the va_end
macro.254)
- Returns
+<b> Returns</b>
3 The vscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the vscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
early matching failure.
<a name="7.19.6.12" href="#7.19.6.12"><b> 7.19.6.12 The vsnprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vsnprintf(char * restrict s, size_t n,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vsnprintf function is equivalent to snprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsnprintf function does not invoke the
va_end macro.254) If copying takes place between objects that overlap, the behavior is
undefined.
- Returns
+<b> Returns</b>
3 The vsnprintf function returns the number of characters that would have been written
had n been sufficiently large, not counting the terminating null character, or a negative
value if an encoding error occurred. Thus, the null-terminated output has been
[<a name="p294" href="#p294">page 294</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.6.13" href="#7.19.6.13"><b> 7.19.6.13 The vsprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vsprintf(char * restrict s,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vsprintf function is equivalent to sprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsprintf function does not invoke the
va_end macro.254) If copying takes place between objects that overlap, the behavior is
undefined.
- Returns
+<b> Returns</b>
3 The vsprintf function returns the number of characters written in the array, not
counting the terminating null character, or a negative value if an encoding error occurred.
<a name="7.19.6.14" href="#7.19.6.14"><b> 7.19.6.14 The vsscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
int vsscanf(const char * restrict s,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vsscanf function is equivalent to sscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsscanf function does not invoke the
va_end macro.254)
- Returns
+<b> Returns</b>
3 The vsscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the vsscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
<a name="7.19.7" href="#7.19.7"><b> 7.19.7 Character input/output functions</b></a>
<a name="7.19.7.1" href="#7.19.7.1"><b> 7.19.7.1 The fgetc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fgetc(FILE *stream);
- Description
+<b> Description</b>
2 If the end-of-file indicator for the input stream pointed to by stream is not set and a
next character is present, the fgetc function obtains that character as an unsigned
char converted to an int and advances the associated file position indicator for the
stream (if defined).
- Returns
+<b> Returns</b>
3 If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
of-file indicator for the stream is set and the fgetc function returns EOF. Otherwise, the
fgetc function returns the next character from the input stream pointed to by stream.
If a read error occurs, the error indicator for the stream is set and the fgetc function
returns EOF.255)
<a name="7.19.7.2" href="#7.19.7.2"><b> 7.19.7.2 The fgets function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
char *fgets(char * restrict s, int n,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fgets function reads at most one less than the number of characters specified by n
from the stream pointed to by stream into the array pointed to by s. No additional
characters are read after a new-line character (which is retained) or after end-of-file. A
null character is written immediately after the last character read into the array.
- Returns
+<b> Returns</b>
3 The fgets function returns s if successful. If end-of-file is encountered and no
characters have been read into the array, the contents of the array remain unchanged and a
null pointer is returned. If a read error occurs during the operation, the array contents are
[<a name="p296" href="#p296">page 296</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.7.3" href="#7.19.7.3"><b> 7.19.7.3 The fputc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fputc(int c, FILE *stream);
- Description
+<b> Description</b>
2 The fputc function writes the character specified by c (converted to an unsigned
char) to the output stream pointed to by stream, at the position indicated by the
associated file position indicator for the stream (if defined), and advances the indicator
appropriately. If the file cannot support positioning requests, or if the stream was opened
with append mode, the character is appended to the output stream.
- Returns
+<b> Returns</b>
3 The fputc function returns the character written. If a write error occurs, the error
indicator for the stream is set and fputc returns EOF.
<a name="7.19.7.4" href="#7.19.7.4"><b> 7.19.7.4 The fputs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fputs(const char * restrict s,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fputs function writes the string pointed to by s to the stream pointed to by
stream. The terminating null character is not written.
- Returns
+<b> Returns</b>
3 The fputs function returns EOF if a write error occurs; otherwise it returns a
nonnegative value.
<a name="7.19.7.5" href="#7.19.7.5"><b> 7.19.7.5 The getc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int getc(FILE *stream);
- Description
+<b> Description</b>
2 The getc function is equivalent to fgetc, except that if it is implemented as a macro, it
may evaluate stream more than once, so the argument should never be an expression
with side effects.
[<a name="p297" href="#p297">page 297</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The getc function returns the next character from the input stream pointed to by
stream. If the stream is at end-of-file, the end-of-file indicator for the stream is set and
getc returns EOF. If a read error occurs, the error indicator for the stream is set and
getc returns EOF.
<a name="7.19.7.6" href="#7.19.7.6"><b> 7.19.7.6 The getchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int getchar(void);
- Description
+<b> Description</b>
2 The getchar function is equivalent to getc with the argument stdin.
- Returns
+<b> Returns</b>
3 The getchar function returns the next character from the input stream pointed to by
stdin. If the stream is at end-of-file, the end-of-file indicator for the stream is set and
getchar returns EOF. If a read error occurs, the error indicator for the stream is set and
getchar returns EOF.
<a name="7.19.7.7" href="#7.19.7.7"><b> 7.19.7.7 The gets function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
char *gets(char *s);
- Description
+<b> Description</b>
2 The gets function reads characters from the input stream pointed to by stdin, into the
array pointed to by s, until end-of-file is encountered or a new-line character is read.
Any new-line character is discarded, and a null character is written immediately after the
last character read into the array.
- Returns
+<b> Returns</b>
3 The gets function returns s if successful. If end-of-file is encountered and no
characters have been read into the array, the contents of the array remain unchanged and a
null pointer is returned. If a read error occurs during the operation, the array contents are
[<a name="p298" href="#p298">page 298</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.7.8" href="#7.19.7.8"><b> 7.19.7.8 The putc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int putc(int c, FILE *stream);
- Description
+<b> Description</b>
2 The putc function is equivalent to fputc, except that if it is implemented as a macro, it
may evaluate stream more than once, so that argument should never be an expression
with side effects.
- Returns
+<b> Returns</b>
3 The putc function returns the character written. If a write error occurs, the error
indicator for the stream is set and putc returns EOF.
<a name="7.19.7.9" href="#7.19.7.9"><b> 7.19.7.9 The putchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int putchar(int c);
- Description
+<b> Description</b>
2 The putchar function is equivalent to putc with the second argument stdout.
- Returns
+<b> Returns</b>
3 The putchar function returns the character written. If a write error occurs, the error
indicator for the stream is set and putchar returns EOF.
<a name="7.19.7.10" href="#7.19.7.10"><b> 7.19.7.10 The puts function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int puts(const char *s);
- Description
+<b> Description</b>
2 The puts function writes the string pointed to by s to the stream pointed to by stdout,
and appends a new-line character to the output. The terminating null character is not
written.
- Returns
+<b> Returns</b>
3 The puts function returns EOF if a write error occurs; otherwise it returns a nonnegative
value.
[<a name="p299" href="#p299">page 299</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.7.11" href="#7.19.7.11"><b> 7.19.7.11 The ungetc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int ungetc(int c, FILE *stream);
- Description
+<b> Description</b>
2 The ungetc function pushes the character specified by c (converted to an unsigned
char) back onto the input stream pointed to by stream. Pushed-back characters will be
returned by subsequent reads on that stream in the reverse order of their pushing. A
For a binary stream, its file position indicator is decremented by each successful call to
the ungetc function; if its value was zero before a call, it is indeterminate after the
call.256)
- Returns
+<b> Returns</b>
6 The ungetc function returns the character pushed back after conversion, or EOF if the
operation fails.
Forward references: file positioning functions (<a href="#7.19.9">7.19.9</a>).
<a name="7.19.8" href="#7.19.8"><b> 7.19.8 Direct input/output functions</b></a>
<a name="7.19.8.1" href="#7.19.8.1"><b> 7.19.8.1 The fread function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
size_t fread(void * restrict ptr,
size_t size, size_t nmemb,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fread function reads, into the array pointed to by ptr, up to nmemb elements
whose size is specified by size, from the stream pointed to by stream. For each
object, size calls are made to the fgetc function and the results stored, in the order
indicator for the stream (if defined) is advanced by the number of characters successfully
read. If an error occurs, the resulting value of the file position indicator for the stream is
indeterminate. If a partial element is read, its value is indeterminate.
- Returns
+<b> Returns</b>
3 The fread function returns the number of elements successfully read, which may be
less than nmemb if a read error or end-of-file is encountered. If size or nmemb is zero,
fread returns zero and the contents of the array and the state of the stream remain
unchanged.
<a name="7.19.8.2" href="#7.19.8.2"><b> 7.19.8.2 The fwrite function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
size_t fwrite(const void * restrict ptr,
size_t size, size_t nmemb,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fwrite function writes, from the array pointed to by ptr, up to nmemb elements
whose size is specified by size, to the stream pointed to by stream. For each object,
size calls are made to the fputc function, taking the values (in order) from an array of
[<a name="p301" href="#p301">page 301</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The fwrite function returns the number of elements successfully written, which will be
less than nmemb only if a write error is encountered. If size or nmemb is zero,
fwrite returns zero and the state of the stream remains unchanged.
<a name="7.19.9" href="#7.19.9"><b> 7.19.9 File positioning functions</b></a>
<a name="7.19.9.1" href="#7.19.9.1"><b> 7.19.9.1 The fgetpos function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fgetpos(FILE * restrict stream,
fpos_t * restrict pos);
- Description
+<b> Description</b>
2 The fgetpos function stores the current values of the parse state (if any) and file
position indicator for the stream pointed to by stream in the object pointed to by pos.
The values stored contain unspecified information usable by the fsetpos function for
repositioning the stream to its position at the time of the call to the fgetpos function.
- Returns
+<b> Returns</b>
3 If successful, the fgetpos function returns zero; on failure, the fgetpos function
returns nonzero and stores an implementation-defined positive value in errno.
Forward references: the fsetpos function (<a href="#7.19.9.3">7.19.9.3</a>).
<a name="7.19.9.2" href="#7.19.9.2"><b> 7.19.9.2 The fseek function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fseek(FILE *stream, long int offset, int whence);
- Description
+<b> Description</b>
2 The fseek function sets the file position indicator for the stream pointed to by stream.
If a read or write error occurs, the error indicator for the stream is set and fseek fails.
3 For a binary stream, the new position, measured in characters from the beginning of the
effects of the ungetc function on the stream, clears the end-of-file indicator for the
stream, and then establishes the new position. After a successful fseek call, the next
operation on an update stream may be either input or output.
- Returns
+<b> Returns</b>
6 The fseek function returns nonzero only for a request that cannot be satisfied.
Forward references: the ftell function (<a href="#7.19.9.4">7.19.9.4</a>).
<a name="7.19.9.3" href="#7.19.9.3"><b> 7.19.9.3 The fsetpos function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int fsetpos(FILE *stream, const fpos_t *pos);
- Description
+<b> Description</b>
2 The fsetpos function sets the mbstate_t object (if any) and file position indicator
for the stream pointed to by stream according to the value of the object pointed to by
pos, which shall be a value obtained from an earlier successful call to the fgetpos
on the stream, clears the end-of-file indicator for the stream, and then establishes the new
parse state and position. After a successful fsetpos call, the next operation on an
update stream may be either input or output.
- Returns
+<b> Returns</b>
4 If successful, the fsetpos function returns zero; on failure, the fsetpos function
returns nonzero and stores an implementation-defined positive value in errno.
<a name="7.19.9.4" href="#7.19.9.4"><b> 7.19.9.4 The ftell function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
long int ftell(FILE *stream);
- Description
+<b> Description</b>
2 The ftell function obtains the current value of the file position indicator for the stream
pointed to by stream. For a binary stream, the value is the number of characters from
the beginning of the file. For a text stream, its file position indicator contains unspecified
[<a name="p303" href="#p303">page 303</a>] (<a href="#Contents">Contents</a>)
or read.
- Returns
+<b> Returns</b>
3 If successful, the ftell function returns the current value of the file position indicator
for the stream. On failure, the ftell function returns -1L and stores an
implementation-defined positive value in errno.
<a name="7.19.9.5" href="#7.19.9.5"><b> 7.19.9.5 The rewind function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
void rewind(FILE *stream);
- Description
+<b> Description</b>
2 The rewind function sets the file position indicator for the stream pointed to by
stream to the beginning of the file. It is equivalent to
(void)fseek(stream, 0L, SEEK_SET)
except that the error indicator for the stream is also cleared.
- Returns
+<b> Returns</b>
3 The rewind function returns no value.
<a name="7.19.10" href="#7.19.10"><b> 7.19.10 Error-handling functions</b></a>
<a name="7.19.10.1" href="#7.19.10.1"><b> 7.19.10.1 The clearerr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
void clearerr(FILE *stream);
- Description
+<b> Description</b>
2 The clearerr function clears the end-of-file and error indicators for the stream pointed
to by stream.
- Returns
+<b> Returns</b>
3 The clearerr function returns no value.
[<a name="p304" href="#p304">page 304</a>] (<a href="#Contents">Contents</a>)
<a name="7.19.10.2" href="#7.19.10.2"><b> 7.19.10.2 The feof function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int feof(FILE *stream);
- Description
+<b> Description</b>
2 The feof function tests the end-of-file indicator for the stream pointed to by stream.
- Returns
+<b> Returns</b>
3 The feof function returns nonzero if and only if the end-of-file indicator is set for
stream.
<a name="7.19.10.3" href="#7.19.10.3"><b> 7.19.10.3 The ferror function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
int ferror(FILE *stream);
- Description
+<b> Description</b>
2 The ferror function tests the error indicator for the stream pointed to by stream.
- Returns
+<b> Returns</b>
3 The ferror function returns nonzero if and only if the error indicator is set for
stream.
<a name="7.19.10.4" href="#7.19.10.4"><b> 7.19.10.4 The perror function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
void perror(const char *s);
- Description
+<b> Description</b>
2 The perror function maps the error number in the integer expression errno to an
error message. It writes a sequence of characters to the standard error stream thus: first
(if s is not a null pointer and the character pointed to by s is not the null character), the
string pointed to by s followed by a colon (:) and a space; then an appropriate error
message string followed by a new-line character. The contents of the error message
strings are the same as those returned by the strerror function with argument errno.
- Returns
+<b> Returns</b>
3 The perror function returns no value.
Forward references: the strerror function (<a href="#7.21.6.2">7.21.6.2</a>).
expression errno on an error. If the value of the result cannot be represented, the
behavior is undefined.
<a name="7.20.1.1" href="#7.20.1.1"><b> 7.20.1.1 The atof function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
double atof(const char *nptr);
- Description
+<b> Description</b>
2 The atof function converts the initial portion of the string pointed to by nptr to
double representation. Except for the behavior on error, it is equivalent to
strtod(nptr, (char **)NULL)
- Returns
+<b> Returns</b>
3 The atof function returns the converted value.
Forward references: the strtod, strtof, and strtold functions (<a href="#7.20.1.3">7.20.1.3</a>).
<a name="7.20.1.2" href="#7.20.1.2"><b> 7.20.1.2 The atoi, atol, and atoll functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int atoi(const char *nptr);
long int atol(const char *nptr);
long long int atoll(const char *nptr);
- Description
+<b> Description</b>
2 The atoi, atol, and atoll functions convert the initial portion of the string pointed
to by nptr to int, long int, and long long int representation, respectively.
Except for the behavior on error, they are equivalent to
atoi: (int)strtol(nptr, (char **)NULL, 10)
atol: strtol(nptr, (char **)NULL, 10)
atoll: strtoll(nptr, (char **)NULL, 10)
- Returns
+<b> Returns</b>
3 The atoi, atol, and atoll functions return the converted value.
Forward references: the strtol, strtoll, strtoul, and strtoull functions
(<a href="#7.20.1.4">7.20.1.4</a>).
[<a name="p307" href="#p307">page 307</a>] (<a href="#Contents">Contents</a>)
<a name="7.20.1.3" href="#7.20.1.3"><b> 7.20.1.3 The strtod, strtof, and strtold functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
double strtod(const char * restrict nptr,
char ** restrict endptr);
char ** restrict endptr);
long double strtold(const char * restrict nptr,
char ** restrict endptr);
- Description
+<b> Description</b>
2 The strtod, strtof, and strtold functions convert the initial portion of the string
pointed to by nptr to double, float, and long double representation,
respectively. First, they decompose the input string into three parts: an initial, possibly
stipulation that the error with respect to D should have a correct sign for the current
rounding direction.260)
- Returns
+<b> Returns</b>
10 The functions return the converted value, if any. If no conversion could be performed,
zero is returned. If the correct value is outside the range of representable values, plus or
minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the return
than the smallest normalized positive number in the return type; whether errno acquires
the value ERANGE is implementation-defined.
<a name="7.20.1.4" href="#7.20.1.4"><b> 7.20.1.4 The strtol, strtoll, strtoul, and strtoull functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
long int strtol(
const char * restrict nptr,
const char * restrict nptr,
char ** restrict endptr,
int base);
- Description
+<b> Description</b>
2 The strtol, strtoll, strtoul, and strtoull functions convert the initial
portion of the string pointed to by nptr to long int, long long int, unsigned
long int, and unsigned long long int representation, respectively. First,
7 If the subject sequence is empty or does not have the expected form, no conversion is
performed; the value of nptr is stored in the object pointed to by endptr, provided
that endptr is not a null pointer.
- Returns
+<b> Returns</b>
8 The strtol, strtoll, strtoul, and strtoull functions return the converted
value, if any. If no conversion could be performed, zero is returned. If the correct value
is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,
<a name="7.20.2" href="#7.20.2"><b> 7.20.2 Pseudo-random sequence generation functions</b></a>
<a name="7.20.2.1" href="#7.20.2.1"><b> 7.20.2.1 The rand function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int rand(void);
- Description
+<b> Description</b>
2 The rand function computes a sequence of pseudo-random integers in the range 0 to
RAND_MAX.
3 The implementation shall behave as if no library function calls the rand function.
- Returns
+<b> Returns</b>
4 The rand function returns a pseudo-random integer.
Environmental limits
5 The value of the RAND_MAX macro shall be at least 32767.
<a name="7.20.2.2" href="#7.20.2.2"><b> 7.20.2.2 The srand function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void srand(unsigned int seed);
- Description
+<b> Description</b>
2 The srand function uses the argument as a seed for a new sequence of pseudo-random
numbers to be returned by subsequent calls to rand. If srand is then called with the
same seed value, the sequence of pseudo-random numbers shall be repeated. If rand is
called before any calls to srand have been made, the same sequence shall be generated
as when srand is first called with a seed value of 1.
3 The implementation shall behave as if no library function calls the srand function.
- Returns
+<b> Returns</b>
4 The srand function returns no value.
5 EXAMPLE The following functions define a portable implementation of rand and srand.
static unsigned long int next = 1;
defined: either a null pointer is returned, or the behavior is as if the size were some
nonzero value, except that the returned pointer shall not be used to access an object.
<a name="7.20.3.1" href="#7.20.3.1"><b> 7.20.3.1 The calloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void *calloc(size_t nmemb, size_t size);
- Description
+<b> Description</b>
2 The calloc function allocates space for an array of nmemb objects, each of whose size
is size. The space is initialized to all bits zero.261)
- Returns
+<b> Returns</b>
3 The calloc function returns either a null pointer or a pointer to the allocated space.
<a name="7.20.3.2" href="#7.20.3.2"><b> 7.20.3.2 The free function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void free(void *ptr);
- Description
+<b> Description</b>
2 The free function causes the space pointed to by ptr to be deallocated, that is, made
available for further allocation. If ptr is a null pointer, no action occurs. Otherwise, if
the argument does not match a pointer earlier returned by the calloc, malloc, or
realloc function, or if the space has been deallocated by a call to free or realloc,
the behavior is undefined.
- Returns
+<b> Returns</b>
3 The free function returns no value.
<a name="7.20.3.3" href="#7.20.3.3"><b> 7.20.3.3 The malloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void *malloc(size_t size);
- Description
+<b> Description</b>
2 The malloc function allocates space for an object whose size is specified by size and
whose value is indeterminate.
- Returns
+<b> Returns</b>
3 The malloc function returns either a null pointer or a pointer to the allocated space.
<a name="7.20.3.4" href="#7.20.3.4"><b> 7.20.3.4 The realloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void *realloc(void *ptr, size_t size);
- Description
+<b> Description</b>
2 The realloc function deallocates the old object pointed to by ptr and returns a
pointer to a new object that has the size specified by size. The contents of the new
object shall be the same as that of the old object prior to deallocation, up to the lesser of
calloc, malloc, or realloc function, or if the space has been deallocated by a call
to the free or realloc function, the behavior is undefined. If memory for the new
object cannot be allocated, the old object is not deallocated and its value is unchanged.
- Returns
+<b> Returns</b>
4 The realloc function returns a pointer to the new object (which may have the same
value as a pointer to the old object), or a null pointer if the new object could not be
allocated.
<a name="7.20.4" href="#7.20.4"><b> 7.20.4 Communication with the environment</b></a>
<a name="7.20.4.1" href="#7.20.4.1"><b> 7.20.4.1 The abort function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void abort(void);
- Description
+<b> Description</b>
2 The abort function causes abnormal program termination to occur, unless the signal
SIGABRT is being caught and the signal handler does not return. Whether open streams
with unwritten buffered data are flushed, open streams are closed, or temporary files are
removed is implementation-defined. An implementation-defined form of the status
unsuccessful termination is returned to the host environment by means of the function
call raise(SIGABRT).
- Returns
+<b> Returns</b>
3 The abort function does not return to its caller.
<a name="7.20.4.2" href="#7.20.4.2"><b> 7.20.4.2 The atexit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int atexit(void (*func)(void));
- Description
+<b> Description</b>
2 The atexit function registers the function pointed to by func, to be called without
arguments at normal program termination.
Environmental limits
3 The implementation shall support the registration of at least 32 functions.
- Returns
+<b> Returns</b>
4 The atexit function returns zero if the registration succeeds, nonzero if it fails.
Forward references: the exit function (<a href="#7.20.4.3">7.20.4.3</a>).
<a name="7.20.4.3" href="#7.20.4.3"><b> 7.20.4.3 The exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void exit(int status);
- Description
+<b> Description</b>
2 The exit function causes normal program termination to occur. If more than one call to
the exit function is executed by a program, the behavior is undefined.
[<a name="p315" href="#p315">page 315</a>] (<a href="#Contents">Contents</a>)
returned. If the value of status is EXIT_FAILURE, an implementation-defined form
of the status unsuccessful termination is returned. Otherwise the status returned is
implementation-defined.
- Returns
+<b> Returns</b>
6 The exit function cannot return to its caller.
<a name="7.20.4.4" href="#7.20.4.4"><b> 7.20.4.4 The _Exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void _Exit(int status);
- Description
+<b> Description</b>
2 The _Exit function causes normal program termination to occur and control to be
returned to the host environment. No functions registered by the atexit function or
signal handlers registered by the signal function are called. The status returned to the
host environment is determined in the same way as for the exit function (<a href="#7.20.4.3">7.20.4.3</a>).
Whether open streams with unwritten buffered data are flushed, open streams are closed,
or temporary files are removed is implementation-defined.
- Returns
+<b> Returns</b>
3 The _Exit function cannot return to its caller.
[<a name="p316" href="#p316">page 316</a>] (<a href="#Contents">Contents</a>)
<a name="7.20.4.5" href="#7.20.4.5"><b> 7.20.4.5 The getenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
char *getenv(const char *name);
- Description
+<b> Description</b>
2 The getenv function searches an environment list, provided by the host environment,
for a string that matches the string pointed to by name. The set of environment names
and the method for altering the environment list are implementation-defined.
3 The implementation shall behave as if no library function calls the getenv function.
- Returns
+<b> Returns</b>
4 The getenv function returns a pointer to a string associated with the matched list
member. The string pointed to shall not be modified by the program, but may be
overwritten by a subsequent call to the getenv function. If the specified name cannot
be found, a null pointer is returned.
<a name="7.20.4.6" href="#7.20.4.6"><b> 7.20.4.6 The system function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int system(const char *string);
- Description
+<b> Description</b>
2 If string is a null pointer, the system function determines whether the host
environment has a command processor. If string is not a null pointer, the system
function passes the string pointed to by string to that command processor to be
executed in a manner which the implementation shall document; this might then cause the
program calling system to behave in a non-conforming manner or to terminate.
- Returns
+<b> Returns</b>
3 If the argument is a null pointer, the system function returns nonzero only if a
command processor is available. If the argument is not a null pointer, and the system
function does return, it returns an implementation-defined value.
comparison function, and also between any call to the comparison function and any
movement of the objects passed as arguments to that call.
<a name="7.20.5.1" href="#7.20.5.1"><b> 7.20.5.1 The bsearch function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
- Description
+<b> Description</b>
2 The bsearch function searches an array of nmemb objects, the initial element of which
is pointed to by base, for an element that matches the object pointed to by key. The
respectively, to be less than, to match, or to be greater than the array element. The array
shall consist of: all the elements that compare less than, all the elements that compare
equal to, and all the elements that compare greater than the key object, in that order.264)
- Returns
+<b> Returns</b>
4 The bsearch function returns a pointer to a matching element of the array, or a null
pointer if no match is found. If two elements compare as equal, which element is
matched is unspecified.
<a name="7.20.5.2" href="#7.20.5.2"><b> 7.20.5.2 The qsort function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
- Description
+<b> Description</b>
2 The qsort function sorts an array of nmemb objects, the initial element of which is
pointed to by base. The size of each object is specified by size.
3 The contents of the array are sorted into ascending order according to a comparison
greater than zero if the first argument is considered to be respectively less than, equal to,
or greater than the second.
4 If two elements compare as equal, their order in the resulting sorted array is unspecified.
- Returns
+<b> Returns</b>
5 The qsort function returns no value.
<a name="7.20.6" href="#7.20.6"><b> 7.20.6 Integer arithmetic functions</b></a>
<a name="7.20.6.1" href="#7.20.6.1"><b> 7.20.6.1 The abs, labs and llabs functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);
- Description
+<b> Description</b>
2 The abs, labs, and llabs functions compute the absolute value of an integer j. If the
result cannot be represented, the behavior is undefined.265)
- Returns
+<b> Returns</b>
3 The abs, labs, and llabs, functions return the absolute value.
<a name="7.20.6.2" href="#7.20.6.2"><b> 7.20.6.2 The div, ldiv, and lldiv functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
div_t div(int numer, int denom);
ldiv_t ldiv(long int numer, long int denom);
lldiv_t lldiv(long long int numer, long long int denom);
- Description
+<b> Description</b>
2 The div, ldiv, and lldiv, functions compute numer / denom and numer %
denom in a single operation.
- Returns
+<b> Returns</b>
3 The div, ldiv, and lldiv functions return a structure of type div_t, ldiv_t, and
lldiv_t, respectively, comprising both the quotient and the remainder. The structures
shall contain (in either order) the members quot (the quotient) and rem (the remainder),
otherwise.266) Changing the LC_CTYPE category causes the conversion state of these
functions to be indeterminate.
<a name="7.20.7.1" href="#7.20.7.1"><b> 7.20.7.1 The mblen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int mblen(const char *s, size_t n);
- Description
+<b> Description</b>
2 If s is not a null pointer, the mblen function determines the number of bytes contained
in the multibyte character pointed to by s. Except that the conversion state of the
mbtowc function is not affected, it is equivalent to
mbtowc((wchar_t *)0, s, n);
3 The implementation shall behave as if no library function calls the mblen function.
- Returns
+<b> Returns</b>
4 If s is a null pointer, the mblen function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the mblen function either returns 0 (if s points to the null character),
[<a name="p321" href="#p321">page 321</a>] (<a href="#Contents">Contents</a>)
<a name="7.20.7.2" href="#7.20.7.2"><b> 7.20.7.2 The mbtowc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int mbtowc(wchar_t * restrict pwc,
const char * restrict s,
size_t n);
- Description
+<b> Description</b>
2 If s is not a null pointer, the mbtowc function inspects at most n bytes beginning with
the byte pointed to by s to determine the number of bytes needed to complete the next
multibyte character (including any shift sequences). If the function determines that the
the object pointed to by pwc. If the corresponding wide character is the null wide
character, the function is left in the initial conversion state.
3 The implementation shall behave as if no library function calls the mbtowc function.
- Returns
+<b> Returns</b>
4 If s is a null pointer, the mbtowc function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the mbtowc function either returns 0 (if s points to the null character),
5 In no case will the value returned be greater than n or the value of the MB_CUR_MAX
macro.
<a name="7.20.7.3" href="#7.20.7.3"><b> 7.20.7.3 The wctomb function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
int wctomb(char *s, wchar_t wc);
- Description
+<b> Description</b>
2 The wctomb function determines the number of bytes needed to represent the multibyte
character corresponding to the wide character given by wc (including any shift
sequences), and stores the multibyte character representation in the array whose first
[<a name="p322" href="#p322">page 322</a>] (<a href="#Contents">Contents</a>)
3 The implementation shall behave as if no library function calls the wctomb function.
- Returns
+<b> Returns</b>
4 If s is a null pointer, the wctomb function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the wctomb function returns -1 if the value of wc does not correspond
1 The behavior of the multibyte string functions is affected by the LC_CTYPE category of
the current locale.
<a name="7.20.8.1" href="#7.20.8.1"><b> 7.20.8.1 The mbstowcs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
size_t mbstowcs(wchar_t * restrict pwcs,
const char * restrict s,
size_t n);
- Description
+<b> Description</b>
2 The mbstowcs function converts a sequence of multibyte characters that begins in the
initial shift state from the array pointed to by s into a sequence of corresponding wide
characters and stores not more than n wide characters into the array pointed to by pwcs.
not affected.
3 No more than n elements will be modified in the array pointed to by pwcs. If copying
takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
4 If an invalid multibyte character is encountered, the mbstowcs function returns
(size_t)(-1). Otherwise, the mbstowcs function returns the number of array
elements modified, not including a terminating null wide character, if any.267)
[<a name="p323" href="#p323">page 323</a>] (<a href="#Contents">Contents</a>)
<a name="7.20.8.2" href="#7.20.8.2"><b> 7.20.8.2 The wcstombs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.20"><stdlib.h></a>
size_t wcstombs(char * restrict s,
const wchar_t * restrict pwcs,
size_t n);
- Description
+<b> Description</b>
2 The wcstombs function converts a sequence of wide characters from the array pointed
to by pwcs into a sequence of corresponding multibyte characters that begins in the
initial shift state, and stores these multibyte characters into the array pointed to by s,
function, except that the conversion state of the wctomb function is not affected.
3 No more than n bytes will be modified in the array pointed to by s. If copying takes place
between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
4 If a wide character is encountered that does not correspond to a valid multibyte character,
the wcstombs function returns (size_t)(-1). Otherwise, the wcstombs function
returns the number of bytes modified, not including a terminating null character, if
different value).
<a name="7.21.2" href="#7.21.2"><b> 7.21.2 Copying functions</b></a>
<a name="7.21.2.1" href="#7.21.2.1"><b> 7.21.2.1 The memcpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
void *memcpy(void * restrict s1,
const void * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The memcpy function copies n characters from the object pointed to by s2 into the
object pointed to by s1. If copying takes place between objects that overlap, the behavior
is undefined.
- Returns
+<b> Returns</b>
3 The memcpy function returns the value of s1.
[<a name="p325" href="#p325">page 325</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.2.2" href="#7.21.2.2"><b> 7.21.2.2 The memmove function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
void *memmove(void *s1, const void *s2, size_t n);
- Description
+<b> Description</b>
2 The memmove function copies n characters from the object pointed to by s2 into the
object pointed to by s1. Copying takes place as if the n characters from the object
pointed to by s2 are first copied into a temporary array of n characters that does not
overlap the objects pointed to by s1 and s2, and then the n characters from the
temporary array are copied into the object pointed to by s1.
- Returns
+<b> Returns</b>
3 The memmove function returns the value of s1.
<a name="7.21.2.3" href="#7.21.2.3"><b> 7.21.2.3 The strcpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strcpy(char * restrict s1,
const char * restrict s2);
- Description
+<b> Description</b>
2 The strcpy function copies the string pointed to by s2 (including the terminating null
character) into the array pointed to by s1. If copying takes place between objects that
overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The strcpy function returns the value of s1.
<a name="7.21.2.4" href="#7.21.2.4"><b> 7.21.2.4 The strncpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strncpy(char * restrict s1,
const char * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The strncpy function copies not more than n characters (characters that follow a null
character are not copied) from the array pointed to by s2 to the array pointed to by
3 If the array pointed to by s2 is a string that is shorter than n characters, null characters
are appended to the copy in the array pointed to by s1, until n characters in all have been
written.
- Returns
+<b> Returns</b>
4 The strncpy function returns the value of s1.
<a name="7.21.3" href="#7.21.3"><b> 7.21.3 Concatenation functions</b></a>
<a name="7.21.3.1" href="#7.21.3.1"><b> 7.21.3.1 The strcat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strcat(char * restrict s1,
const char * restrict s2);
- Description
+<b> Description</b>
2 The strcat function appends a copy of the string pointed to by s2 (including the
terminating null character) to the end of the string pointed to by s1. The initial character
of s2 overwrites the null character at the end of s1. If copying takes place between
objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The strcat function returns the value of s1.
<a name="7.21.3.2" href="#7.21.3.2"><b> 7.21.3.2 The strncat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strncat(char * restrict s1,
const char * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The strncat function appends not more than n characters (a null character and
characters that follow it are not appended) from the array pointed to by s2 to the end of
the string pointed to by s1. The initial character of s2 overwrites the null character at the
[<a name="p327" href="#p327">page 327</a>] (<a href="#Contents">Contents</a>)
takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The strncat function returns the value of s1.
Forward references: the strlen function (<a href="#7.21.6.3">7.21.6.3</a>).
<a name="7.21.4" href="#7.21.4"><b> 7.21.4 Comparison functions</b></a>
pair of characters (both interpreted as unsigned char) that differ in the objects being
compared.
<a name="7.21.4.1" href="#7.21.4.1"><b> 7.21.4.1 The memcmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
int memcmp(const void *s1, const void *s2, size_t n);
- Description
+<b> Description</b>
2 The memcmp function compares the first n characters of the object pointed to by s1 to
the first n characters of the object pointed to by s2.271)
- Returns
+<b> Returns</b>
3 The memcmp function returns an integer greater than, equal to, or less than zero,
accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
pointed to by s2.
<a name="7.21.4.2" href="#7.21.4.2"><b> 7.21.4.2 The strcmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
int strcmp(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strcmp function compares the string pointed to by s1 to the string pointed to by
s2.
- Returns
+<b> Returns</b>
3 The strcmp function returns an integer greater than, equal to, or less than zero,
accordingly as the string pointed to by s1 is greater than, equal to, or less than the string
pointed to by s2.
<a name="7.21.4.3" href="#7.21.4.3"><b> 7.21.4.3 The strcoll function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
int strcoll(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strcoll function compares the string pointed to by s1 to the string pointed to by
s2, both interpreted as appropriate to the LC_COLLATE category of the current locale.
- Returns
+<b> Returns</b>
3 The strcoll function returns an integer greater than, equal to, or less than zero,
accordingly as the string pointed to by s1 is greater than, equal to, or less than the string
pointed to by s2 when both are interpreted as appropriate to the current locale.
<a name="7.21.4.4" href="#7.21.4.4"><b> 7.21.4.4 The strncmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
int strncmp(const char *s1, const char *s2, size_t n);
- Description
+<b> Description</b>
2 The strncmp function compares not more than n characters (characters that follow a
null character are not compared) from the array pointed to by s1 to the array pointed to
by s2.
- Returns
+<b> Returns</b>
3 The strncmp function returns an integer greater than, equal to, or less than zero,
accordingly as the possibly null-terminated array pointed to by s1 is greater than, equal
to, or less than the possibly null-terminated array pointed to by s2.
<a name="7.21.4.5" href="#7.21.4.5"><b> 7.21.4.5 The strxfrm function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
size_t strxfrm(char * restrict s1,
const char * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The strxfrm function transforms the string pointed to by s2 and places the resulting
string into the array pointed to by s1. The transformation is such that if the strcmp
function is applied to two transformed strings, it returns a value greater than, equal to, or
pointed to by s1, including the terminating null character. If n is zero, s1 is permitted to
be a null pointer. If copying takes place between objects that overlap, the behavior is
undefined.
- Returns
+<b> Returns</b>
3 The strxfrm function returns the length of the transformed string (not including the
terminating null character). If the value returned is n or more, the contents of the array
pointed to by s1 are indeterminate.
<a name="7.21.5" href="#7.21.5"><b> 7.21.5 Search functions</b></a>
<a name="7.21.5.1" href="#7.21.5.1"><b> 7.21.5.1 The memchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
void *memchr(const void *s, int c, size_t n);
- Description
+<b> Description</b>
2 The memchr function locates the first occurrence of c (converted to an unsigned
char) in the initial n characters (each interpreted as unsigned char) of the object
pointed to by s.
- Returns
+<b> Returns</b>
3 The memchr function returns a pointer to the located character, or a null pointer if the
character does not occur in the object.
<a name="7.21.5.2" href="#7.21.5.2"><b> 7.21.5.2 The strchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strchr(const char *s, int c);
- Description
+<b> Description</b>
2 The strchr function locates the first occurrence of c (converted to a char) in the
string pointed to by s. The terminating null character is considered to be part of the
string.
- Returns
+<b> Returns</b>
3 The strchr function returns a pointer to the located character, or a null pointer if the
character does not occur in the string.
[<a name="p330" href="#p330">page 330</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.5.3" href="#7.21.5.3"><b> 7.21.5.3 The strcspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
size_t strcspn(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strcspn function computes the length of the maximum initial segment of the string
pointed to by s1 which consists entirely of characters not from the string pointed to by
s2.
- Returns
+<b> Returns</b>
3 The strcspn function returns the length of the segment.
<a name="7.21.5.4" href="#7.21.5.4"><b> 7.21.5.4 The strpbrk function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strpbrk(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strpbrk function locates the first occurrence in the string pointed to by s1 of any
character from the string pointed to by s2.
- Returns
+<b> Returns</b>
3 The strpbrk function returns a pointer to the character, or a null pointer if no character
from s2 occurs in s1.
<a name="7.21.5.5" href="#7.21.5.5"><b> 7.21.5.5 The strrchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strrchr(const char *s, int c);
- Description
+<b> Description</b>
2 The strrchr function locates the last occurrence of c (converted to a char) in the
string pointed to by s. The terminating null character is considered to be part of the
string.
- Returns
+<b> Returns</b>
3 The strrchr function returns a pointer to the character, or a null pointer if c does not
occur in the string.
[<a name="p331" href="#p331">page 331</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.5.6" href="#7.21.5.6"><b> 7.21.5.6 The strspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
size_t strspn(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strspn function computes the length of the maximum initial segment of the string
pointed to by s1 which consists entirely of characters from the string pointed to by s2.
- Returns
+<b> Returns</b>
3 The strspn function returns the length of the segment.
<a name="7.21.5.7" href="#7.21.5.7"><b> 7.21.5.7 The strstr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strstr(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strstr function locates the first occurrence in the string pointed to by s1 of the
sequence of characters (excluding the terminating null character) in the string pointed to
by s2.
- Returns
+<b> Returns</b>
3 The strstr function returns a pointer to the located string, or a null pointer if the string
is not found. If s2 points to a string with zero length, the function returns s1.
<a name="7.21.5.8" href="#7.21.5.8"><b> 7.21.5.8 The strtok function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strtok(char * restrict s1,
const char * restrict s2);
- Description
+<b> Description</b>
2 A sequence of calls to the strtok function breaks the string pointed to by s1 into a
sequence of tokens, each of which is delimited by a character from the string pointed to
by s2. The first call in the sequence has a non-null first argument; subsequent calls in the
5 Each subsequent call, with a null pointer as the value of the first argument, starts
searching from the saved pointer and behaves as described above.
6 The implementation shall behave as if no library function calls the strtok function.
- Returns
+<b> Returns</b>
7 The strtok function returns a pointer to the first character of a token, or a null pointer
if there is no token.
8 EXAMPLE
<a name="7.21.6" href="#7.21.6"><b> 7.21.6 Miscellaneous functions</b></a>
<a name="7.21.6.1" href="#7.21.6.1"><b> 7.21.6.1 The memset function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
void *memset(void *s, int c, size_t n);
- Description
+<b> Description</b>
2 The memset function copies the value of c (converted to an unsigned char) into
each of the first n characters of the object pointed to by s.
- Returns
+<b> Returns</b>
3 The memset function returns the value of s.
[<a name="p333" href="#p333">page 333</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.6.2" href="#7.21.6.2"><b> 7.21.6.2 The strerror function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
char *strerror(int errnum);
- Description
+<b> Description</b>
2 The strerror function maps the number in errnum to a message string. Typically,
the values for errnum come from errno, but strerror shall map any value of type
int to a message.
3 The implementation shall behave as if no library function calls the strerror function.
- Returns
+<b> Returns</b>
4 The strerror function returns a pointer to the string, the contents of which are locale-
specific. The array pointed to shall not be modified by the program, but may be
overwritten by a subsequent call to the strerror function.
<a name="7.21.6.3" href="#7.21.6.3"><b> 7.21.6.3 The strlen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><string.h></a>
size_t strlen(const char *s);
- Description
+<b> Description</b>
2 The strlen function computes the length of the string pointed to by s.
- Returns
+<b> Returns</b>
3 The strlen function returns the number of characters that precede the terminating null
character.
Saving Time is not in effect, and negative if the information is not available.
<a name="7.23.2" href="#7.23.2"><b> 7.23.2 Time manipulation functions</b></a>
<a name="7.23.2.1" href="#7.23.2.1"><b> 7.23.2.1 The clock function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
clock_t clock(void);
- Description
+<b> Description</b>
2 The clock function determines the processor time used.
- Returns
+<b> Returns</b>
3 The clock function returns the implementation's best approximation to the processor
time used by the program since the beginning of an implementation-defined era related
only to the program invocation. To determine the time in seconds, the value returned by
the processor time used is not available or its value cannot be represented, the function
returns the value (clock_t)(-1).275)
<a name="7.23.2.2" href="#7.23.2.2"><b> 7.23.2.2 The difftime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
double difftime(time_t time1, time_t time0);
- Description
+<b> Description</b>
2 The difftime function computes the difference between two calendar times: time1 -
time0.
- Returns
+<b> Returns</b>
3 The difftime function returns the difference expressed in seconds as a double.
[<a name="p339" href="#p339">page 339</a>] (<a href="#Contents">Contents</a>)
<a name="7.23.2.3" href="#7.23.2.3"><b> 7.23.2.3 The mktime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
time_t mktime(struct tm *timeptr);
- Description
+<b> Description</b>
2 The mktime function converts the broken-down time, expressed as local time, in the
structure pointed to by timeptr into a calendar time value with the same encoding as
that of the values returned by the time function. The original values of the tm_wday
set appropriately, and the other components are set to represent the specified calendar
time, but with their values forced to the ranges indicated above; the final value of
tm_mday is not set until tm_mon and tm_year are determined.
- Returns
+<b> Returns</b>
3 The mktime function returns the specified calendar time encoded as a value of type
time_t. If the calendar time cannot be represented, the function returns the value
(time_t)(-1).
printf("%s\n", wday[time_str.tm_wday]);
<a name="7.23.2.4" href="#7.23.2.4"><b> 7.23.2.4 The time function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
time_t time(time_t *timer);
- Description
+<b> Description</b>
2 The time function determines the current calendar time. The encoding of the value is
unspecified.
- Returns
+<b> Returns</b>
3 The time function returns the implementation's best approximation to the current
calendar time. The value (time_t)(-1) is returned if the calendar time is not
available. If timer is not a null pointer, the return value is also assigned to the object it
previous call to any of them. The implementation shall behave as if no other library
functions call these functions.
<a name="7.23.3.1" href="#7.23.3.1"><b> 7.23.3.1 The asctime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
char *asctime(const struct tm *timeptr);
- Description
+<b> Description</b>
2 The asctime function converts the broken-down time in the structure pointed to by
timeptr into a string in the form
Sun Sep 16 01:03:52 1973\n\0
1900 + timeptr->tm_year);
return result;
}
- Returns
+<b> Returns</b>
3 The asctime function returns a pointer to the string.
<a name="7.23.3.2" href="#7.23.3.2"><b> 7.23.3.2 The ctime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
char *ctime(const time_t *timer);
- Description
+<b> Description</b>
2 The ctime function converts the calendar time pointed to by timer to local time in the
form of a string. It is equivalent to
asctime(localtime(timer))
- Returns
+<b> Returns</b>
3 The ctime function returns the pointer returned by the asctime function with that
broken-down time as argument.
Forward references: the localtime function (<a href="#7.23.3.4">7.23.3.4</a>).
[<a name="p342" href="#p342">page 342</a>] (<a href="#Contents">Contents</a>)
<a name="7.23.3.3" href="#7.23.3.3"><b> 7.23.3.3 The gmtime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
struct tm *gmtime(const time_t *timer);
- Description
+<b> Description</b>
2 The gmtime function converts the calendar time pointed to by timer into a broken-
down time, expressed as UTC.
- Returns
+<b> Returns</b>
3 The gmtime function returns a pointer to the broken-down time, or a null pointer if the
specified time cannot be converted to UTC.
<a name="7.23.3.4" href="#7.23.3.4"><b> 7.23.3.4 The localtime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
struct tm *localtime(const time_t *timer);
- Description
+<b> Description</b>
2 The localtime function converts the calendar time pointed to by timer into a
broken-down time, expressed as local time.
- Returns
+<b> Returns</b>
3 The localtime function returns a pointer to the broken-down time, or a null pointer if
the specified time cannot be converted to local time.
<a name="7.23.3.5" href="#7.23.3.5"><b> 7.23.3.5 The strftime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
size_t strftime(char * restrict s,
size_t maxsize,
const char * restrict format,
const struct tm * restrict timeptr);
- Description
+<b> Description</b>
2 The strftime function places characters into the array pointed to by s as controlled by
the string pointed to by format. The format shall be a multibyte character sequence,
beginning and ending in its initial shift state. The format string consists of zero or
[<a name="p346" href="#p346">page 346</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
8 If the total number of resulting characters including the terminating null character is not
more than maxsize, the strftime function returns the number of characters placed
into the array pointed to by s not including the terminating null character. Otherwise,
1 The formatted wide character input/output functions shall behave as if there is a sequence
point after the actions associated with each specifier.280)
<a name="7.24.2.1" href="#7.24.2.1"><b> 7.24.2.1 The fwprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int fwprintf(FILE * restrict stream,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The fwprintf function writes output to the stream pointed to by stream, under
control of the wide string pointed to by format that specifies how subsequent arguments
are converted for output. If there are insufficient arguments for the format, the behavior
adjacent decimal strings L < U, both having DECIMAL_DIG significant digits; the value
of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that
the error should have a correct sign for the current rounding direction.
- Returns
+<b> Returns</b>
14 The fwprintf function returns the number of wide characters transmitted, or a negative
value if an output or encoding error occurred.
Forward references: the btowc function (<a href="#7.24.6.1.1">7.24.6.1.1</a>), the mbrtowc function
(<a href="#7.24.6.3.2">7.24.6.3.2</a>).
<a name="7.24.2.2" href="#7.24.2.2"><b> 7.24.2.2 The fwscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int fwscanf(FILE * restrict stream,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The fwscanf function reads input from the stream pointed to by stream, under
control of the wide string pointed to by format that specifies the admissible input
sequences and how they are to be converted for assignment, using subsequent arguments
15 Trailing white space (including new-line wide characters) is left unread unless matched
by a directive. The success of literal matches and suppressed assignments is not directly
determinable other than via the %n directive.
- Returns
+<b> Returns</b>
16 The fwscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the function returns the number of input items
assigned, which can be fewer than provided for, or even zero, in the event of an early
wcstol, wcstoll, wcstoul, and wcstoull functions (<a href="#7.24.4.1.2">7.24.4.1.2</a>), the wcrtomb
function (<a href="#7.24.6.3.3">7.24.6.3.3</a>).
<a name="7.24.2.3" href="#7.24.2.3"><b> 7.24.2.3 The swprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int swprintf(wchar_t * restrict s,
size_t n,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The swprintf function is equivalent to fwprintf, except that the argument s
specifies an array of wide characters into which the generated output is to be written,
rather than written to a stream. No more than n wide characters are written, including a
terminating null wide character, which is always added (unless n is zero).
- Returns
+<b> Returns</b>
3 The swprintf function returns the number of wide characters written in the array, not
counting the terminating null wide character, or a negative value if an encoding error
occurred or if n or more wide characters were requested to be written.
<a name="7.24.2.4" href="#7.24.2.4"><b> 7.24.2.4 The swscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int swscanf(const wchar_t * restrict s,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The swscanf function is equivalent to fwscanf, except that the argument s specifies a
wide string from which the input is to be obtained, rather than from a stream. Reaching
the end of the wide string is equivalent to encountering end-of-file for the fwscanf
function.
- Returns
+<b> Returns</b>
3 The swscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the swscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
[<a name="p362" href="#p362">page 362</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.2.5" href="#7.24.2.5"><b> 7.24.2.5 The vfwprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int vfwprintf(FILE * restrict stream,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfwprintf function is equivalent to fwprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfwprintf function does not invoke the
va_end macro.291)
- Returns
+<b> Returns</b>
3 The vfwprintf function returns the number of wide characters transmitted, or a
negative value if an output or encoding error occurred.
4 EXAMPLE The following shows the use of the vfwprintf function in a general error-reporting
[<a name="p363" href="#p363">page 363</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.2.6" href="#7.24.2.6"><b> 7.24.2.6 The vfwscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int vfwscanf(FILE * restrict stream,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfwscanf function is equivalent to fwscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfwscanf function does not invoke the
va_end macro.291)
- Returns
+<b> Returns</b>
3 The vfwscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the vfwscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
early matching failure.
<a name="7.24.2.7" href="#7.24.2.7"><b> 7.24.2.7 The vswprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.24"><wchar.h></a>
int vswprintf(wchar_t * restrict s,
size_t n,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vswprintf function is equivalent to swprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vswprintf function does not invoke the
va_end macro.291)
- Returns
+<b> Returns</b>
3 The vswprintf function returns the number of wide characters written in the array, not
counting the terminating null wide character, or a negative value if an encoding error
occurred or if n or more wide characters were requested to be generated.
[<a name="p364" href="#p364">page 364</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.2.8" href="#7.24.2.8"><b> 7.24.2.8 The vswscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.24"><wchar.h></a>
int vswscanf(const wchar_t * restrict s,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vswscanf function is equivalent to swscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vswscanf function does not invoke the
va_end macro.291)
- Returns
+<b> Returns</b>
3 The vswscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the vswscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
early matching failure.
<a name="7.24.2.9" href="#7.24.2.9"><b> 7.24.2.9 The vwprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.24"><wchar.h></a>
int vwprintf(const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vwprintf function is equivalent to wprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vwprintf function does not invoke the
va_end macro.291)
- Returns
+<b> Returns</b>
3 The vwprintf function returns the number of wide characters transmitted, or a negative
value if an output or encoding error occurred.
[<a name="p365" href="#p365">page 365</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.2.10" href="#7.24.2.10"><b> 7.24.2.10 The vwscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.15"><stdarg.h></a>
#include <a href="#7.24"><wchar.h></a>
int vwscanf(const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vwscanf function is equivalent to wscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vwscanf function does not invoke the
va_end macro.291)
- Returns
+<b> Returns</b>
3 The vwscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the vwscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
early matching failure.
<a name="7.24.2.11" href="#7.24.2.11"><b> 7.24.2.11 The wprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int wprintf(const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The wprintf function is equivalent to fwprintf with the argument stdout
interposed before the arguments to wprintf.
- Returns
+<b> Returns</b>
3 The wprintf function returns the number of wide characters transmitted, or a negative
value if an output or encoding error occurred.
<a name="7.24.2.12" href="#7.24.2.12"><b> 7.24.2.12 The wscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int wscanf(const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The wscanf function is equivalent to fwscanf with the argument stdin interposed
before the arguments to wscanf.
[<a name="p366" href="#p366">page 366</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The wscanf function returns the value of the macro EOF if an input failure occurs
before any conversion. Otherwise, the wscanf function returns the number of input
items assigned, which can be fewer than provided for, or even zero, in the event of an
early matching failure.
<a name="7.24.3" href="#7.24.3"><b> 7.24.3 Wide character input/output functions</b></a>
<a name="7.24.3.1" href="#7.24.3.1"><b> 7.24.3.1 The fgetwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wint_t fgetwc(FILE *stream);
- Description
+<b> Description</b>
2 If the end-of-file indicator for the input stream pointed to by stream is not set and a
next wide character is present, the fgetwc function obtains that wide character as a
wchar_t converted to a wint_t and advances the associated file position indicator for
the stream (if defined).
- Returns
+<b> Returns</b>
3 If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
of-file indicator for the stream is set and the fgetwc function returns WEOF. Otherwise,
the fgetwc function returns the next wide character from the input stream pointed to by
function returns WEOF. If an encoding error occurs (including too few bytes), the value of
the macro EILSEQ is stored in errno and the fgetwc function returns WEOF.292)
<a name="7.24.3.2" href="#7.24.3.2"><b> 7.24.3.2 The fgetws function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wchar_t *fgetws(wchar_t * restrict s,
int n, FILE * restrict stream);
- Description
+<b> Description</b>
2 The fgetws function reads at most one less than the number of wide characters
specified by n from the stream pointed to by stream into the array pointed to by s. No
additional wide characters are read after a new-line wide character (which is retained) or
after end-of-file. A null wide character is written immediately after the last wide
character read into the array.
- Returns
+<b> Returns</b>
3 The fgetws function returns s if successful. If end-of-file is encountered and no
characters have been read into the array, the contents of the array remain unchanged and a
null pointer is returned. If a read or encoding error occurs during the operation, the array
contents are indeterminate and a null pointer is returned.
<a name="7.24.3.3" href="#7.24.3.3"><b> 7.24.3.3 The fputwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wint_t fputwc(wchar_t c, FILE *stream);
- Description
+<b> Description</b>
2 The fputwc function writes the wide character specified by c to the output stream
pointed to by stream, at the position indicated by the associated file position indicator
for the stream (if defined), and advances the indicator appropriately. If the file cannot
support positioning requests, or if the stream was opened with append mode, the
character is appended to the output stream.
- Returns
+<b> Returns</b>
3 The fputwc function returns the wide character written. If a write error occurs, the
error indicator for the stream is set and fputwc returns WEOF. If an encoding error
occurs, the value of the macro EILSEQ is stored in errno and fputwc returns WEOF.
<a name="7.24.3.4" href="#7.24.3.4"><b> 7.24.3.4 The fputws function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int fputws(const wchar_t * restrict s,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fputws function writes the wide string pointed to by s to the stream pointed to by
stream. The terminating null wide character is not written.
- Returns
+<b> Returns</b>
3 The fputws function returns EOF if a write or encoding error occurs; otherwise, it
returns a nonnegative value.
[<a name="p368" href="#p368">page 368</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.3.5" href="#7.24.3.5"><b> 7.24.3.5 The fwide function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int fwide(FILE *stream, int mode);
- Description
+<b> Description</b>
2 The fwide function determines the orientation of the stream pointed to by stream. If
mode is greater than zero, the function first attempts to make the stream wide oriented. If
mode is less than zero, the function first attempts to make the stream byte oriented.293)
Otherwise, mode is zero and the function does not alter the orientation of the stream.
- Returns
+<b> Returns</b>
3 The fwide function returns a value greater than zero if, after the call, the stream has
wide orientation, a value less than zero if the stream has byte orientation, or zero if the
stream has no orientation.
<a name="7.24.3.6" href="#7.24.3.6"><b> 7.24.3.6 The getwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wint_t getwc(FILE *stream);
- Description
+<b> Description</b>
2 The getwc function is equivalent to fgetwc, except that if it is implemented as a
macro, it may evaluate stream more than once, so the argument should never be an
expression with side effects.
- Returns
+<b> Returns</b>
3 The getwc function returns the next wide character from the input stream pointed to by
stream, or WEOF.
<a name="7.24.3.7" href="#7.24.3.7"><b> 7.24.3.7 The getwchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wint_t getwchar(void);
[<a name="p369" href="#p369">page 369</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The getwchar function is equivalent to getwc with the argument stdin.
- Returns
+<b> Returns</b>
3 The getwchar function returns the next wide character from the input stream pointed to
by stdin, or WEOF.
<a name="7.24.3.8" href="#7.24.3.8"><b> 7.24.3.8 The putwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wint_t putwc(wchar_t c, FILE *stream);
- Description
+<b> Description</b>
2 The putwc function is equivalent to fputwc, except that if it is implemented as a
macro, it may evaluate stream more than once, so that argument should never be an
expression with side effects.
- Returns
+<b> Returns</b>
3 The putwc function returns the wide character written, or WEOF.
<a name="7.24.3.9" href="#7.24.3.9"><b> 7.24.3.9 The putwchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wint_t putwchar(wchar_t c);
- Description
+<b> Description</b>
2 The putwchar function is equivalent to putwc with the second argument stdout.
- Returns
+<b> Returns</b>
3 The putwchar function returns the character written, or WEOF.
<a name="7.24.3.10" href="#7.24.3.10"><b> 7.24.3.10 The ungetwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wint_t ungetwc(wint_t c, FILE *stream);
- Description
+<b> Description</b>
2 The ungetwc function pushes the wide character specified by c back onto the input
stream pointed to by stream. Pushed-back wide characters will be returned by
subsequent reads on that stream in the reverse order of their pushing. A successful
back. For a text or binary stream, the value of its file position indicator after a successful
call to the ungetwc function is unspecified until all pushed-back wide characters are
read or discarded.
- Returns
+<b> Returns</b>
6 The ungetwc function returns the wide character pushed back, or WEOF if the operation
fails.
<a name="7.24.4" href="#7.24.4"><b> 7.24.4 General wide string utilities</b></a>
<a name="7.24.4.1" href="#7.24.4.1"><b> 7.24.4.1 Wide string numeric conversion functions</b></a>
<a name="7.24.4.1.1" href="#7.24.4.1.1"><b> 7.24.4.1.1 The wcstod, wcstof, and wcstold functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
double wcstod(const wchar_t * restrict nptr,
wchar_t ** restrict endptr);
wchar_t ** restrict endptr);
long double wcstold(const wchar_t * restrict nptr,
wchar_t ** restrict endptr);
- Description
+<b> Description</b>
2 The wcstod, wcstof, and wcstold functions convert the initial portion of the wide
string pointed to by nptr to double, float, and long double representation,
respectively. First, they decompose the input string into three parts: an initial, possibly
correctly rounding L and U according to the current rounding direction, with the extra
stipulation that the error with respect to D should have a correct sign for the current
rounding direction.296)
- Returns
+<b> Returns</b>
10 The functions return the converted value, if any. If no conversion could be performed,
zero is returned. If the correct value is outside the range of representable values, plus or
minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the return
[<a name="p374" href="#p374">page 374</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.4.1.2" href="#7.24.4.1.2"><b> 7.24.4.1.2 The wcstol, wcstoll, wcstoul, and wcstoull functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
long int wcstol(
const wchar_t * restrict nptr,
const wchar_t * restrict nptr,
wchar_t ** restrict endptr,
int base);
- Description
+<b> Description</b>
2 The wcstol, wcstoll, wcstoul, and wcstoull functions convert the initial
portion of the wide string pointed to by nptr to long int, long long int,
unsigned long int, and unsigned long long int representation,
7 If the subject sequence is empty or does not have the expected form, no conversion is
performed; the value of nptr is stored in the object pointed to by endptr, provided
that endptr is not a null pointer.
- Returns
+<b> Returns</b>
8 The wcstol, wcstoll, wcstoul, and wcstoull functions return the converted
value, if any. If no conversion could be performed, zero is returned. If the correct value
is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,
sign of the value, if any), and the value of the macro ERANGE is stored in errno.
<a name="7.24.4.2" href="#7.24.4.2"><b> 7.24.4.2 Wide string copying functions</b></a>
<a name="7.24.4.2.1" href="#7.24.4.2.1"><b> 7.24.4.2.1 The wcscpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcscpy(wchar_t * restrict s1,
const wchar_t * restrict s2);
- Description
+<b> Description</b>
2 The wcscpy function copies the wide string pointed to by s2 (including the terminating
null wide character) into the array pointed to by s1.
- Returns
+<b> Returns</b>
3 The wcscpy function returns the value of s1.
[<a name="p376" href="#p376">page 376</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.4.2.2" href="#7.24.4.2.2"><b> 7.24.4.2.2 The wcsncpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcsncpy(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsncpy function copies not more than n wide characters (those that follow a null
wide character are not copied) from the array pointed to by s2 to the array pointed to by
s1.297)
3 If the array pointed to by s2 is a wide string that is shorter than n wide characters, null
wide characters are appended to the copy in the array pointed to by s1, until n wide
characters in all have been written.
- Returns
+<b> Returns</b>
4 The wcsncpy function returns the value of s1.
<a name="7.24.4.2.3" href="#7.24.4.2.3"><b> 7.24.4.2.3 The wmemcpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wmemcpy(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wmemcpy function copies n wide characters from the object pointed to by s2 to the
object pointed to by s1.
- Returns
+<b> Returns</b>
3 The wmemcpy function returns the value of s1.
[<a name="p377" href="#p377">page 377</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.4.2.4" href="#7.24.4.2.4"><b> 7.24.4.2.4 The wmemmove function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2,
size_t n);
- Description
+<b> Description</b>
2 The wmemmove function copies n wide characters from the object pointed to by s2 to
the object pointed to by s1. Copying takes place as if the n wide characters from the
object pointed to by s2 are first copied into a temporary array of n wide characters that
does not overlap the objects pointed to by s1 or s2, and then the n wide characters from
the temporary array are copied into the object pointed to by s1.
- Returns
+<b> Returns</b>
3 The wmemmove function returns the value of s1.
<a name="7.24.4.3" href="#7.24.4.3"><b> 7.24.4.3 Wide string concatenation functions</b></a>
<a name="7.24.4.3.1" href="#7.24.4.3.1"><b> 7.24.4.3.1 The wcscat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcscat(wchar_t * restrict s1,
const wchar_t * restrict s2);
- Description
+<b> Description</b>
2 The wcscat function appends a copy of the wide string pointed to by s2 (including the
terminating null wide character) to the end of the wide string pointed to by s1. The initial
wide character of s2 overwrites the null wide character at the end of s1.
- Returns
+<b> Returns</b>
3 The wcscat function returns the value of s1.
<a name="7.24.4.3.2" href="#7.24.4.3.2"><b> 7.24.4.3.2 The wcsncat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcsncat(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsncat function appends not more than n wide characters (a null wide character
and those that follow it are not appended) from the array pointed to by s2 to the end of
the wide string pointed to by s1. The initial wide character of s2 overwrites the null
wide character at the end of s1. A terminating null wide character is always appended to
the result.298)
- Returns
+<b> Returns</b>
3 The wcsncat function returns the value of s1.
<a name="7.24.4.4" href="#7.24.4.4"><b> 7.24.4.4 Wide string comparison functions</b></a>
1 Unless explicitly stated otherwise, the functions described in this subclause order two
wide characters the same way as two integers of the underlying integer type designated
by wchar_t.
<a name="7.24.4.4.1" href="#7.24.4.4.1"><b> 7.24.4.4.1 The wcscmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int wcscmp(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcscmp function compares the wide string pointed to by s1 to the wide string
pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcscmp function returns an integer greater than, equal to, or less than zero,
accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the
wide string pointed to by s2.
<a name="7.24.4.4.2" href="#7.24.4.4.2"><b> 7.24.4.4.2 The wcscoll function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int wcscoll(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcscoll function compares the wide string pointed to by s1 to the wide string
pointed to by s2, both interpreted as appropriate to the LC_COLLATE category of the
current locale.
- Returns
+<b> Returns</b>
3 The wcscoll function returns an integer greater than, equal to, or less than zero,
accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the
wide string pointed to by s2 when both are interpreted as appropriate to the current
locale.
<a name="7.24.4.4.3" href="#7.24.4.4.3"><b> 7.24.4.4.3 The wcsncmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int wcsncmp(const wchar_t *s1, const wchar_t *s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsncmp function compares not more than n wide characters (those that follow a
null wide character are not compared) from the array pointed to by s1 to the array
pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcsncmp function returns an integer greater than, equal to, or less than zero,
accordingly as the possibly null-terminated array pointed to by s1 is greater than, equal
to, or less than the possibly null-terminated array pointed to by s2.
<a name="7.24.4.4.4" href="#7.24.4.4.4"><b> 7.24.4.4.4 The wcsxfrm function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t wcsxfrm(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsxfrm function transforms the wide string pointed to by s2 and places the
resulting wide string into the array pointed to by s1. The transformation is such that if
the wcscmp function is applied to two transformed wide strings, it returns a value greater
applied to the same two original wide strings. No more than n wide characters are placed
into the resulting array pointed to by s1, including the terminating null wide character. If
n is zero, s1 is permitted to be a null pointer.
- Returns
+<b> Returns</b>
3 The wcsxfrm function returns the length of the transformed wide string (not including
the terminating null wide character). If the value returned is n or greater, the contents of
the array pointed to by s1 are indeterminate.
1 + wcsxfrm(NULL, s, 0)
<a name="7.24.4.4.5" href="#7.24.4.4.5"><b> 7.24.4.4.5 The wmemcmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int wmemcmp(const wchar_t *s1, const wchar_t *s2,
size_t n);
- Description
+<b> Description</b>
2 The wmemcmp function compares the first n wide characters of the object pointed to by
s1 to the first n wide characters of the object pointed to by s2.
- Returns
+<b> Returns</b>
3 The wmemcmp function returns an integer greater than, equal to, or less than zero,
accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
pointed to by s2.
<a name="7.24.4.5" href="#7.24.4.5"><b> 7.24.4.5 Wide string search functions</b></a>
<a name="7.24.4.5.1" href="#7.24.4.5.1"><b> 7.24.4.5.1 The wcschr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcschr(const wchar_t *s, wchar_t c);
- Description
+<b> Description</b>
2 The wcschr function locates the first occurrence of c in the wide string pointed to by s.
The terminating null wide character is considered to be part of the wide string.
- Returns
+<b> Returns</b>
3 The wcschr function returns a pointer to the located wide character, or a null pointer if
the wide character does not occur in the wide string.
<a name="7.24.4.5.2" href="#7.24.4.5.2"><b> 7.24.4.5.2 The wcscspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t wcscspn(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcscspn function computes the length of the maximum initial segment of the wide
string pointed to by s1 which consists entirely of wide characters not from the wide
string pointed to by s2.
[<a name="p381" href="#p381">page 381</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The wcscspn function returns the length of the segment.
<a name="7.24.4.5.3" href="#7.24.4.5.3"><b> 7.24.4.5.3 The wcspbrk function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcspbrk function locates the first occurrence in the wide string pointed to by s1 of
any wide character from the wide string pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcspbrk function returns a pointer to the wide character in s1, or a null pointer if
no wide character from s2 occurs in s1.
<a name="7.24.4.5.4" href="#7.24.4.5.4"><b> 7.24.4.5.4 The wcsrchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
- Description
+<b> Description</b>
2 The wcsrchr function locates the last occurrence of c in the wide string pointed to by
s. The terminating null wide character is considered to be part of the wide string.
- Returns
+<b> Returns</b>
3 The wcsrchr function returns a pointer to the wide character, or a null pointer if c does
not occur in the wide string.
<a name="7.24.4.5.5" href="#7.24.4.5.5"><b> 7.24.4.5.5 The wcsspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t wcsspn(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcsspn function computes the length of the maximum initial segment of the wide
string pointed to by s1 which consists entirely of wide characters from the wide string
pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcsspn function returns the length of the segment.
[<a name="p382" href="#p382">page 382</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.4.5.6" href="#7.24.4.5.6"><b> 7.24.4.5.6 The wcsstr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcsstr function locates the first occurrence in the wide string pointed to by s1 of
the sequence of wide characters (excluding the terminating null wide character) in the
wide string pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcsstr function returns a pointer to the located wide string, or a null pointer if the
wide string is not found. If s2 points to a wide string with zero length, the function
returns s1.
<a name="7.24.4.5.7" href="#7.24.4.5.7"><b> 7.24.4.5.7 The wcstok function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wcstok(wchar_t * restrict s1,
const wchar_t * restrict s2,
wchar_t ** restrict ptr);
- Description
+<b> Description</b>
2 A sequence of calls to the wcstok function breaks the wide string pointed to by s1 into
a sequence of tokens, each of which is delimited by a wide character from the wide string
pointed to by s2. The third argument points to a caller-provided wchar_t pointer into
by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
value for ptr, shall start searching just past the element overwritten by a null wide
character (if any).
- Returns
+<b> Returns</b>
7 The wcstok function returns a pointer to the first wide character of a token, or a null
pointer if there is no token.
8 EXAMPLE
t = wcstok(NULL, L"?", &ptr1); // t is a null pointer
<a name="7.24.4.5.8" href="#7.24.4.5.8"><b> 7.24.4.5.8 The wmemchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wmemchr(const wchar_t *s, wchar_t c,
size_t n);
- Description
+<b> Description</b>
2 The wmemchr function locates the first occurrence of c in the initial n wide characters of
the object pointed to by s.
- Returns
+<b> Returns</b>
3 The wmemchr function returns a pointer to the located wide character, or a null pointer if
the wide character does not occur in the object.
<a name="7.24.4.6" href="#7.24.4.6"><b> 7.24.4.6 Miscellaneous functions</b></a>
<a name="7.24.4.6.1" href="#7.24.4.6.1"><b> 7.24.4.6.1 The wcslen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t wcslen(const wchar_t *s);
- Description
+<b> Description</b>
2 The wcslen function computes the length of the wide string pointed to by s.
- Returns
+<b> Returns</b>
3 The wcslen function returns the number of wide characters that precede the terminating
null wide character.
<a name="7.24.4.6.2" href="#7.24.4.6.2"><b> 7.24.4.6.2 The wmemset function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
- Description
+<b> Description</b>
2 The wmemset function copies the value of c into each of the first n wide characters of
the object pointed to by s.
- Returns
+<b> Returns</b>
3 The wmemset function returns the value of s.
<a name="7.24.5" href="#7.24.5"><b> 7.24.5 Wide character time conversion functions</b></a>
<a name="7.24.5.1" href="#7.24.5.1"><b> 7.24.5.1 The wcsftime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><time.h></a>
#include <a href="#7.24"><wchar.h></a>
size_t wcsftime(wchar_t * restrict s,
size_t maxsize,
const wchar_t * restrict format,
const struct tm * restrict timeptr);
- Description
+<b> Description</b>
2 The wcsftime function is equivalent to the strftime function, except that:
-- The argument s points to the initial element of an array of wide characters into which
the generated output is to be placed.
-- The argument format is a wide string and the conversion specifiers are replaced by
corresponding sequences of wide characters.
-- The return value indicates the number of wide characters.
- Returns
+<b> Returns</b>
3 If the total number of resulting wide characters including the terminating null wide
character is not more than maxsize, the wcsftime function returns the number of
wide characters placed into the array pointed to by s not including the terminating null
<a name="7.24.6.1" href="#7.24.6.1"><b> 7.24.6.1 Single-byte/wide character conversion functions</b></a>
<a name="7.24.6.1.1" href="#7.24.6.1.1"><b> 7.24.6.1.1 The btowc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
wint_t btowc(int c);
- Description
+<b> Description</b>
2 The btowc function determines whether c constitutes a valid single-byte character in the
initial shift state.
- Returns
+<b> Returns</b>
3 The btowc function returns WEOF if c has the value EOF or if (unsigned char)c
does not constitute a valid single-byte character in the initial shift state. Otherwise, it
returns the wide character representation of that character.
<a name="7.24.6.1.2" href="#7.24.6.1.2"><b> 7.24.6.1.2 The wctob function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stdio.h></a>
#include <a href="#7.24"><wchar.h></a>
int wctob(wint_t c);
- Description
+<b> Description</b>
2 The wctob function determines whether c corresponds to a member of the extended
character set whose multibyte character representation is a single byte when in the initial
shift state.
- Returns
+<b> Returns</b>
3 The wctob function returns EOF if c does not correspond to a multibyte character with
length one in the initial shift state. Otherwise, it returns the single-byte representation of
that character as an unsigned char converted to an int.
<a name="7.24.6.2" href="#7.24.6.2"><b> 7.24.6.2 Conversion state functions</b></a>
<a name="7.24.6.2.1" href="#7.24.6.2.1"><b> 7.24.6.2.1 The mbsinit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
int mbsinit(const mbstate_t *ps);
- Description
+<b> Description</b>
2 If ps is not a null pointer, the mbsinit function determines whether the pointed-to
mbstate_t object describes an initial conversion state.
[<a name="p387" href="#p387">page 387</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The mbsinit function returns nonzero if ps is a null pointer or if the pointed-to object
describes an initial conversion state; otherwise, it returns zero.
<a name="7.24.6.3" href="#7.24.6.3"><b> 7.24.6.3 Restartable multibyte/wide character conversion functions</b></a>
2 Also unlike their corresponding functions, the return value does not represent whether the
encoding is state-dependent.
<a name="7.24.6.3.1" href="#7.24.6.3.1"><b> 7.24.6.3.1 The mbrlen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t mbrlen(const char * restrict s,
size_t n,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 The mbrlen function is equivalent to the call:
mbrtowc(NULL, s, n, ps != NULL ? ps : &internal)
where internal is the mbstate_t object for the mbrlen function, except that the
expression designated by ps is evaluated only once.
- Returns
+<b> Returns</b>
3 The mbrlen function returns a value between zero and n, inclusive, (size_t)(-2),
or (size_t)(-1).
Forward references: the mbrtowc function (<a href="#7.24.6.3.2">7.24.6.3.2</a>).
[<a name="p388" href="#p388">page 388</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.6.3.2" href="#7.24.6.3.2"><b> 7.24.6.3.2 The mbrtowc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t mbrtowc(wchar_t * restrict pwc,
const char * restrict s,
size_t n,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the mbrtowc function is equivalent to the call:
mbrtowc(NULL, "", 1, ps)
In this case, the values of the parameters pwc and n are ignored.
corresponding wide character and then, if pwc is not a null pointer, stores that value in
the object pointed to by pwc. If the corresponding wide character is the null wide
character, the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The mbrtowc function returns the first of the following that applies (given the current
conversion state):
0 if the next n or fewer bytes complete the multibyte character that
[<a name="p389" href="#p389">page 389</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.6.3.3" href="#7.24.6.3.3"><b> 7.24.6.3.3 The wcrtomb function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t wcrtomb(char * restrict s,
wchar_t wc,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the wcrtomb function is equivalent to the call
wcrtomb(buf, L'\0', ps)
where buf is an internal buffer.
array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
wc is a null wide character, a null byte is stored, preceded by any shift sequence needed
to restore the initial shift state; the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The wcrtomb function returns the number of bytes stored in the array object (including
any shift sequences). When wc is not a valid wide character, an encoding error occurs:
the function stores the value of the macro EILSEQ in errno and returns
[<a name="p390" href="#p390">page 390</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.6.4.1" href="#7.24.6.4.1"><b> 7.24.6.4.1 The mbsrtowcs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t mbsrtowcs(wchar_t * restrict dst,
const char ** restrict src,
size_t len,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 The mbsrtowcs function converts a sequence of multibyte characters that begins in the
conversion state described by the object pointed to by ps, from the array indirectly
pointed to by src into a sequence of corresponding wide characters. If dst is not a null
just past the last multibyte character converted (if any). If conversion stopped due to
reaching a terminating null character and if dst is not a null pointer, the resulting state
described is the initial conversion state.
- Returns
+<b> Returns</b>
4 If the input conversion encounters a sequence of bytes that do not form a valid multibyte
character, an encoding error occurs: the mbsrtowcs function stores the value of the
macro EILSEQ in errno and returns (size_t)(-1); the conversion state is
[<a name="p391" href="#p391">page 391</a>] (<a href="#Contents">Contents</a>)
<a name="7.24.6.4.2" href="#7.24.6.4.2"><b> 7.24.6.4.2 The wcsrtombs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.24"><wchar.h></a>
size_t wcsrtombs(char * restrict dst,
const wchar_t ** restrict src,
size_t len,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 The wcsrtombs function converts a sequence of wide characters from the array
indirectly pointed to by src into a sequence of corresponding multibyte characters that
begins in the conversion state described by the object pointed to by ps. If dst is not a
address just past the last wide character converted (if any). If conversion stopped due to
reaching a terminating null wide character, the resulting state described is the initial
conversion state.
- Returns
+<b> Returns</b>
4 If conversion stops because a wide character is reached that does not correspond to a
valid multibyte character, an encoding error occurs: the wcsrtombs function stores the
value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion
both printing and white-space wide characters.304)
Forward references: the wctob function (<a href="#7.24.6.1.2">7.24.6.1.2</a>).
<a name="7.25.2.1.1" href="#7.25.2.1.1"><b> 7.25.2.1.1 The iswalnum function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswalnum(wint_t wc);
- Description
+<b> Description</b>
2 The iswalnum function tests for any wide character for which iswalpha or
iswdigit is true.
<a name="7.25.2.1.2" href="#7.25.2.1.2"><b> 7.25.2.1.2 The iswalpha function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswalpha(wint_t wc);
- Description
+<b> Description</b>
2 The iswalpha function tests for any wide character for which iswupper or
iswlower is true, or any wide character that is one of a locale-specific set of alphabetic
wide characters for which none of iswcntrl, iswdigit, iswpunct, or iswspace
is true.305)
<a name="7.25.2.1.3" href="#7.25.2.1.3"><b> 7.25.2.1.3 The iswblank function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswblank(wint_t wc);
- Description
+<b> Description</b>
2 The iswblank function tests for any wide character that is a standard blank wide
character or is one of a locale-specific set of wide characters for which iswspace is true
and that is used to separate words within a line of text. The standard blank wide
characters are the following: space (L' '), and horizontal tab (L'\t'). In the "C"
locale, iswblank returns true only for the standard blank characters.
<a name="7.25.2.1.4" href="#7.25.2.1.4"><b> 7.25.2.1.4 The iswcntrl function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswcntrl(wint_t wc);
- Description
+<b> Description</b>
2 The iswcntrl function tests for any control wide character.
<a name="7.25.2.1.5" href="#7.25.2.1.5"><b> 7.25.2.1.5 The iswdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswdigit(wint_t wc);
- Description
+<b> Description</b>
2 The iswdigit function tests for any wide character that corresponds to a decimal-digit
character (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.25.2.1.6" href="#7.25.2.1.6"><b> 7.25.2.1.6 The iswgraph function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswgraph(wint_t wc);
[<a name="p395" href="#p395">page 395</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The iswgraph function tests for any wide character for which iswprint is true and
iswspace is false.306)
<a name="7.25.2.1.7" href="#7.25.2.1.7"><b> 7.25.2.1.7 The iswlower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswlower(wint_t wc);
- Description
+<b> Description</b>
2 The iswlower function tests for any wide character that corresponds to a lowercase
letter or is one of a locale-specific set of wide characters for which none of iswcntrl,
iswdigit, iswpunct, or iswspace is true.
<a name="7.25.2.1.8" href="#7.25.2.1.8"><b> 7.25.2.1.8 The iswprint function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswprint(wint_t wc);
- Description
+<b> Description</b>
2 The iswprint function tests for any printing wide character.
<a name="7.25.2.1.9" href="#7.25.2.1.9"><b> 7.25.2.1.9 The iswpunct function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswpunct(wint_t wc);
- Description
+<b> Description</b>
2 The iswpunct function tests for any printing wide character that is one of a locale-
specific set of punctuation wide characters for which neither iswspace nor iswalnum
is true.306)
<a name="7.25.2.1.10" href="#7.25.2.1.10"><b> 7.25.2.1.10 The iswspace function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswspace(wint_t wc);
[<a name="p396" href="#p396">page 396</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The iswspace function tests for any wide character that corresponds to a locale-specific
set of white-space wide characters for which none of iswalnum, iswgraph, or
iswpunct is true.
<a name="7.25.2.1.11" href="#7.25.2.1.11"><b> 7.25.2.1.11 The iswupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswupper(wint_t wc);
- Description
+<b> Description</b>
2 The iswupper function tests for any wide character that corresponds to an uppercase
letter or is one of a locale-specific set of wide characters for which none of iswcntrl,
iswdigit, iswpunct, or iswspace is true.
<a name="7.25.2.1.12" href="#7.25.2.1.12"><b> 7.25.2.1.12 The iswxdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswxdigit(wint_t wc);
- Description
+<b> Description</b>
2 The iswxdigit function tests for any wide character that corresponds to a
hexadecimal-digit character (as defined in <a href="#6.4.4.1">6.4.4.1</a>).
<a name="7.25.2.2" href="#7.25.2.2"><b> 7.25.2.2 Extensible wide character classification functions</b></a>
as well as testing equivalent to that performed by the functions described in the previous
subclause (<a href="#7.25.2.1">7.25.2.1</a>).
<a name="7.25.2.2.1" href="#7.25.2.2.1"><b> 7.25.2.2.1 The iswctype function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
int iswctype(wint_t wc, wctype_t desc);
- Description
+<b> Description</b>
2 The iswctype function determines whether the wide character wc has the property
described by desc. The current setting of the LC_CTYPE category shall be the same as
during the call to wctype that returned the value desc.
iswctype(wc, wctype("space")) // iswspace(wc)
iswctype(wc, wctype("upper")) // iswupper(wc)
iswctype(wc, wctype("xdigit")) // iswxdigit(wc)
- Returns
+<b> Returns</b>
4 The iswctype function returns nonzero (true) if and only if the value of the wide
character wc has the property described by desc.
Forward references: the wctype function (<a href="#7.25.2.2.2">7.25.2.2.2</a>).
<a name="7.25.2.2.2" href="#7.25.2.2.2"><b> 7.25.2.2.2 The wctype function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
wctype_t wctype(const char *property);
- Description
+<b> Description</b>
2 The wctype function constructs a value with type wctype_t that describes a class of
wide characters identified by the string argument property.
3 The strings listed in the description of the iswctype function shall be valid in all
locales as property arguments to the wctype function.
- Returns
+<b> Returns</b>
4 If property identifies a valid class of wide characters according to the LC_CTYPE
category of the current locale, the wctype function returns a nonzero value that is valid
as the second argument to the iswctype function; otherwise, it returns zero. *
1 The header <a href="#7.25"><wctype.h></a> declares several functions useful for mapping wide characters.
<a name="7.25.3.1" href="#7.25.3.1"><b> 7.25.3.1 Wide character case mapping functions</b></a>
<a name="7.25.3.1.1" href="#7.25.3.1.1"><b> 7.25.3.1.1 The towlower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
wint_t towlower(wint_t wc);
- Description
+<b> Description</b>
2 The towlower function converts an uppercase letter to a corresponding lowercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a wide character for which iswupper is true and there are one or
more corresponding wide characters, as specified by the current locale, for which
iswlower is true, the towlower function returns one of the corresponding wide
characters (always the same one for any given locale); otherwise, the argument is
returned unchanged.
<a name="7.25.3.1.2" href="#7.25.3.1.2"><b> 7.25.3.1.2 The towupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
wint_t towupper(wint_t wc);
- Description
+<b> Description</b>
2 The towupper function converts a lowercase letter to a corresponding uppercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a wide character for which iswlower is true and there are one or
more corresponding wide characters, as specified by the current locale, for which
iswupper is true, the towupper function returns one of the corresponding wide
[<a name="p399" href="#p399">page 399</a>] (<a href="#Contents">Contents</a>)
<a name="7.25.3.2.1" href="#7.25.3.2.1"><b> 7.25.3.2.1 The towctrans function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
wint_t towctrans(wint_t wc, wctrans_t desc);
- Description
+<b> Description</b>
2 The towctrans function maps the wide character wc using the mapping described by
desc. The current setting of the LC_CTYPE category shall be the same as during the call
to wctrans that returned the value desc.
mapping function (<a href="#7.25.3.1">7.25.3.1</a>) in the comment that follows the expression:
towctrans(wc, wctrans("tolower")) // towlower(wc)
towctrans(wc, wctrans("toupper")) // towupper(wc)
- Returns
+<b> Returns</b>
4 The towctrans function returns the mapped value of wc using the mapping described
by desc.
<a name="7.25.3.2.2" href="#7.25.3.2.2"><b> 7.25.3.2.2 The wctrans function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><wctype.h></a>
wctrans_t wctrans(const char *property);
- Description
+<b> Description</b>
2 The wctrans function constructs a value with type wctrans_t that describes a
mapping between wide characters identified by the string argument property.
3 The strings listed in the description of the towctrans function shall be valid in all
locales as property arguments to the wctrans function.
- Returns
+<b> Returns</b>
4 If property identifies a valid mapping of wide characters according to the LC_CTYPE
category of the current locale, the wctrans function returns a nonzero value that is valid
as the second argument to the towctrans function; otherwise, it returns zero.
[<a name="p468" href="#p468">page 468</a>] (<a href="#Contents">Contents</a>)
<a name="G.5.1" href="#G.5.1"><b> G.5.1 Multiplicative operators</b></a>
- Semantics
+<b> Semantics</b>
1 If one operand has real type and the other operand has imaginary type, then the result has
imaginary type. If both operands have imaginary type, then the result has real type. (If
either operand has complex type, then the result has complex type.)
with division, provides better roundoff characteristics.
<a name="G.5.2" href="#G.5.2"><b> G.5.2 Additive operators</b></a>
- Semantics
+<b> Semantics</b>
1 If both operands have imaginary type, then the result has imaginary type. (If one operand
has real type and the other operand has imaginary type, or if either operand has complex
type, then the result has complex type.)
[<a name="p56" href="#p56">page 56</a>] (<a href="#Contents">Contents</a>)
<a name="6.4" href="#6.4"><b> 6.4 Lexical elements</b></a>
- Syntax
+<b> Syntax</b>
1 token:
keyword
identifier
string-literal
punctuator
each non-white-space character that cannot be one of the above
- Constraints
+<b> Constraints</b>
2 Each preprocessing token that is converted to a token shall have the lexical form of a
keyword, an identifier, a constant, a string literal, or a punctuator.
- Semantics
+<b> Semantics</b>
3 A token is the minimal lexical element of the language in translation phases 7 and 8. The
categories of tokens are: keywords, identifiers, constants, string literals, and punctuators.
A preprocessing token is the minimal lexical element of the language in translation
(<a href="#6.5.3.1">6.5.3.1</a>), preprocessing directives (<a href="#6.10">6.10</a>), preprocessing numbers (<a href="#6.4.8">6.4.8</a>), string literals
(<a href="#6.4.5">6.4.5</a>).
<a name="6.4.1" href="#6.4.1"><b> 6.4.1 Keywords</b></a>
- Syntax
+<b> Syntax</b>
1 keyword: one of
alignof goto union
auto if unsigned
extern struct _Static_assert
float switch _Thread_local
for typedef
- Semantics
+<b> Semantics</b>
2 The above tokens (case sensitive) are reserved (in translation phases 7 and 8) for use as
keywords, and shall not be used otherwise. The keyword _Imaginary is reserved for
[<a name="p58" href="#p58">page 58</a>] (<a href="#Contents">Contents</a>)
specifying imaginary types.70)
<a name="6.4.2" href="#6.4.2"><b> 6.4.2 Identifiers</b></a>
<a name="6.4.2.1" href="#6.4.2.1"><b> 6.4.2.1 General</b></a>
- Syntax
+<b> Syntax</b>
1 identifier:
identifier-nondigit
identifier identifier-nondigit
N O P Q R S T U V W X Y Z
digit: one of
0 1 2 3 4 5 6 7 8 9
- Semantics
+<b> Semantics</b>
2 An identifier is a sequence of nondigit characters (including the underscore _, the
lowercase and uppercase Latin letters, and other characters) and digits, which designates
one or more entities as described in <a href="#6.2.1">6.2.1</a>. Lowercase and uppercase letters are distinct.
identifiers differ only in nonsignificant characters, the behavior is undefined.
Forward references: universal character names (<a href="#6.4.3">6.4.3</a>), macro replacement (<a href="#6.10.3">6.10.3</a>).
<a name="6.4.2.2" href="#6.4.2.2"><b> 6.4.2.2 Predefined identifiers</b></a>
- Semantics
+<b> Semantics</b>
1 The identifier __func__ shall be implicitly declared by the translator as if,
immediately following the opening brace of each function definition, the declaration
static const char __func__[] = "function-name";
[<a name="p60" href="#p60">page 60</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.3" href="#6.4.3"><b> 6.4.3 Universal character names</b></a>
- Syntax
+<b> Syntax</b>
1 universal-character-name:
\u hex-quad
\U hex-quad hex-quad
hex-quad:
hexadecimal-digit hexadecimal-digit
hexadecimal-digit hexadecimal-digit
- Constraints
+<b> Constraints</b>
2 A universal character name shall not specify a character whose short identifier is less than
00A0 other than 0024 ($), 0040 (@), or 0060 ('), nor one in the range D800 through
DFFF inclusive.73)
- Description
+<b> Description</b>
3 Universal character names may be used in identifiers, character constants, and string
literals to designate characters that are not in the basic character set.
- Semantics
+<b> Semantics</b>
4 The universal character name \Unnnnnnnn designates the character whose eight-digit
short identifier (as specified by ISO/IEC 10646) is nnnnnnnn.74) Similarly, the universal
character name \unnnn designates the character whose four-digit short identifier is nnnn
[<a name="p61" href="#p61">page 61</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.4" href="#6.4.4"><b> 6.4.4 Constants</b></a>
- Syntax
+<b> Syntax</b>
1 constant:
integer-constant
floating-constant
enumeration-constant
character-constant
- Constraints
+<b> Constraints</b>
2 Each constant shall have a type and the value of a constant shall be in the range of
representable values for its type.
- Semantics
+<b> Semantics</b>
3 Each constant has a type, determined by its form and value, as detailed later.
<a name="6.4.4.1" href="#6.4.4.1"><b> 6.4.4.1 Integer constants</b></a>
- Syntax
+<b> Syntax</b>
1 integer-constant:
decimal-constant integer-suffixopt
octal-constant integer-suffixopt
l L
long-long-suffix: one of
ll LL
- Description
+<b> Description</b>
2 An integer constant begins with a digit, but has no period or exponent part. It may have a
prefix that specifies its base and a suffix that specifies its type.
3 A decimal constant begins with a nonzero digit and consists of a sequence of decimal
digits 0 through 7 only. A hexadecimal constant consists of the prefix 0x or 0X followed
by a sequence of the decimal digits and the letters a (or A) through f (or F) with values
10 through 15 respectively.
- Semantics
+<b> Semantics</b>
4 The value of a decimal constant is computed base 10; that of an octal constant, base 8;
that of a hexadecimal constant, base 16. The lexically first digit is the most significant.
5 The type of an integer constant is the first of the corresponding list in which its value can
[<a name="p64" href="#p64">page 64</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.4.2" href="#6.4.4.2"><b> 6.4.4.2 Floating constants</b></a>
- Syntax
+<b> Syntax</b>
1 floating-constant:
decimal-floating-constant
hexadecimal-floating-constant
[<a name="p65" href="#p65">page 65</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 A floating constant has a significand part that may be followed by an exponent part and a
suffix that specifies its type. The components of the significand part may include a digit
sequence representing the whole-number part, followed by a period (.), followed by a
e, E, p, or P followed by an exponent consisting of an optionally signed digit sequence.
Either the whole-number part or the fraction part has to be present; for decimal floating
constants, either the period or the exponent part has to be present.
- Semantics
+<b> Semantics</b>
3 The significand part is interpreted as a (decimal or hexadecimal) rational number; the
digit sequence in the exponent part is interpreted as a decimal integer. For decimal
floating constants, the exponent indicates the power of 10 by which the significand part is
[<a name="p66" href="#p66">page 66</a>] (<a href="#Contents">Contents</a>)
<a name="6.4.4.3" href="#6.4.4.3"><b> 6.4.4.3 Enumeration constants</b></a>
- Syntax
+<b> Syntax</b>
1 enumeration-constant:
identifier
- Semantics
+<b> Semantics</b>
2 An identifier declared as an enumeration constant has type int.
Forward references: enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>).
<a name="6.4.4.4" href="#6.4.4.4"><b> 6.4.4.4 Character constants</b></a>
- Syntax
+<b> Syntax</b>
1 character-constant:
' c-char-sequence '
L' c-char-sequence '
hexadecimal-escape-sequence:
\x hexadecimal-digit
hexadecimal-escape-sequence hexadecimal-digit
- Description
+<b> Description</b>
2 An integer character constant is a sequence of one or more multibyte characters enclosed
in single-quotes, as in 'x'. A wide character constant is the same, except prefixed by the
letter L, u, or U. With a few exceptions detailed later, the elements of the sequence are
[<a name="p68" href="#p68">page 68</a>] (<a href="#Contents">Contents</a>)
- Constraints
+<b> Constraints</b>
9 The value of an octal or hexadecimal escape sequence shall be in the range of
representable values for the corresponding type:
Prefix Corresponding Type
L the unsigned type corresponding to wchar_t
u char16_t
U char32_t
- Semantics
+<b> Semantics</b>
10 An integer character constant has type int. The value of an integer character constant
containing a single character that maps to a single-byte execution character is the
numerical value of the representation of the mapped character interpreted as an integer.
Forward references: common definitions <a href="#7.19"><stddef.h></a> (<a href="#7.19">7.19</a>), the mbtowc function
(<a href="#7.22.7.2">7.22.7.2</a>), Unicode utilities <a href="#7.27"><uchar.h></a> (<a href="#7.27">7.27</a>).
<a name="6.4.5" href="#6.4.5"><b> 6.4.5 String literals</b></a>
- Syntax
+<b> Syntax</b>
1 string-literal:
encoding-prefixopt " s-char-sequenceopt "
encoding-prefix:
any member of the source character set except
the double-quote ", backslash \, or new-line character
escape-sequence
- Constraints
+<b> Constraints</b>
2 A sequence of adjacent string literal tokens shall not include both a wide string literal and
a UTF-8 string literal.
- Description
+<b> Description</b>
3 A character string literal is a sequence of zero or more multibyte characters enclosed in
double-quotes, as in "xyz". A UTF-8 string literal is the same, except prefixed by u8.
A wide string literal is the same, except prefixed by the letter L, u, or U.
[<a name="p70" href="#p70">page 70</a>] (<a href="#Contents">Contents</a>)
be represented by the escape sequence \".
- Semantics
+<b> Semantics</b>
5 In translation phase 6, the multibyte character sequences specified by any sequence of
adjacent character and identically-prefixed string literal tokens are concatenated into a
single multibyte character sequence. If any of the tokens has an encoding prefix, the
Forward references: common definitions <a href="#7.19"><stddef.h></a> (<a href="#7.19">7.19</a>), the mbstowcs
function (<a href="#7.22.8.1">7.22.8.1</a>), Unicode utilities <a href="#7.27"><uchar.h></a> (<a href="#7.27">7.27</a>).
<a name="6.4.6" href="#6.4.6"><b> 6.4.6 Punctuators</b></a>
- Syntax
+<b> Syntax</b>
1 punctuator: one of
[ ] ( ) { } . ->
++ -- & * + - ~ !
= *= /= %= += -= <<= >>= &= ^= |=
, # ##
<: :> <% %> %: %:%:
- Semantics
+<b> Semantics</b>
2 A punctuator is a symbol that has independent syntactic and semantic significance.
Depending on context, it may specify an operation to be performed (which in turn may
yield a value or a function designator, produce a side effect, or some combination thereof)
Forward references: expressions (<a href="#6.5">6.5</a>), declarations (<a href="#6.7">6.7</a>), preprocessing directives
(<a href="#6.10">6.10</a>), statements (<a href="#6.8">6.8</a>).
<a name="6.4.7" href="#6.4.7"><b> 6.4.7 Header names</b></a>
- Syntax
+<b> Syntax</b>
1 header-name:
< h-char-sequence >
" q-char-sequence "
q-char:
any member of the source character set except
the new-line character and "
- Semantics
+<b> Semantics</b>
2 The sequences in both forms of header names are mapped in an implementation-defined
manner to headers or external source file names as specified in <a href="#6.10.2">6.10.2</a>.
3 If the characters ', \, ", //, or /* occur in the sequence between the < and > delimiters,
Forward references: source file inclusion (<a href="#6.10.2">6.10.2</a>).
<a name="6.4.8" href="#6.4.8"><b> 6.4.8 Preprocessing numbers</b></a>
- Syntax
+<b> Syntax</b>
1 pp-number:
digit
. digit
pp-number p sign
pp-number P sign
pp-number .
- Description
+<b> Description</b>
2 A preprocessing number begins with a digit optionally preceded by a period (.) and may
be followed by valid identifier characters and the character sequences e+, e-, E+, E-,
p+, p-, P+, or P-.
3 Preprocessing number tokens lexically include all floating and integer constant tokens.
- Semantics
+<b> Semantics</b>
4 A preprocessing number does not have type or a value; it acquires both after a successful
conversion (as part of translation phase 7) to a floating constant token or an integer
constant token.
[<a name="p77" href="#p77">page 77</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.1" href="#6.5.1"><b> 6.5.1 Primary expressions</b></a>
- Syntax
+<b> Syntax</b>
1 primary-expression:
identifier
constant
string-literal
( expression )
generic-selection
- Semantics
+<b> Semantics</b>
2 An identifier is a primary expression, provided it has been declared as designating an
object (in which case it is an lvalue) or a function (in which case it is a function
designator).91)
designator, or a void expression.
Forward references: declarations (<a href="#6.7">6.7</a>).
<a name="6.5.1.1" href="#6.5.1.1"><b> 6.5.1.1 Generic selection</b></a>
- Syntax
+<b> Syntax</b>
1 generic-selection:
_Generic ( assignment-expression , generic-assoc-list )
generic-assoc-list:
generic-association:
type-name : assignment-expression
default : assignment-expression
- Constraints
+<b> Constraints</b>
2 A generic selection shall have no more than one default generic association. The type
name in a generic association shall specify a complete object type other than a variably
compatible with at most one of the types named in its generic association list. If a
generic selection has no default generic association, its controlling expression shall
have type compatible with exactly one of the types named in its generic association list.
- Semantics
+<b> Semantics</b>
3 The controlling expression of a generic selection is not evaluated. If a generic selection
has a generic association with a type name that is compatible with the type of the
controlling expression, then the result expression of the generic selection is the
)(X)
<a name="6.5.2" href="#6.5.2"><b> 6.5.2 Postfix operators</b></a>
- Syntax
+<b> Syntax</b>
1 postfix-expression:
primary-expression
postfix-expression [ expression ]
[<a name="p79" href="#p79">page 79</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.2.1" href="#6.5.2.1"><b> 6.5.2.1 Array subscripting</b></a>
- Constraints
+<b> Constraints</b>
1 One of the expressions shall have type ''pointer to complete object type'', the other
expression shall have integer type, and the result has type ''type''.
- Semantics
+<b> Semantics</b>
2 A postfix expression followed by an expression in square brackets [] is a subscripted
designation of an element of an array object. The definition of the subscript operator []
is that E1[E2] is identical to (*((E1)+(E2))). Because of the conversion rules that
Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), address and indirection operators
(<a href="#6.5.3.2">6.5.3.2</a>), array declarators (<a href="#6.7.6.2">6.7.6.2</a>).
<a name="6.5.2.2" href="#6.5.2.2"><b> 6.5.2.2 Function calls</b></a>
- Constraints
+<b> Constraints</b>
1 The expression that denotes the called function92) shall have type pointer to function
returning void or returning a complete object type other than an array type.
2 If the expression that denotes the called function has a type that includes a prototype, the
have a type such that its value may be assigned to an object with the unqualified version
of the type of its corresponding parameter.
- Semantics
+<b> Semantics</b>
3 A postfix expression followed by parentheses () containing a possibly empty, comma-
separated list of expressions is a function call. The postfix expression denotes the called
function. The list of expressions specifies the arguments to the function.
Forward references: function declarators (including prototypes) (<a href="#6.7.6.3">6.7.6.3</a>), function
definitions (<a href="#6.9.1">6.9.1</a>), the return statement (<a href="#6.8.6.4">6.8.6.4</a>), simple assignment (<a href="#6.5.16.1">6.5.16.1</a>).
<a name="6.5.2.3" href="#6.5.2.3"><b> 6.5.2.3 Structure and union members</b></a>
- Constraints
+<b> Constraints</b>
1 The first operand of the . operator shall have an atomic, qualified, or unqualified
structure or union type, and the second operand shall name a member of that type.
2 The first operand of the -> operator shall have type ''pointer to atomic, qualified, or
unqualified structure'' or ''pointer to atomic, qualified, or unqualified union'', and the
second operand shall name a member of the type pointed to.
- Semantics
+<b> Semantics</b>
3 A postfix expression followed by the . operator and an identifier designates a member of
a structure or union object. The value is that of the named member,95) and is an lvalue if
the first expression is an lvalue. If the first expression has qualified type, the result has
[<a name="p84" href="#p84">page 84</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.2.4" href="#6.5.2.4"><b> 6.5.2.4 Postfix increment and decrement operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the postfix increment or decrement operator shall have atomic, qualified,
or unqualified real or pointer type, and shall be a modifiable lvalue.
- Semantics
+<b> Semantics</b>
2 The result of the postfix ++ operator is the value of the operand. As a side effect, the
value of the operand object is incremented (that is, the value 1 of the appropriate type is
added to it). See the discussions of additive operators and compound assignment for
it).
Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), compound assignment (<a href="#6.5.16.2">6.5.16.2</a>).
<a name="6.5.2.5" href="#6.5.2.5"><b> 6.5.2.5 Compound literals</b></a>
- Constraints
+<b> Constraints</b>
1 The type name shall specify a complete object type or an array of unknown size, but not a
variable length array type.
2 All the constraints for initializer lists in <a href="#6.7.9">6.7.9</a> also apply to compound literals.
- Semantics
+<b> Semantics</b>
3 A postfix expression that consists of a parenthesized type name followed by a brace-
enclosed list of initializers is a compound literal. It provides an unnamed object whose
value is given by the initializer list.99)
[<a name="p87" href="#p87">page 87</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.3" href="#6.5.3"><b> 6.5.3 Unary operators</b></a>
- Syntax
+<b> Syntax</b>
1 unary-expression:
postfix-expression
++ unary-expression
unary-operator: one of
& * + - ~ !
<a name="6.5.3.1" href="#6.5.3.1"><b> 6.5.3.1 Prefix increment and decrement operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the prefix increment or decrement operator shall have atomic, qualified,
or unqualified real or pointer type, and shall be a modifiable lvalue.
- Semantics
+<b> Semantics</b>
2 The value of the operand of the prefix ++ operator is incremented. The result is the new
value of the operand after incrementation. The expression ++E is equivalent to (E+=1).
See the discussions of additive operators and compound assignment for information on
operand is decremented.
Forward references: additive operators (<a href="#6.5.6">6.5.6</a>), compound assignment (<a href="#6.5.16.2">6.5.16.2</a>).
<a name="6.5.3.2" href="#6.5.3.2"><b> 6.5.3.2 Address and indirection operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the unary & operator shall be either a function designator, the result of a
[] or unary * operator, or an lvalue that designates an object that is not a bit-field and is
not declared with the register storage-class specifier.
2 The operand of the unary * operator shall have pointer type.
- Semantics
+<b> Semantics</b>
3 The unary & operator yields the address of its operand. If the operand has type ''type'',
the result has type ''pointer to type''. If the operand is the result of a unary * operator,
neither that operator nor the & operator is evaluated and the result is as if both were
Forward references: storage-class specifiers (<a href="#6.7.1">6.7.1</a>), structure and union specifiers
(<a href="#6.7.2.1">6.7.2.1</a>).
<a name="6.5.3.3" href="#6.5.3.3"><b> 6.5.3.3 Unary arithmetic operators</b></a>
- Constraints
+<b> Constraints</b>
1 The operand of the unary + or - operator shall have arithmetic type; of the ~ operator,
integer type; of the ! operator, scalar type.
- Semantics
+<b> Semantics</b>
2 The result of the unary + operator is the value of its (promoted) operand. The integer
promotions are performed on the operand, and the result has the promoted type.
3 The result of the unary - operator is the negative of its (promoted) operand. The integer
[<a name="p89" href="#p89">page 89</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.3.4" href="#6.5.3.4"><b> 6.5.3.4 The sizeof and alignof operators</b></a>
- Constraints
+<b> Constraints</b>
1 The sizeof operator shall not be applied to an expression that has function type or an
incomplete type, to the parenthesized name of such a type, or to an expression that
designates a bit-field member. The alignof operator shall not be applied to a function
type or an incomplete type.
- Semantics
+<b> Semantics</b>
2 The sizeof operator yields the size (in bytes) of its operand, which may be an
expression or the parenthesized name of a type. The size is determined from the type of
the operand. The result is an integer. If the type of the operand is a variable length array
Forward references: common definitions <a href="#7.19"><stddef.h></a> (<a href="#7.19">7.19</a>), declarations (<a href="#6.7">6.7</a>),
structure and union specifiers (<a href="#6.7.2.1">6.7.2.1</a>), type names (<a href="#6.7.7">6.7.7</a>), array declarators (<a href="#6.7.6.2">6.7.6.2</a>).
<a name="6.5.4" href="#6.5.4"><b> 6.5.4 Cast operators</b></a>
- Syntax
+<b> Syntax</b>
1 cast-expression:
unary-expression
( type-name ) cast-expression
- Constraints
+<b> Constraints</b>
2 Unless the type name specifies a void type, the type name shall specify atomic, qualified,
or unqualified scalar type, and the operand shall have scalar type.
3 Conversions that involve pointers, other than where permitted by the constraints of
<a href="#6.5.16.1">6.5.16.1</a>, shall be specified by means of an explicit cast.
4 A pointer type shall not be converted to any floating type. A floating type shall not be
converted to any pointer type.
- Semantics
+<b> Semantics</b>
5 Preceding an expression by a parenthesized type name converts the value of the
expression to the named type. This construction is called a cast.104) A cast that specifies
no conversion has no effect on the type or value of an expression.
[<a name="p91" href="#p91">page 91</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.5" href="#6.5.5"><b> 6.5.5 Multiplicative operators</b></a>
- Syntax
+<b> Syntax</b>
1 multiplicative-expression:
cast-expression
multiplicative-expression * cast-expression
multiplicative-expression / cast-expression
multiplicative-expression % cast-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have arithmetic type. The operands of the % operator shall
have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the binary * operator is the product of the operands.
5 The result of the / operator is the quotient from the division of the first operand by the
(a/b)*b + a%b shall equal a; otherwise, the behavior of both a/b and a%b is
undefined.
<a name="6.5.6" href="#6.5.6"><b> 6.5.6 Additive operators</b></a>
- Syntax
+<b> Syntax</b>
1 additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
- Constraints
+<b> Constraints</b>
2 For addition, either both operands shall have arithmetic type, or one operand shall be a
pointer to a complete object type and the other shall have integer type. (Incrementing is
equivalent to adding 1.)
-- the left operand is a pointer to a complete object type and the right operand has
integer type.
(Decrementing is equivalent to subtracting 1.)
- Semantics
+<b> Semantics</b>
4 If both operands have arithmetic type, the usual arithmetic conversions are performed on
them.
5 The result of the binary + operator is the sum of the operands.
Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>), common definitions <a href="#7.19"><stddef.h></a>
(<a href="#7.19">7.19</a>).
<a name="6.5.7" href="#6.5.7"><b> 6.5.7 Bitwise shift operators</b></a>
- Syntax
+<b> Syntax</b>
1 shift-expression:
additive-expression
shift-expression << additive-expression
shift-expression >> additive-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The integer promotions are performed on each of the operands. The type of the result is
that of the promoted left operand. If the value of the right operand is negative or is
part of the quotient of E1 / 2E2 . If E1 has a signed type and a negative value, the
resulting value is implementation-defined.
<a name="6.5.8" href="#6.5.8"><b> 6.5.8 Relational operators</b></a>
- Syntax
+<b> Syntax</b>
1 relational-expression:
shift-expression
relational-expression < shift-expression
relational-expression > shift-expression
relational-expression <= shift-expression
relational-expression >= shift-expression
- Constraints
+<b> Constraints</b>
2 One of the following shall hold:
-- both operands have real type; or *
-- both operands are pointers to qualified or unqualified versions of compatible object
types.
- Semantics
+<b> Semantics</b>
3 If both of the operands have arithmetic type, the usual arithmetic conversions are
performed.
4 For the purposes of these operators, a pointer to an object that is not an element of an
(greater than or equal to) shall yield 1 if the specified relation is true and 0 if it is
false.107) The result has type int.
<a name="6.5.9" href="#6.5.9"><b> 6.5.9 Equality operators</b></a>
- Syntax
+<b> Syntax</b>
1 equality-expression:
relational-expression
equality-expression == relational-expression
equality-expression != relational-expression
- Constraints
+<b> Constraints</b>
2 One of the following shall hold:
-- both operands have arithmetic type;
-- both operands are pointers to qualified or unqualified versions of compatible types;
-- one operand is a pointer to an object type and the other is a pointer to a qualified or
unqualified version of void; or
-- one operand is a pointer and the other is a null pointer constant.
- Semantics
+<b> Semantics</b>
3 The == (equal to) and != (not equal to) operators are analogous to the relational
operators except for their lower precedence.108) Each of the operators yields 1 if the
specified relation is true and 0 if it is false. The result has type int. For any pair of
array behaves the same as a pointer to the first element of an array of length one with the
type of the object as its element type.
<a name="6.5.10" href="#6.5.10"><b> 6.5.10 Bitwise AND operator</b></a>
- Syntax
+<b> Syntax</b>
1 AND-expression:
equality-expression
AND-expression & equality-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the binary & operator is the bitwise AND of the operands (that is, each bit in
the result is set if and only if each of the corresponding bits in the converted operands is
[<a name="p97" href="#p97">page 97</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.11" href="#6.5.11"><b> 6.5.11 Bitwise exclusive OR operator</b></a>
- Syntax
+<b> Syntax</b>
1 exclusive-OR-expression:
AND-expression
exclusive-OR-expression ^ AND-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the ^ operator is the bitwise exclusive OR of the operands (that is, each bit
in the result is set if and only if exactly one of the corresponding bits in the converted
operands is set).
<a name="6.5.12" href="#6.5.12"><b> 6.5.12 Bitwise inclusive OR operator</b></a>
- Syntax
+<b> Syntax</b>
1 inclusive-OR-expression:
exclusive-OR-expression
inclusive-OR-expression | exclusive-OR-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have integer type.
- Semantics
+<b> Semantics</b>
3 The usual arithmetic conversions are performed on the operands.
4 The result of the | operator is the bitwise inclusive OR of the operands (that is, each bit in
the result is set if and only if at least one of the corresponding bits in the converted
[<a name="p98" href="#p98">page 98</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.13" href="#6.5.13"><b> 6.5.13 Logical AND operator</b></a>
- Syntax
+<b> Syntax</b>
1 logical-AND-expression:
inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have scalar type.
- Semantics
+<b> Semantics</b>
3 The && operator shall yield 1 if both of its operands compare unequal to 0; otherwise, it
yields 0. The result has type int.
4 Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation;
the first and second operands. If the first operand compares equal to 0, the second
operand is not evaluated.
<a name="6.5.14" href="#6.5.14"><b> 6.5.14 Logical OR operator</b></a>
- Syntax
+<b> Syntax</b>
1 logical-OR-expression:
logical-AND-expression
logical-OR-expression || logical-AND-expression
- Constraints
+<b> Constraints</b>
2 Each of the operands shall have scalar type.
- Semantics
+<b> Semantics</b>
3 The || operator shall yield 1 if either of its operands compare unequal to 0; otherwise, it
yields 0. The result has type int.
4 Unlike the bitwise | operator, the || operator guarantees left-to-right evaluation; if the
[<a name="p99" href="#p99">page 99</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.15" href="#6.5.15"><b> 6.5.15 Conditional operator</b></a>
- Syntax
+<b> Syntax</b>
1 conditional-expression:
logical-OR-expression
logical-OR-expression ? expression : conditional-expression
- Constraints
+<b> Constraints</b>
2 The first operand shall have scalar type.
3 One of the following shall hold for the second and third operands:
-- both operands have arithmetic type;
-- one operand is a pointer and the other is a null pointer constant; or
-- one operand is a pointer to an object type and the other is a pointer to a qualified or
unqualified version of void.
- Semantics
+<b> Semantics</b>
4 The first operand is evaluated; there is a sequence point between its evaluation and the
evaluation of the second or third operand (whichever is evaluated). The second operand
is evaluated only if the first compares unequal to 0; the third operand is evaluated only if
vp ip void *
<a name="6.5.16" href="#6.5.16"><b> 6.5.16 Assignment operators</b></a>
- Syntax
+<b> Syntax</b>
1 assignment-expression:
conditional-expression
unary-expression assignment-operator assignment-expression
assignment-operator: one of
= *= /= %= += -= <<= >>= &= ^= |=
- Constraints
+<b> Constraints</b>
2 An assignment operator shall have a modifiable lvalue as its left operand.
- Semantics
+<b> Semantics</b>
3 An assignment operator stores a value in the object designated by the left operand. An
assignment expression has the value of the left operand after the assignment,111) but is not
an lvalue. The type of an assignment expression is the type the left operand would have
[<a name="p101" href="#p101">page 101</a>] (<a href="#Contents">Contents</a>)
<a name="6.5.16.1" href="#6.5.16.1"><b> 6.5.16.1 Simple assignment</b></a>
- Constraints
+<b> Constraints</b>
1 One of the following shall hold:112)
-- the left operand has atomic, qualified, or unqualified arithmetic type, and the right has
arithmetic type;
pointer constant; or
-- the left operand has type atomic, qualified, or unqualified _Bool, and the right is a
pointer.
- Semantics
+<b> Semantics</b>
2 In simple assignment (=), the value of the right operand is converted to the type of the
assignment expression and replaces the value stored in the object designated by the left
operand.
value of the const object c.
<a name="6.5.16.2" href="#6.5.16.2"><b> 6.5.16.2 Compound assignment</b></a>
- Constraints
+<b> Constraints</b>
1 For the operators += and -= only, either the left operand shall be an atomic, qualified, or
unqualified pointer to a complete object type, and the right shall have integer type; or the
left operand shall have atomic, qualified, or unqualified arithmetic type, and the right
arithmetic type, and (considering the type the left operand would have after lvalue
conversion) each operand shall have arithmetic type consistent with those allowed by the
corresponding binary operator.
- Semantics
+<b> Semantics</b>
3 A compound assignment of the form E1 op = E2 is equivalent to the simple assignment
expression E1 = E1 op (E2), except that the lvalue E1 is evaluated only once, and with
respect to an indeterminately-sequenced function call, the operation of a compound
read-modify-write operation with memory_order_seq_cst memory order
semantics.113)
<a name="6.5.17" href="#6.5.17"><b> 6.5.17 Comma operator</b></a>
- Syntax
+<b> Syntax</b>
1 expression:
assignment-expression
expression , assignment-expression
- Semantics
+<b> Semantics</b>
2 The left operand of a comma operator is evaluated as a void expression; there is a
sequence point between its evaluation and that of the right operand. Then the right
operand is evaluated; the result has its type and value.114) *
[<a name="p104" href="#p104">page 104</a>] (<a href="#Contents">Contents</a>)
<a name="6.6" href="#6.6"><b> 6.6 Constant expressions</b></a>
- Syntax
+<b> Syntax</b>
1 constant-expression:
conditional-expression
- Description
+<b> Description</b>
2 A constant expression can be evaluated during translation rather than runtime, and
accordingly may be used in any place that a constant may be.
- Constraints
+<b> Constraints</b>
3 Constant expressions shall not contain assignment, increment, decrement, function-call,
or comma operators, except when they are contained within a subexpression that is not
evaluated.115)
4 Each constant expression shall evaluate to a constant that is in the range of representable
values for its type.
- Semantics
+<b> Semantics</b>
5 An expression that evaluates to a constant is required in several contexts. If a floating
expression is evaluated in the translation environment, the arithmetic precision and range
shall be at least as great as if the expression were being evaluated in the execution
[<a name="p106" href="#p106">page 106</a>] (<a href="#Contents">Contents</a>)
<a name="6.7" href="#6.7"><b> 6.7 Declarations</b></a>
- Syntax
+<b> Syntax</b>
1 declaration:
declaration-specifiers init-declarator-listopt ;
static_assert-declaration
init-declarator:
declarator
declarator = initializer
- Constraints
+<b> Constraints</b>
2 A declaration other than a static_assert declaration shall declare at least a declarator
(other than the parameters of a function or the members of a structure or union), a tag, or
the members of an enumeration.
may be redeclared as specified in <a href="#6.7.2.3">6.7.2.3</a>.
4 All declarations in the same scope that refer to the same object or function shall specify
compatible types.
- Semantics
+<b> Semantics</b>
5 A declaration specifies the interpretation and attributes of a set of identifiers. A definition
of an identifier is a declaration for that identifier that:
-- for an object, causes storage to be reserved for that object;
Forward references: declarators (<a href="#6.7.6">6.7.6</a>), enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>), initialization
(<a href="#6.7.9">6.7.9</a>), type names (<a href="#6.7.7">6.7.7</a>), type qualifiers (<a href="#6.7.3">6.7.3</a>).
<a name="6.7.1" href="#6.7.1"><b> 6.7.1 Storage-class specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 storage-class-specifier:
typedef
extern
_Thread_local
auto
register
- Constraints
+<b> Constraints</b>
2 At most, one storage-class specifier may be given in the declaration specifiers in a
declaration, except that _Thread_local may appear with static or extern.120)
3 In the declaration of an object with block scope, if the declaration specifiers include
_Thread_local, they shall also include either static or extern. If
_Thread_local appears in any declaration of an object, it shall be present in every
declaration of that object.
- Semantics
+<b> Semantics</b>
4 The typedef specifier is called a ''storage-class specifier'' for syntactic convenience
only; it is discussed in <a href="#6.7.8">6.7.8</a>. The meanings of the various linkages and storage durations
were discussed in <a href="#6.2.2">6.2.2</a> and <a href="#6.2.4">6.2.4</a>.
or union member objects.
Forward references: type definitions (<a href="#6.7.8">6.7.8</a>).
<a name="6.7.2" href="#6.7.2"><b> 6.7.2 Type specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 type-specifier:
void
char
struct-or-union-specifier
enum-specifier
typedef-name
- Constraints
+<b> Constraints</b>
2 At least one type specifier shall be given in the declaration specifiers in each declaration,
and in the specifier-qualifier list in each struct declaration and type name. Each list of
[<a name="p110" href="#p110">page 110</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
4 Specifiers for structures, unions, enumerations, and atomic types are discussed in <a href="#6.7.2.1">6.7.2.1</a>
through <a href="#6.7.2.4">6.7.2.4</a>. Declarations of typedef names are discussed in <a href="#6.7.8">6.7.8</a>. The
characteristics of the other types are discussed in <a href="#6.2.5">6.2.5</a>.
Forward references: atomic type specifiers (<a href="#6.7.2.4">6.7.2.4</a>), enumeration specifiers (<a href="#6.7.2.2">6.7.2.2</a>),
structure and union specifiers (<a href="#6.7.2.1">6.7.2.1</a>), tags (<a href="#6.7.2.3">6.7.2.3</a>), type definitions (<a href="#6.7.8">6.7.8</a>).
<a name="6.7.2.1" href="#6.7.2.1"><b> 6.7.2.1 Structure and union specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 struct-or-union-specifier:
struct-or-union identifieropt { struct-declaration-list }
struct-or-union identifier
struct-declarator:
declarator
declaratoropt : constant-expression
- Constraints
+<b> Constraints</b>
2 A struct-declaration that does not declare an anonymous structure or anonymous union
shall contain a struct-declarator-list.
5 A bit-field shall have a type that is a qualified or unqualified version of _Bool, signed
int, unsigned int, or some other implementation-defined type. It is
implementation-defined whether atomic types are permitted.
- Semantics
+<b> Semantics</b>
6 As discussed in <a href="#6.2.5">6.2.5</a>, a structure is a type consisting of a sequence of members, whose
storage is allocated in an ordered sequence, and a union is a type consisting of a sequence
of members whose storage overlap.
[<a name="p115" href="#p115">page 115</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.2.2" href="#6.7.2.2"><b> 6.7.2.2 Enumeration specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 enum-specifier:
enum identifieropt { enumerator-list }
enum identifieropt { enumerator-list , }
enumerator:
enumeration-constant
enumeration-constant = constant-expression
- Constraints
+<b> Constraints</b>
2 The expression that defines the value of an enumeration constant shall be an integer
constant expression that has a value representable as an int.
- Semantics
+<b> Semantics</b>
3 The identifiers in an enumerator list are declared as constants that have type int and
may appear wherever such are permitted.127) An enumerator with = defines its
enumeration constant as the value of the constant expression. If the first enumerator has
Forward references: tags (<a href="#6.7.2.3">6.7.2.3</a>).
<a name="6.7.2.3" href="#6.7.2.3"><b> 6.7.2.3 Tags</b></a>
- Constraints
+<b> Constraints</b>
1 A specific type shall have its content defined at most once.
2 Where two declarations that use the same tag declare the same type, they shall both use
the same choice of struct, union, or enum.
3 A type specifier of the form
enum identifier
without an enumerator list shall only appear after the type it specifies is complete.
- Semantics
+<b> Semantics</b>
4 All declarations of structure, union, or enumerated types that have the same scope and
use the same tag declare the same type. Irrespective of whether there is a tag or what
other declarations of the type are in the same translation unit, the type is incomplete129)
Forward references: declarators (<a href="#6.7.6">6.7.6</a>), type definitions (<a href="#6.7.8">6.7.8</a>).
<a name="6.7.2.4" href="#6.7.2.4"><b> 6.7.2.4 Atomic type specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 atomic-type-specifier:
_Atomic ( type-name )
- Constraints
+<b> Constraints</b>
2 Atomic type specifiers shall not be used if the implementation does not support atomic
types (see <a href="#6.10.8.3">6.10.8.3</a>).
3 The type name in an atomic type specifier shall not refer to an array type, a function type,
an atomic type, or a qualified type.
- Semantics
+<b> Semantics</b>
4 The properties associated with atomic types are meaningful only for expressions that are
lvalues. If the _Atomic keyword is immediately followed by a left parenthesis, it is
interpreted as a type specifier (with a type name), not as a type qualifier.
[<a name="p119" href="#p119">page 119</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.3" href="#6.7.3"><b> 6.7.3 Type qualifiers</b></a>
- Syntax
+<b> Syntax</b>
1 type-qualifier:
const
restrict
volatile
_Atomic
- Constraints
+<b> Constraints</b>
2 Types other than pointer types whose referenced type is an object type shall not be
restrict-qualified.
3 The type modified by the _Atomic qualifier shall not be an array type or a function
type.
- Semantics
+<b> Semantics</b>
4 The properties associated with qualified types are meaningful only for expressions that
are lvalues.132)
5 If the same qualifier appears more than once in the same specifier-qualifier-list, either
}
<a name="6.7.4" href="#6.7.4"><b> 6.7.4 Function specifiers</b></a>
- Syntax
+<b> Syntax</b>
1 function-specifier:
inline
_Noreturn
- Constraints
+<b> Constraints</b>
2 Function specifiers shall be used only in the declaration of an identifier for a function.
3 An inline definition of a function with external linkage shall not contain a definition of a
modifiable object with static or thread storage duration, and shall not contain a reference
to an identifier with internal linkage.
4 In a hosted environment, no function specifier(s) shall appear in a declaration of main.
- Semantics
+<b> Semantics</b>
5 A function specifier may appear more than once; the behavior is the same as if it
appeared only once.
6 A function declared with an inline function specifier is an inline function. Making a *
Forward references: function definitions (<a href="#6.9.1">6.9.1</a>).
<a name="6.7.5" href="#6.7.5"><b> 6.7.5 Alignment specifier</b></a>
- Syntax
+<b> Syntax</b>
1 alignment-specifier:
_Alignas ( type-name )
_Alignas ( constant-expression )
- Constraints
+<b> Constraints</b>
2 An alignment attribute shall not be specified in a declaration of a typedef, or a bit-field, or
a function, or a parameter, or an object declared with the register storage-class
specifier.
4 The combined effect of all alignment attributes in a declaration shall not specify an
alignment that is less strict than the alignment that would otherwise be required for the
type of the object or member being declared.
- Semantics
+<b> Semantics</b>
5 The first form is equivalent to _Alignas(alignof(type-name)).
6 The alignment requirement of the declared object or member is taken to be the specified
alignment. An alignment specification of zero has no effect.141) When multiple
[<a name="p126" href="#p126">page 126</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.6" href="#6.7.6"><b> 6.7.6 Declarators</b></a>
- Syntax
+<b> Syntax</b>
1 declarator:
pointeropt direct-declarator
direct-declarator:
identifier-list:
identifier
identifier-list , identifier
- Semantics
+<b> Semantics</b>
2 Each declarator declares one identifier, and asserts that when an operand of the same
form as the declarator appears in an expression, it designates a function or object with the
scope, storage duration, and type indicated by the declaration specifiers.
directly or via one or more typedefs.
Forward references: array declarators (<a href="#6.7.6.2">6.7.6.2</a>), type definitions (<a href="#6.7.8">6.7.8</a>).
<a name="6.7.6.1" href="#6.7.6.1"><b> 6.7.6.1 Pointer declarators</b></a>
- Semantics
+<b> Semantics</b>
1 If, in the declaration ''T D1'', D1 has the form
* type-qualifier-listopt D
and the type specified for ident in the declaration ''T D'' is ''derived-declarator-type-list
declares constant_ptr as an object that has type ''const-qualified pointer to int''.
<a name="6.7.6.2" href="#6.7.6.2"><b> 6.7.6.2 Array declarators</b></a>
- Constraints
+<b> Constraints</b>
1 In addition to optional type qualifiers and the keyword static, the [ and ] may delimit
an expression or *. If they delimit an expression (which specifies the size of an array), the
expression shall have an integer type. If the expression is a constant expression, it shall
identifier (as defined in <a href="#6.2.3">6.2.3</a>), have no linkage, and have either block scope or function
prototype scope. If an identifier is declared to be an object with static or thread storage
duration, it shall not have a variable length array type.
- Semantics
+<b> Semantics</b>
3 If, in the declaration ''T D1'', D1 has one of the forms:
D[ type-qualifier-listopt assignment-expressionopt ]
D[ static type-qualifier-listopt assignment-expression ]
Forward references: function declarators (<a href="#6.7.6.3">6.7.6.3</a>), function definitions (<a href="#6.9.1">6.9.1</a>),
initialization (<a href="#6.7.9">6.7.9</a>).
<a name="6.7.6.3" href="#6.7.6.3"><b> 6.7.6.3 Function declarators (including prototypes)</b></a>
- Constraints
+<b> Constraints</b>
1 A function declarator shall not specify a return type that is a function type or an array
type.
2 The only storage-class specifier that shall occur in a parameter declaration is register.
shall be empty.
4 After adjustment, the parameters in a parameter type list in a function declarator that is
part of a definition of that function shall not have incomplete type.
- Semantics
+<b> Semantics</b>
5 If, in the declaration ''T D1'', D1 has the form
[<a name="p134" href="#p134">page 134</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.7" href="#6.7.7"><b> 6.7.7 Type names</b></a>
- Syntax
+<b> Syntax</b>
1 type-name:
specifier-qualifier-list abstract-declaratoropt
abstract-declarator:
assignment-expression ]
direct-abstract-declaratoropt [ * ]
direct-abstract-declaratoropt ( parameter-type-listopt )
- Semantics
+<b> Semantics</b>
2 In several contexts, it is necessary to specify a type. This is accomplished using a type
name, which is syntactically a declaration for a function or an object of that type that
omits the identifier.147)
[<a name="p135" href="#p135">page 135</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.8" href="#6.7.8"><b> 6.7.8 Type definitions</b></a>
- Syntax
+<b> Syntax</b>
1 typedef-name:
identifier
- Constraints
+<b> Constraints</b>
2 If a typedef name specifies a variably modified type then it shall have block scope.
- Semantics
+<b> Semantics</b>
3 In a declaration whose storage-class specifier is typedef, each declarator defines an
identifier to be a typedef name that denotes the type specified for the identifier in the way
described in <a href="#6.7.6">6.7.6</a>. Any array size expressions associated with variable length array
[<a name="p137" href="#p137">page 137</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.9" href="#6.7.9"><b> 6.7.9 Initialization</b></a>
- Syntax
+<b> Syntax</b>
1 initializer:
assignment-expression
{ initializer-list }
designator:
[ constant-expression ]
. identifier
- Constraints
+<b> Constraints</b>
2 No initializer shall attempt to provide a value for an object not contained within the entity
being initialized.
3 The type of the entity to be initialized shall be an array of unknown size or a complete
identifier shall be the name of a member of that type.
[<a name="p138" href="#p138">page 138</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
8 An initializer specifies the initial value stored in an object.
9 Except where explicitly stated otherwise, for the purposes of this subclause unnamed
members of objects of structure and union type do not participate in initialization.
[<a name="p143" href="#p143">page 143</a>] (<a href="#Contents">Contents</a>)
<a name="6.7.10" href="#6.7.10"><b> 6.7.10 Static assertions</b></a>
- Syntax
+<b> Syntax</b>
1 static_assert-declaration:
_Static_assert ( constant-expression , string-literal ) ;
- Constraints
+<b> Constraints</b>
2 The constant expression shall compare unequal to 0.
- Semantics
+<b> Semantics</b>
3 The constant expression shall be an integer constant expression. If the value of the
constant expression compares unequal to 0, the declaration has no effect. Otherwise, the
constraint is violated and the implementation shall produce a diagnostic message that
[<a name="p144" href="#p144">page 144</a>] (<a href="#Contents">Contents</a>)
<a name="6.8" href="#6.8"><b> 6.8 Statements and blocks</b></a>
- Syntax
+<b> Syntax</b>
1 statement:
labeled-statement
compound-statement
selection-statement
iteration-statement
jump-statement
- Semantics
+<b> Semantics</b>
2 A statement specifies an action to be performed. Except as indicated, statements are
executed in sequence.
3 A block allows a set of declarations and statements to be grouped into one syntactic unit.
Forward references: expression and null statements (<a href="#6.8.3">6.8.3</a>), selection statements
(<a href="#6.8.4">6.8.4</a>), iteration statements (<a href="#6.8.5">6.8.5</a>), the return statement (<a href="#6.8.6.4">6.8.6.4</a>).
<a name="6.8.1" href="#6.8.1"><b> 6.8.1 Labeled statements</b></a>
- Syntax
+<b> Syntax</b>
1 labeled-statement:
identifier : statement
case constant-expression : statement
default : statement
- Constraints
+<b> Constraints</b>
2 A case or default label shall appear only in a switch statement. Further
constraints on such labels are discussed under the switch statement.
[<a name="p145" href="#p145">page 145</a>] (<a href="#Contents">Contents</a>)
3 Label names shall be unique within a function.
- Semantics
+<b> Semantics</b>
4 Any statement may be preceded by a prefix that declares an identifier as a label name.
Labels in themselves do not alter the flow of control, which continues unimpeded across
them.
Forward references: the goto statement (<a href="#6.8.6.1">6.8.6.1</a>), the switch statement (<a href="#6.8.4.2">6.8.4.2</a>).
<a name="6.8.2" href="#6.8.2"><b> 6.8.2 Compound statement</b></a>
- Syntax
+<b> Syntax</b>
1 compound-statement:
{ block-item-listopt }
block-item-list:
block-item:
declaration
statement
- Semantics
+<b> Semantics</b>
2 A compound statement is a block.
<a name="6.8.3" href="#6.8.3"><b> 6.8.3 Expression and null statements</b></a>
- Syntax
+<b> Syntax</b>
1 expression-statement:
expressionopt ;
- Semantics
+<b> Semantics</b>
2 The expression in an expression statement is evaluated as a void expression for its side
effects.153)
3 A null statement (consisting of just a semicolon) performs no operations.
Forward references: iteration statements (<a href="#6.8.5">6.8.5</a>).
<a name="6.8.4" href="#6.8.4"><b> 6.8.4 Selection statements</b></a>
- Syntax
+<b> Syntax</b>
1 selection-statement:
if ( expression ) statement
if ( expression ) statement else statement
switch ( expression ) statement
- Semantics
+<b> Semantics</b>
2 A selection statement selects among a set of statements depending on the value of a
controlling expression.
3 A selection statement is a block whose scope is a strict subset of the scope of its
enclosing block. Each associated substatement is also a block whose scope is a strict
subset of the scope of the selection statement.
<a name="6.8.4.1" href="#6.8.4.1"><b> 6.8.4.1 The if statement</b></a>
- Constraints
+<b> Constraints</b>
1 The controlling expression of an if statement shall have scalar type.
- Semantics
+<b> Semantics</b>
2 In both forms, the first substatement is executed if the expression compares unequal to 0.
In the else form, the second substatement is executed if the expression compares equal
3 An else is associated with the lexically nearest preceding if that is allowed by the
syntax.
<a name="6.8.4.2" href="#6.8.4.2"><b> 6.8.4.2 The switch statement</b></a>
- Constraints
+<b> Constraints</b>
1 The controlling expression of a switch statement shall have integer type.
2 If a switch statement has an associated case or default label within the scope of an
identifier with a variably modified type, the entire switch statement shall be within the
(Any enclosed switch statement may have a default label or case constant
expressions with values that duplicate case constant expressions in the enclosing
switch statement.)
- Semantics
+<b> Semantics</b>
4 A switch statement causes control to jump to, into, or past the statement that is the
switch body, depending on the value of a controlling expression, and on the presence of a
default label and the values of any case labels on or in the switch body. A case or
access an indeterminate value. Similarly, the call to the function f cannot be reached.
<a name="6.8.5" href="#6.8.5"><b> 6.8.5 Iteration statements</b></a>
- Syntax
+<b> Syntax</b>
1 iteration-statement:
while ( expression ) statement
do statement while ( expression ) ;
for ( expressionopt ; expressionopt ; expressionopt ) statement
for ( declaration expressionopt ; expressionopt ) statement
- Constraints
+<b> Constraints</b>
2 The controlling expression of an iteration statement shall have scalar type.
3 The declaration part of a for statement shall only declare identifiers for objects having
storage class auto or register.
- Semantics
+<b> Semantics</b>
4 An iteration statement causes a statement called the loop body to be executed repeatedly
until the controlling expression compares equal to 0. The repetition occurs regardless of
whether the loop body is entered from the iteration statement or by a jump.155)
2 Both clause-1 and expression-3 can be omitted. An omitted expression-2 is replaced by a
nonzero constant.
<a name="6.8.6" href="#6.8.6"><b> 6.8.6 Jump statements</b></a>
- Syntax
+<b> Syntax</b>
1 jump-statement:
goto identifier ;
continue ;
[<a name="p150" href="#p150">page 150</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
2 A jump statement causes an unconditional jump to another place.
<a name="6.8.6.1" href="#6.8.6.1"><b> 6.8.6.1 The goto statement</b></a>
- Constraints
+<b> Constraints</b>
1 The identifier in a goto statement shall name a label located somewhere in the enclosing
function. A goto statement shall not jump from outside the scope of an identifier having
a variably modified type to inside the scope of that identifier.
- Semantics
+<b> Semantics</b>
2 A goto statement causes an unconditional jump to the statement prefixed by the named
label in the enclosing function.
3 EXAMPLE 1 It is sometimes convenient to jump into the middle of a complicated set of statements. The
goto lab4; // invalid: going INTO scope of VLA.
<a name="6.8.6.2" href="#6.8.6.2"><b> 6.8.6.2 The continue statement</b></a>
- Constraints
+<b> Constraints</b>
1 A continue statement shall appear only in or as a loop body.
- Semantics
+<b> Semantics</b>
2 A continue statement causes a jump to the loop-continuation portion of the smallest
enclosing iteration statement; that is, to the end of the loop body. More precisely, in each
of the statements
unless the continue statement shown is in an enclosed iteration statement (in which
case it is interpreted within that statement), it is equivalent to goto contin;.159)
<a name="6.8.6.3" href="#6.8.6.3"><b> 6.8.6.3 The break statement</b></a>
- Constraints
+<b> Constraints</b>
1 A break statement shall appear only in or as a switch body or loop body.
- Semantics
+<b> Semantics</b>
2 A break statement terminates execution of the smallest enclosing switch or iteration
statement.
[<a name="p152" href="#p152">page 152</a>] (<a href="#Contents">Contents</a>)
<a name="6.8.6.4" href="#6.8.6.4"><b> 6.8.6.4 The return statement</b></a>
- Constraints
+<b> Constraints</b>
1 A return statement with an expression shall not appear in a function whose return type
is void. A return statement without an expression shall only appear in a function
whose return type is void.
- Semantics
+<b> Semantics</b>
2 A return statement terminates execution of the current function and returns control to
its caller. A function may have any number of return statements.
3 If a return statement with an expression is executed, the value of the expression is
[<a name="p153" href="#p153">page 153</a>] (<a href="#Contents">Contents</a>)
<a name="6.9" href="#6.9"><b> 6.9 External definitions</b></a>
- Syntax
+<b> Syntax</b>
1 translation-unit:
external-declaration
translation-unit external-declaration
external-declaration:
function-definition
declaration
- Constraints
+<b> Constraints</b>
2 The storage-class specifiers auto and register shall not appear in the declaration
specifiers in an external declaration.
3 There shall be no more than one external definition for each identifier declared with
linkage is used in an expression (other than as a part of the operand of a sizeof
operator whose result is an integer constant), there shall be exactly one external definition
for the identifier in the translation unit.
- Semantics
+<b> Semantics</b>
4 As discussed in <a href="#5.1.1.1">5.1.1.1</a>, the unit of program text after preprocessing is a translation unit,
which consists of a sequence of external declarations. These are described as ''external''
because they appear outside any function (and hence have file scope). As discussed in
[<a name="p154" href="#p154">page 154</a>] (<a href="#Contents">Contents</a>)
<a name="6.9.1" href="#6.9.1"><b> 6.9.1 Function definitions</b></a>
- Syntax
+<b> Syntax</b>
1 function-definition:
declaration-specifiers declarator declaration-listopt compound-statement
declaration-list:
declaration
declaration-list declaration
- Constraints
+<b> Constraints</b>
2 The identifier declared in a function definition (which is the name of the function) shall
have a function type, as specified by the declarator portion of the function definition.162)
3 The return type of a function shall be void or a complete object type other than array
[<a name="p155" href="#p155">page 155</a>] (<a href="#Contents">Contents</a>)
- Semantics
+<b> Semantics</b>
7 The declarator in a function definition specifies the name of the function being defined
and the identifiers of its parameters. If the declarator includes a parameter type list, the
list also specifies the types of all the parameters; such a declarator also serves as a
}
<a name="6.9.2" href="#6.9.2"><b> 6.9.2 External object definitions</b></a>
- Semantics
+<b> Semantics</b>
1 If the declaration of an identifier for an object has file scope and an initializer, the
declaration is an external definition for the identifier.
2 A declaration of an identifier for an object that has file scope without an initializer, and
[<a name="p158" href="#p158">page 158</a>] (<a href="#Contents">Contents</a>)
<a name="6.10" href="#6.10"><b> 6.10 Preprocessing directives</b></a>
- Syntax
+<b> Syntax</b>
1 preprocessing-file:
groupopt
group:
pp-tokens preprocessing-token
new-line:
the new-line character
- Description
+<b> Description</b>
2 A preprocessing directive consists of a sequence of preprocessing tokens that satisfies the
following constraints: The first token in the sequence is a # preprocessing token that (at
the start of translation phase 4) is either the first character in the source file (optionally
4 When in a group that is skipped (<a href="#6.10.1">6.10.1</a>), the directive syntax is relaxed to allow any
sequence of preprocessing tokens to occur between the directive name and the following
new-line character.
- Constraints
+<b> Constraints</b>
5 The only white-space characters that shall appear between preprocessing tokens within a
preprocessing directive (from just after the introducing # preprocessing token through
just before the terminating new-line character) are space and horizontal-tab (including
spaces that have replaced comments or possibly other white-space characters in
translation phase 3).
- Semantics
+<b> Semantics</b>
6 The implementation can process and skip sections of source files conditionally, include
other source files, and replace macros. These capabilities are called preprocessing,
because conceptually they occur before translation of the resulting translation unit.
replaced.
<a name="6.10.1" href="#6.10.1"><b> 6.10.1 Conditional inclusion</b></a>
- Constraints
+<b> Constraints</b>
1 The expression that controls conditional inclusion shall be an integer constant expression
except that: identifiers (including those lexically identical to keywords) are interpreted as *
described below;166) and it may contain unary operator expressions of the form
2 Each preprocessing token that remains (in the list of preprocessing tokens that will
become the controlling expression) after all macro replacements have occurred shall be in
the lexical form of a token (<a href="#6.4">6.4</a>).
- Semantics
+<b> Semantics</b>
3 Preprocessing directives of the forms
# if constant-expression new-line groupopt
# elif constant-expression new-line groupopt
Forward references: macro replacement (<a href="#6.10.3">6.10.3</a>), source file inclusion (<a href="#6.10.2">6.10.2</a>), largest
integer types (<a href="#7.20.1.5">7.20.1.5</a>).
<a name="6.10.2" href="#6.10.2"><b> 6.10.2 Source file inclusion</b></a>
- Constraints
+<b> Constraints</b>
1 A #include directive shall identify a header or source file that can be processed by the
implementation.
- Semantics
+<b> Semantics</b>
2 A preprocessing directive of the form
# include <h-char-sequence> new-line
searches a sequence of implementation-defined places for a header identified uniquely by
Forward references: macro replacement (<a href="#6.10.3">6.10.3</a>).
<a name="6.10.3" href="#6.10.3"><b> 6.10.3 Macro replacement</b></a>
- Constraints
+<b> Constraints</b>
1 Two replacement lists are identical if and only if the preprocessing tokens in both have
the same number, ordering, spelling, and white-space separation, where all white-space
separations are considered identical.
macro that uses the ellipsis notation in the parameters.
6 A parameter identifier in a function-like macro shall be uniquely declared within its
scope.
- Semantics
+<b> Semantics</b>
7 The identifier immediately following the define is called the macro name. There is one
name space for macro names. Any white-space characters preceding or following the
replacement list of preprocessing tokens are not considered part of the replacement list
were a parameter, and the variable arguments shall form the preprocessing tokens used to
replace it.
<a name="6.10.3.2" href="#6.10.3.2"><b> 6.10.3.2 The # operator</b></a>
- Constraints
+<b> Constraints</b>
1 Each # preprocessing token in the replacement list for a function-like macro shall be
followed by a parameter as the next preprocessing token in the replacement list.
- Semantics
+<b> Semantics</b>
2 If, in the replacement list, a parameter is immediately preceded by a # preprocessing
token, both are replaced by a single character string literal preprocessing token that
contains the spelling of the preprocessing token sequence for the corresponding
[<a name="p167" href="#p167">page 167</a>] (<a href="#Contents">Contents</a>)
<a name="6.10.3.3" href="#6.10.3.3"><b> 6.10.3.3 The ## operator</b></a>
- Constraints
+<b> Constraints</b>
1 A ## preprocessing token shall not occur at the beginning or at the end of a replacement
list for either form of macro definition.
- Semantics
+<b> Semantics</b>
2 If, in the replacement list of a function-like macro, a parameter is immediately preceded
or followed by a ## preprocessing token, the parameter is replaced by the corresponding
argument's preprocessing token sequence; however, if an argument consists of no
printf("x is %d but y is %d", x, y));
<a name="6.10.4" href="#6.10.4"><b> 6.10.4 Line control</b></a>
- Constraints
+<b> Constraints</b>
1 The string literal of a #line directive, if present, shall be a character string literal.
- Semantics
+<b> Semantics</b>
2 The line number of the current source line is one greater than the number of new-line
characters read or introduced in translation phase 1 (<a href="#5.1.1.2">5.1.1.2</a>) while processing the source
file to the current token.
[<a name="p172" href="#p172">page 172</a>] (<a href="#Contents">Contents</a>)
<a name="6.10.5" href="#6.10.5"><b> 6.10.5 Error directive</b></a>
- Semantics
+<b> Semantics</b>
1 A preprocessing directive of the form
# error pp-tokensopt new-line
causes the implementation to produce a diagnostic message that includes the specified
sequence of preprocessing tokens.
<a name="6.10.6" href="#6.10.6"><b> 6.10.6 Pragma directive</b></a>
- Semantics
+<b> Semantics</b>
1 A preprocessing directive of the form
# pragma pp-tokensopt new-line
where the preprocessing token STDC does not immediately follow pragma in the
[<a name="p173" href="#p173">page 173</a>] (<a href="#Contents">Contents</a>)
<a name="6.10.7" href="#6.10.7"><b> 6.10.7 Null directive</b></a>
- Semantics
+<b> Semantics</b>
1 A preprocessing directive of the form
# new-line
has no effect.
2 An implementation that defines __STDC_NO_COMPLEX__ shall not define
__STDC_IEC_559_COMPLEX__.
<a name="6.10.9" href="#6.10.9"><b> 6.10.9 Pragma operator</b></a>
- Semantics
+<b> Semantics</b>
1 A unary operator expression of the form:
_Pragma ( string-literal )
is processed as follows: The string literal is destringized by deleting the L prefix, if
expands to _Static_assert.
<a name="7.2.1" href="#7.2.1"><b> 7.2.1 Program diagnostics</b></a>
<a name="7.2.1.1" href="#7.2.1.1"><b> 7.2.1.1 The assert macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.2"><assert.h></a>
void assert(scalar expression);
- Description
+<b> Description</b>
2 The assert macro puts diagnostic tests into programs; it expands to a void expression.
When it is executed, if expression (which shall have a scalar type) is false (that is,
compares equal to 0), the assert macro writes information about the particular call that
[<a name="p185" href="#p185">page 185</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The assert macro returns no value.
Forward references: the abort function (<a href="#7.22.4.1">7.22.4.1</a>).
the finite endpoint of the cut along the negative real axis approaches the cut from above,
so the cut maps to the positive imaginary axis.
<a name="7.3.4" href="#7.3.4"><b> 7.3.4 The CX_LIMITED_RANGE pragma</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
#pragma STDC CX_LIMITED_RANGE on-off-switch
- Description
+<b> Description</b>
2 The usual mathematical formulas for complex multiply, divide, and absolute value are
problematic because of their treatment of infinities and because of undue overflow and
underflow. The CX_LIMITED_RANGE pragma can be used to inform the
undefined. The default state for the pragma is ''off''.
<a name="7.3.5" href="#7.3.5"><b> 7.3.5 Trigonometric functions</b></a>
<a name="7.3.5.1" href="#7.3.5.1"><b> 7.3.5.1 The cacos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cacos(double complex z);
float complex cacosf(float complex z);
long double complex cacosl(long double complex z);
- Description
+<b> Description</b>
2 The cacos functions compute the complex arc cosine of z, with branch cuts outside the
interval [-1, +1] along the real axis.
- Returns
+<b> Returns</b>
3 The cacos functions return the complex arc cosine value, in the range of a strip
mathematically unbounded along the imaginary axis and in the interval [0, pi ] along the
real axis.
<a name="7.3.5.2" href="#7.3.5.2"><b> 7.3.5.2 The casin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex casin(double complex z);
float complex casinf(float complex z);
long double complex casinl(long double complex z);
- Description
+<b> Description</b>
2 The casin functions compute the complex arc sine of z, with branch cuts outside the
interval [-1, +1] along the real axis.
- Returns
+<b> Returns</b>
3 The casin functions return the complex arc sine value, in the range of a strip
mathematically unbounded along the imaginary axis and in the interval [-pi /2, +pi /2]
along the real axis.
<a name="7.3.5.3" href="#7.3.5.3"><b> 7.3.5.3 The catan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex catan(double complex z);
float complex catanf(float complex z);
long double complex catanl(long double complex z);
- Description
+<b> Description</b>
2 The catan functions compute the complex arc tangent of z, with branch cuts outside the
interval [-i, +i] along the imaginary axis.
- Returns
+<b> Returns</b>
3 The catan functions return the complex arc tangent value, in the range of a strip
mathematically unbounded along the imaginary axis and in the interval [-pi /2, +pi /2]
along the real axis.
<a name="7.3.5.4" href="#7.3.5.4"><b> 7.3.5.4 The ccos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ccos(double complex z);
float complex ccosf(float complex z);
long double complex ccosl(long double complex z);
- Description
+<b> Description</b>
2 The ccos functions compute the complex cosine of z.
- Returns
+<b> Returns</b>
3 The ccos functions return the complex cosine value.
<a name="7.3.5.5" href="#7.3.5.5"><b> 7.3.5.5 The csin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex csin(double complex z);
float complex csinf(float complex z);
long double complex csinl(long double complex z);
- Description
+<b> Description</b>
2 The csin functions compute the complex sine of z.
[<a name="p190" href="#p190">page 190</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The csin functions return the complex sine value.
<a name="7.3.5.6" href="#7.3.5.6"><b> 7.3.5.6 The ctan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ctan(double complex z);
float complex ctanf(float complex z);
long double complex ctanl(long double complex z);
- Description
+<b> Description</b>
2 The ctan functions compute the complex tangent of z.
- Returns
+<b> Returns</b>
3 The ctan functions return the complex tangent value.
<a name="7.3.6" href="#7.3.6"><b> 7.3.6 Hyperbolic functions</b></a>
<a name="7.3.6.1" href="#7.3.6.1"><b> 7.3.6.1 The cacosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cacosh(double complex z);
float complex cacoshf(float complex z);
long double complex cacoshl(long double complex z);
- Description
+<b> Description</b>
2 The cacosh functions compute the complex arc hyperbolic cosine of z, with a branch
cut at values less than 1 along the real axis.
- Returns
+<b> Returns</b>
3 The cacosh functions return the complex arc hyperbolic cosine value, in the range of a
half-strip of nonnegative values along the real axis and in the interval [-ipi , +ipi ] along the
imaginary axis.
<a name="7.3.6.2" href="#7.3.6.2"><b> 7.3.6.2 The casinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex casinh(double complex z);
float complex casinhf(float complex z);
[<a name="p191" href="#p191">page 191</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The casinh functions compute the complex arc hyperbolic sine of z, with branch cuts
outside the interval [-i, +i] along the imaginary axis.
- Returns
+<b> Returns</b>
3 The casinh functions return the complex arc hyperbolic sine value, in the range of a
strip mathematically unbounded along the real axis and in the interval [-ipi /2, +ipi /2]
along the imaginary axis.
<a name="7.3.6.3" href="#7.3.6.3"><b> 7.3.6.3 The catanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex catanh(double complex z);
float complex catanhf(float complex z);
long double complex catanhl(long double complex z);
- Description
+<b> Description</b>
2 The catanh functions compute the complex arc hyperbolic tangent of z, with branch
cuts outside the interval [-1, +1] along the real axis.
- Returns
+<b> Returns</b>
3 The catanh functions return the complex arc hyperbolic tangent value, in the range of a
strip mathematically unbounded along the real axis and in the interval [-ipi /2, +ipi /2]
along the imaginary axis.
<a name="7.3.6.4" href="#7.3.6.4"><b> 7.3.6.4 The ccosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ccosh(double complex z);
float complex ccoshf(float complex z);
long double complex ccoshl(long double complex z);
- Description
+<b> Description</b>
2 The ccosh functions compute the complex hyperbolic cosine of z.
- Returns
+<b> Returns</b>
3 The ccosh functions return the complex hyperbolic cosine value.
[<a name="p192" href="#p192">page 192</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.6.5" href="#7.3.6.5"><b> 7.3.6.5 The csinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex csinh(double complex z);
float complex csinhf(float complex z);
long double complex csinhl(long double complex z);
- Description
+<b> Description</b>
2 The csinh functions compute the complex hyperbolic sine of z.
- Returns
+<b> Returns</b>
3 The csinh functions return the complex hyperbolic sine value.
<a name="7.3.6.6" href="#7.3.6.6"><b> 7.3.6.6 The ctanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex ctanh(double complex z);
float complex ctanhf(float complex z);
long double complex ctanhl(long double complex z);
- Description
+<b> Description</b>
2 The ctanh functions compute the complex hyperbolic tangent of z.
- Returns
+<b> Returns</b>
3 The ctanh functions return the complex hyperbolic tangent value.
<a name="7.3.7" href="#7.3.7"><b> 7.3.7 Exponential and logarithmic functions</b></a>
<a name="7.3.7.1" href="#7.3.7.1"><b> 7.3.7.1 The cexp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cexp(double complex z);
float complex cexpf(float complex z);
long double complex cexpl(long double complex z);
- Description
+<b> Description</b>
2 The cexp functions compute the complex base-e exponential of z.
- Returns
+<b> Returns</b>
3 The cexp functions return the complex base-e exponential value.
[<a name="p193" href="#p193">page 193</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.7.2" href="#7.3.7.2"><b> 7.3.7.2 The clog functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex clog(double complex z);
float complex clogf(float complex z);
long double complex clogl(long double complex z);
- Description
+<b> Description</b>
2 The clog functions compute the complex natural (base-e) logarithm of z, with a branch
cut along the negative real axis.
- Returns
+<b> Returns</b>
3 The clog functions return the complex natural logarithm value, in the range of a strip
mathematically unbounded along the real axis and in the interval [-ipi , +ipi ] along the
imaginary axis.
<a name="7.3.8" href="#7.3.8"><b> 7.3.8 Power and absolute-value functions</b></a>
<a name="7.3.8.1" href="#7.3.8.1"><b> 7.3.8.1 The cabs functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double cabs(double complex z);
float cabsf(float complex z);
long double cabsl(long double complex z);
- Description
+<b> Description</b>
2 The cabs functions compute the complex absolute value (also called norm, modulus, or
magnitude) of z.
- Returns
+<b> Returns</b>
3 The cabs functions return the complex absolute value.
<a name="7.3.8.2" href="#7.3.8.2"><b> 7.3.8.2 The cpow functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cpow(double complex x, double complex y);
float complex cpowf(float complex x, float complex y);
[<a name="p194" href="#p194">page 194</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The cpow functions compute the complex power function xy , with a branch cut for the
first parameter along the negative real axis.
- Returns
+<b> Returns</b>
3 The cpow functions return the complex power function value.
<a name="7.3.8.3" href="#7.3.8.3"><b> 7.3.8.3 The csqrt functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex csqrt(double complex z);
float complex csqrtf(float complex z);
long double complex csqrtl(long double complex z);
- Description
+<b> Description</b>
2 The csqrt functions compute the complex square root of z, with a branch cut along the
negative real axis.
- Returns
+<b> Returns</b>
3 The csqrt functions return the complex square root value, in the range of the right half-
plane (including the imaginary axis).
<a name="7.3.9" href="#7.3.9"><b> 7.3.9 Manipulation functions</b></a>
<a name="7.3.9.1" href="#7.3.9.1"><b> 7.3.9.1 The carg functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double carg(double complex z);
float cargf(float complex z);
long double cargl(long double complex z);
- Description
+<b> Description</b>
2 The carg functions compute the argument (also called phase angle) of z, with a branch
cut along the negative real axis.
- Returns
+<b> Returns</b>
3 The carg functions return the value of the argument in the interval [-pi , +pi ].
[<a name="p195" href="#p195">page 195</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.9.2" href="#7.3.9.2"><b> 7.3.9.2 The cimag functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double cimag(double complex z);
float cimagf(float complex z);
long double cimagl(long double complex z);
- Description
+<b> Description</b>
2 The cimag functions compute the imaginary part of z.196)
- Returns
+<b> Returns</b>
3 The cimag functions return the imaginary part value (as a real).
<a name="7.3.9.3" href="#7.3.9.3"><b> 7.3.9.3 The CMPLX macros</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex CMPLX(double x, double y);
float complex CMPLXF(float x, float y);
long double complex CMPLXL(long double x, long double y);
- Description
+<b> Description</b>
2 The CMPLX macros expand to an expression of the specified complex type, with the real
part having the (converted) value of x and the imaginary part having the (converted)
value of y.
Recommended practice
3 The resulting expression should be suitable for use as an initializer for an object with
static or thread storage duration, provided both arguments are likewise suitable.
- Returns
+<b> Returns</b>
4 The CMPLX macros return the complex value x + i y.
5 NOTE These macros act as if the implementation supported imaginary types and the definitions were:
#define CMPLX(x, y) ((double complex)((double)(x) + \
[<a name="p196" href="#p196">page 196</a>] (<a href="#Contents">Contents</a>)
<a name="7.3.9.4" href="#7.3.9.4"><b> 7.3.9.4 The conj functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex conj(double complex z);
float complex conjf(float complex z);
long double complex conjl(long double complex z);
- Description
+<b> Description</b>
2 The conj functions compute the complex conjugate of z, by reversing the sign of its
imaginary part.
- Returns
+<b> Returns</b>
3 The conj functions return the complex conjugate value.
<a name="7.3.9.5" href="#7.3.9.5"><b> 7.3.9.5 The cproj functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double complex cproj(double complex z);
float complex cprojf(float complex z);
long double complex cprojl(long double complex z);
- Description
+<b> Description</b>
2 The cproj functions compute a projection of z onto the Riemann sphere: z projects to
z except that all complex infinities (even those with one infinite part and one NaN part)
project to positive infinity on the real axis. If z has an infinite part, then cproj(z) is
equivalent to
INFINITY + I * copysign(0.0, cimag(z))
- Returns
+<b> Returns</b>
3 The cproj functions return the value of the projection onto the Riemann sphere.
<a name="7.3.9.6" href="#7.3.9.6"><b> 7.3.9.6 The creal functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.3"><complex.h></a>
double creal(double complex z);
float crealf(float complex z);
long double creall(long double complex z);
- Description
+<b> Description</b>
2 The creal functions compute the real part of z.197)
[<a name="p197" href="#p197">page 197</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The creal functions return the real part value.
1 The functions in this subclause return nonzero (true) if and only if the value of the
argument c conforms to that in the description of the function.
<a name="7.4.1.1" href="#7.4.1.1"><b> 7.4.1.1 The isalnum function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isalnum(int c);
- Description
+<b> Description</b>
2 The isalnum function tests for any character for which isalpha or isdigit is true.
<a name="7.4.1.2" href="#7.4.1.2"><b> 7.4.1.2 The isalpha function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isalpha(int c);
- Description
+<b> Description</b>
2 The isalpha function tests for any character for which isupper or islower is true,
or any character that is one of a locale-specific set of alphabetic characters for which
none of iscntrl, isdigit, ispunct, or isspace is true.200) In the "C" locale,
isalpha returns true only for the characters for which isupper or islower is true.
<a name="7.4.1.3" href="#7.4.1.3"><b> 7.4.1.3 The isblank function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isblank(int c);
- Description
+<b> Description</b>
2 The isblank function tests for any character that is a standard blank character or is one
of a locale-specific set of characters for which isspace is true and that is used to
separate words within a line of text. The standard blank characters are the following:
space (' '), and horizontal tab ('\t'). In the "C" locale, isblank returns true only
for the standard blank characters.
<a name="7.4.1.4" href="#7.4.1.4"><b> 7.4.1.4 The iscntrl function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int iscntrl(int c);
- Description
+<b> Description</b>
2 The iscntrl function tests for any control character.
<a name="7.4.1.5" href="#7.4.1.5"><b> 7.4.1.5 The isdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isdigit(int c);
- Description
+<b> Description</b>
2 The isdigit function tests for any decimal-digit character (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.4.1.6" href="#7.4.1.6"><b> 7.4.1.6 The isgraph function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isgraph(int c);
[<a name="p200" href="#p200">page 200</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The isgraph function tests for any printing character except space (' ').
<a name="7.4.1.7" href="#7.4.1.7"><b> 7.4.1.7 The islower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int islower(int c);
- Description
+<b> Description</b>
2 The islower function tests for any character that is a lowercase letter or is one of a
locale-specific set of characters for which none of iscntrl, isdigit, ispunct, or
isspace is true. In the "C" locale, islower returns true only for the lowercase
letters (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.4.1.8" href="#7.4.1.8"><b> 7.4.1.8 The isprint function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isprint(int c);
- Description
+<b> Description</b>
2 The isprint function tests for any printing character including space (' ').
<a name="7.4.1.9" href="#7.4.1.9"><b> 7.4.1.9 The ispunct function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int ispunct(int c);
- Description
+<b> Description</b>
2 The ispunct function tests for any printing character that is one of a locale-specific set
of punctuation characters for which neither isspace nor isalnum is true. In the "C"
locale, ispunct returns true for every printing character for which neither isspace
nor isalnum is true.
<a name="7.4.1.10" href="#7.4.1.10"><b> 7.4.1.10 The isspace function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isspace(int c);
- Description
+<b> Description</b>
2 The isspace function tests for any character that is a standard white-space character or
is one of a locale-specific set of characters for which isalnum is false. The standard
('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). In the
"C" locale, isspace returns true only for the standard white-space characters.
<a name="7.4.1.11" href="#7.4.1.11"><b> 7.4.1.11 The isupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isupper(int c);
- Description
+<b> Description</b>
2 The isupper function tests for any character that is an uppercase letter or is one of a
locale-specific set of characters for which none of iscntrl, isdigit, ispunct, or
isspace is true. In the "C" locale, isupper returns true only for the uppercase
letters (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.4.1.12" href="#7.4.1.12"><b> 7.4.1.12 The isxdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int isxdigit(int c);
- Description
+<b> Description</b>
2 The isxdigit function tests for any hexadecimal-digit character (as defined in <a href="#6.4.4.1">6.4.4.1</a>).
<a name="7.4.2" href="#7.4.2"><b> 7.4.2 Character case mapping functions</b></a>
<a name="7.4.2.1" href="#7.4.2.1"><b> 7.4.2.1 The tolower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int tolower(int c);
- Description
+<b> Description</b>
2 The tolower function converts an uppercase letter to a corresponding lowercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a character for which isupper is true and there are one or more
corresponding characters, as specified by the current locale, for which islower is true,
the tolower function returns one of the corresponding characters (always the same one
[<a name="p202" href="#p202">page 202</a>] (<a href="#Contents">Contents</a>)
<a name="7.4.2.2" href="#7.4.2.2"><b> 7.4.2.2 The toupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.4"><ctype.h></a>
int toupper(int c);
- Description
+<b> Description</b>
2 The toupper function converts a lowercase letter to a corresponding uppercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a character for which islower is true and there are one or more
corresponding characters, as specified by the current locale, for which isupper is true,
the toupper function returns one of the corresponding characters (always the same one
FE_ and an uppercase letter, and having type ''pointer to const-qualified fenv_t'', may
also be specified by the implementation.
<a name="7.6.1" href="#7.6.1"><b> 7.6.1 The FENV_ACCESS pragma</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
#pragma STDC FENV_ACCESS on-off-switch
- Description
+<b> Description</b>
2 The FENV_ACCESS pragma provides a means to inform the implementation when a
program might access the floating-point environment to test floating-point status flags or
run under non-default floating-point control modes.210) The pragma shall occur either
FE_OVERFLOW | FE_INEXACT. For other argument values the behavior of these
functions is undefined.
<a name="7.6.2.1" href="#7.6.2.1"><b> 7.6.2.1 The feclearexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feclearexcept(int excepts);
- Description
+<b> Description</b>
2 The feclearexcept function attempts to clear the supported floating-point exceptions
represented by its argument.
- Returns
+<b> Returns</b>
3 The feclearexcept function returns zero if the excepts argument is zero or if all
the specified exceptions were successfully cleared. Otherwise, it returns a nonzero value.
[<a name="p208" href="#p208">page 208</a>] (<a href="#Contents">Contents</a>)
<a name="7.6.2.2" href="#7.6.2.2"><b> 7.6.2.2 The fegetexceptflag function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fegetexceptflag(fexcept_t *flagp,
int excepts);
- Description
+<b> Description</b>
2 The fegetexceptflag function attempts to store an implementation-defined
representation of the states of the floating-point status flags indicated by the argument
excepts in the object pointed to by the argument flagp.
- Returns
+<b> Returns</b>
3 The fegetexceptflag function returns zero if the representation was successfully
stored. Otherwise, it returns a nonzero value.
<a name="7.6.2.3" href="#7.6.2.3"><b> 7.6.2.3 The feraiseexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feraiseexcept(int excepts);
- Description
+<b> Description</b>
2 The feraiseexcept function attempts to raise the supported floating-point exceptions
represented by its argument.213) The order in which these floating-point exceptions are
raised is unspecified, except as stated in <a href="#F.8.6">F.8.6</a>. Whether the feraiseexcept function
additionally raises the ''inexact'' floating-point exception whenever it raises the
''overflow'' or ''underflow'' floating-point exception is implementation-defined.
- Returns
+<b> Returns</b>
3 The feraiseexcept function returns zero if the excepts argument is zero or if all
the specified exceptions were successfully raised. Otherwise, it returns a nonzero value.
[<a name="p209" href="#p209">page 209</a>] (<a href="#Contents">Contents</a>)
<a name="7.6.2.4" href="#7.6.2.4"><b> 7.6.2.4 The fesetexceptflag function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fesetexceptflag(const fexcept_t *flagp,
int excepts);
- Description
+<b> Description</b>
2 The fesetexceptflag function attempts to set the floating-point status flags
indicated by the argument excepts to the states stored in the object pointed to by
flagp. The value of *flagp shall have been set by a previous call to
fegetexceptflag whose second argument represented at least those floating-point
exceptions represented by the argument excepts. This function does not raise floating-
point exceptions, but only sets the state of the flags.
- Returns
+<b> Returns</b>
3 The fesetexceptflag function returns zero if the excepts argument is zero or if
all the specified flags were successfully set to the appropriate state. Otherwise, it returns
a nonzero value.
<a name="7.6.2.5" href="#7.6.2.5"><b> 7.6.2.5 The fetestexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fetestexcept(int excepts);
- Description
+<b> Description</b>
2 The fetestexcept function determines which of a specified subset of the floating-
point exception flags are currently set. The excepts argument specifies the floating-
point status flags to be queried.214)
- Returns
+<b> Returns</b>
3 The fetestexcept function returns the value of the bitwise OR of the floating-point
exception macros corresponding to the currently set floating-point exceptions included in
excepts.
1 The fegetround and fesetround functions provide control of rounding direction
modes.
<a name="7.6.3.1" href="#7.6.3.1"><b> 7.6.3.1 The fegetround function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fegetround(void);
- Description
+<b> Description</b>
2 The fegetround function gets the current rounding direction.
- Returns
+<b> Returns</b>
3 The fegetround function returns the value of the rounding direction macro
representing the current rounding direction or a negative value if there is no such
rounding direction macro or the current rounding direction is not determinable.
<a name="7.6.3.2" href="#7.6.3.2"><b> 7.6.3.2 The fesetround function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fesetround(int round);
- Description
+<b> Description</b>
2 The fesetround function establishes the rounding direction represented by its
argument round. If the argument is not equal to the value of a rounding direction macro,
the rounding direction is not changed.
- Returns
+<b> Returns</b>
3 The fesetround function returns zero if and only if the requested rounding direction
was established.
1 The functions in this section manage the floating-point environment -- status flags and
control modes -- as one entity.
<a name="7.6.4.1" href="#7.6.4.1"><b> 7.6.4.1 The fegetenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fegetenv(fenv_t *envp);
- Description
+<b> Description</b>
2 The fegetenv function attempts to store the current floating-point environment in the
object pointed to by envp.
- Returns
+<b> Returns</b>
3 The fegetenv function returns zero if the environment was successfully stored.
Otherwise, it returns a nonzero value.
<a name="7.6.4.2" href="#7.6.4.2"><b> 7.6.4.2 The feholdexcept function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feholdexcept(fenv_t *envp);
- Description
+<b> Description</b>
2 The feholdexcept function saves the current floating-point environment in the object
pointed to by envp, clears the floating-point status flags, and then installs a non-stop
(continue on floating-point exceptions) mode, if available, for all floating-point
[<a name="p212" href="#p212">page 212</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The feholdexcept function returns zero if and only if non-stop floating-point
exception handling was successfully installed.
<a name="7.6.4.3" href="#7.6.4.3"><b> 7.6.4.3 The fesetenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int fesetenv(const fenv_t *envp);
- Description
+<b> Description</b>
2 The fesetenv function attempts to establish the floating-point environment represented
by the object pointed to by envp. The argument envp shall point to an object set by a
call to fegetenv or feholdexcept, or equal a floating-point environment macro.
Note that fesetenv merely installs the state of the floating-point status flags
represented through its argument, and does not raise these floating-point exceptions.
- Returns
+<b> Returns</b>
3 The fesetenv function returns zero if the environment was successfully established.
Otherwise, it returns a nonzero value.
<a name="7.6.4.4" href="#7.6.4.4"><b> 7.6.4.4 The feupdateenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.6"><fenv.h></a>
int feupdateenv(const fenv_t *envp);
- Description
+<b> Description</b>
2 The feupdateenv function attempts to save the currently raised floating-point
exceptions in its automatic storage, install the floating-point environment represented by
the object pointed to by envp, and then raise the saved floating-point exceptions. The
argument envp shall point to an object set by a call to feholdexcept or fegetenv,
or equal a floating-point environment macro.
- Returns
+<b> Returns</b>
3 The feupdateenv function returns zero if all the actions were successfully carried out.
Otherwise, it returns a nonzero value.
<a name="7.8.2" href="#7.8.2"><b> 7.8.2 Functions for greatest-width integer types</b></a>
<a name="7.8.2.1" href="#7.8.2.1"><b> 7.8.2.1 The imaxabs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.8"><inttypes.h></a>
intmax_t imaxabs(intmax_t j);
- Description
+<b> Description</b>
2 The imaxabs function computes the absolute value of an integer j. If the result cannot
be represented, the behavior is undefined.218)
- Returns
+<b> Returns</b>
3 The imaxabs function returns the absolute value.
[<a name="p217" href="#p217">page 217</a>] (<a href="#Contents">Contents</a>)
<a name="7.8.2.2" href="#7.8.2.2"><b> 7.8.2.2 The imaxdiv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.8"><inttypes.h></a>
imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
- Description
+<b> Description</b>
2 The imaxdiv function computes numer / denom and numer % denom in a single
operation.
- Returns
+<b> Returns</b>
3 The imaxdiv function returns a structure of type imaxdiv_t comprising both the
quotient and the remainder. The structure shall contain (in either order) the members
quot (the quotient) and rem (the remainder), each of which has type intmax_t. If
either part of the result cannot be represented, the behavior is undefined.
<a name="7.8.2.3" href="#7.8.2.3"><b> 7.8.2.3 The strtoimax and strtoumax functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.8"><inttypes.h></a>
intmax_t strtoimax(const char * restrict nptr,
char ** restrict endptr, int base);
uintmax_t strtoumax(const char * restrict nptr,
char ** restrict endptr, int base);
- Description
+<b> Description</b>
2 The strtoimax and strtoumax functions are equivalent to the strtol, strtoll,
strtoul, and strtoull functions, except that the initial portion of the string is
converted to intmax_t and uintmax_t representation, respectively.
- Returns
+<b> Returns</b>
3 The strtoimax and strtoumax functions return the converted value, if any. If no
conversion could be performed, zero is returned. If the correct value is outside the range
of representable values, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned
[<a name="p218" href="#p218">page 218</a>] (<a href="#Contents">Contents</a>)
<a name="7.8.2.4" href="#7.8.2.4"><b> 7.8.2.4 The wcstoimax and wcstoumax functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.19"><stddef.h></a> // for wchar_t
#include <a href="#7.8"><inttypes.h></a>
intmax_t wcstoimax(const wchar_t * restrict nptr,
wchar_t ** restrict endptr, int base);
uintmax_t wcstoumax(const wchar_t * restrict nptr,
wchar_t ** restrict endptr, int base);
- Description
+<b> Description</b>
2 The wcstoimax and wcstoumax functions are equivalent to the wcstol, wcstoll,
wcstoul, and wcstoull functions except that the initial portion of the wide string is
converted to intmax_t and uintmax_t representation, respectively.
- Returns
+<b> Returns</b>
3 The wcstoimax function returns the converted value, if any. If no conversion could be
performed, zero is returned. If the correct value is outside the range of representable
values, INTMAX_MAX, INTMAX_MIN, or UINTMAX_MAX is returned (according to the
implementation.
<a name="7.11.1" href="#7.11.1"><b> 7.11.1 Locale control</b></a>
<a name="7.11.1.1" href="#7.11.1.1"><b> 7.11.1.1 The setlocale function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.11"><locale.h></a>
char *setlocale(int category, const char *locale);
- Description
+<b> Description</b>
2 The setlocale function selects the appropriate portion of the program's locale as
specified by the category and locale arguments. The setlocale function may be
used to change or query the program's entire current locale or portions thereof. The value
5 A call to the setlocale function may introduce a data race with other calls to the
setlocale function or with calls to functions that are affected by the current locale.
The implementation shall behave as if no library function calls the setlocale function.
- Returns
+<b> Returns</b>
6 If a pointer to a string is given for locale and the selection can be honored, the
setlocale function returns a pointer to the string associated with the specified
category for the new locale. If the selection cannot be honored, the setlocale
strftime function (<a href="#7.26.3.5">7.26.3.5</a>), the strxfrm function (<a href="#7.23.4.5">7.23.4.5</a>).
<a name="7.11.2" href="#7.11.2"><b> 7.11.2 Numeric formatting convention inquiry</b></a>
<a name="7.11.2.1" href="#7.11.2.1"><b> 7.11.2.1 The localeconv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.11"><locale.h></a>
struct lconv *localeconv(void);
- Description
+<b> Description</b>
2 The localeconv function sets the components of an object with type struct lconv
with values appropriate for the formatting of numeric quantities (monetary and otherwise)
according to the rules of the current locale.
7 The implementation shall behave as if no library function calls the localeconv
function.
- Returns
+<b> Returns</b>
8 The localeconv function returns a pointer to the filled-in object. The structure
pointed to by the return value shall not be modified by the program, but may be
overwritten by a subsequent call to the localeconv function. In addition, calls to the
[<a name="p233" href="#p233">page 233</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.2" href="#7.12.2"><b> 7.12.2 The FP_CONTRACT pragma</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
#pragma STDC FP_CONTRACT on-off-switch
- Description
+<b> Description</b>
2 The FP_CONTRACT pragma can be used to allow (if the state is ''on'') or disallow (if the
state is ''off'') the implementation to contract expressions (<a href="#6.5">6.5</a>). Each pragma can occur
either outside external declarations or preceding all explicit declarations and statements
1 In the synopses in this subclause, real-floating indicates that the argument shall be an
expression of real floating type.
<a name="7.12.3.1" href="#7.12.3.1"><b> 7.12.3.1 The fpclassify macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int fpclassify(real-floating x);
- Description
+<b> Description</b>
2 The fpclassify macro classifies its argument value as NaN, infinite, normal,
subnormal, zero, or into another implementation-defined category. First, an argument
represented in a format wider than its semantic type is converted to its semantic type.
Then classification is based on the type of the argument.231)
- Returns
+<b> Returns</b>
3 The fpclassify macro returns the value of the number classification macro
appropriate to the value of its argument. *
[<a name="p234" href="#p234">page 234</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.3.2" href="#7.12.3.2"><b> 7.12.3.2 The isfinite macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isfinite(real-floating x);
- Description
+<b> Description</b>
2 The isfinite macro determines whether its argument has a finite value (zero,
subnormal, or normal, and not infinite or NaN). First, an argument represented in a
format wider than its semantic type is converted to its semantic type. Then determination
is based on the type of the argument.
- Returns
+<b> Returns</b>
3 The isfinite macro returns a nonzero value if and only if its argument has a finite
value.
<a name="7.12.3.3" href="#7.12.3.3"><b> 7.12.3.3 The isinf macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isinf(real-floating x);
- Description
+<b> Description</b>
2 The isinf macro determines whether its argument value is an infinity (positive or
negative). First, an argument represented in a format wider than its semantic type is
converted to its semantic type. Then determination is based on the type of the argument.
- Returns
+<b> Returns</b>
3 The isinf macro returns a nonzero value if and only if its argument has an infinite
value.
<a name="7.12.3.4" href="#7.12.3.4"><b> 7.12.3.4 The isnan macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isnan(real-floating x);
- Description
+<b> Description</b>
2 The isnan macro determines whether its argument value is a NaN. First, an argument
represented in a format wider than its semantic type is converted to its semantic type.
Then determination is based on the type of the argument.232)
[<a name="p235" href="#p235">page 235</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The isnan macro returns a nonzero value if and only if its argument has a NaN value.
<a name="7.12.3.5" href="#7.12.3.5"><b> 7.12.3.5 The isnormal macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isnormal(real-floating x);
- Description
+<b> Description</b>
2 The isnormal macro determines whether its argument value is normal (neither zero,
subnormal, infinite, nor NaN). First, an argument represented in a format wider than its
semantic type is converted to its semantic type. Then determination is based on the type
of the argument.
- Returns
+<b> Returns</b>
3 The isnormal macro returns a nonzero value if and only if its argument has a normal
value.
<a name="7.12.3.6" href="#7.12.3.6"><b> 7.12.3.6 The signbit macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int signbit(real-floating x);
- Description
+<b> Description</b>
2 The signbit macro determines whether the sign of its argument value is negative.233)
- Returns
+<b> Returns</b>
3 The signbit macro returns a nonzero value if and only if the sign of its argument value
is negative.
<a name="7.12.4" href="#7.12.4"><b> 7.12.4 Trigonometric functions</b></a>
<a name="7.12.4.1" href="#7.12.4.1"><b> 7.12.4.1 The acos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double acos(double x);
float acosf(float x);
long double acosl(long double x);
- Description
+<b> Description</b>
2 The acos functions compute the principal value of the arc cosine of x. A domain error
occurs for arguments not in the interval [-1, +1].
- Returns
+<b> Returns</b>
3 The acos functions return arccos x in the interval [0, pi ] radians.
<a name="7.12.4.2" href="#7.12.4.2"><b> 7.12.4.2 The asin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double asin(double x);
float asinf(float x);
long double asinl(long double x);
- Description
+<b> Description</b>
2 The asin functions compute the principal value of the arc sine of x. A domain error
occurs for arguments not in the interval [-1, +1].
- Returns
+<b> Returns</b>
3 The asin functions return arcsin x in the interval [-pi /2, +pi /2] radians.
<a name="7.12.4.3" href="#7.12.4.3"><b> 7.12.4.3 The atan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double atan(double x);
float atanf(float x);
long double atanl(long double x);
- Description
+<b> Description</b>
2 The atan functions compute the principal value of the arc tangent of x.
[<a name="p237" href="#p237">page 237</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The atan functions return arctan x in the interval [-pi /2, +pi /2] radians.
<a name="7.12.4.4" href="#7.12.4.4"><b> 7.12.4.4 The atan2 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double atan2(double y, double x);
float atan2f(float y, float x);
long double atan2l(long double y, long double x);
- Description
+<b> Description</b>
2 The atan2 functions compute the value of the arc tangent of y/x, using the signs of both
arguments to determine the quadrant of the return value. A domain error may occur if
both arguments are zero.
- Returns
+<b> Returns</b>
3 The atan2 functions return arctan y/x in the interval [-pi , +pi ] radians.
<a name="7.12.4.5" href="#7.12.4.5"><b> 7.12.4.5 The cos functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double cos(double x);
float cosf(float x);
long double cosl(long double x);
- Description
+<b> Description</b>
2 The cos functions compute the cosine of x (measured in radians).
- Returns
+<b> Returns</b>
3 The cos functions return cos x.
<a name="7.12.4.6" href="#7.12.4.6"><b> 7.12.4.6 The sin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double sin(double x);
float sinf(float x);
long double sinl(long double x);
- Description
+<b> Description</b>
2 The sin functions compute the sine of x (measured in radians).
[<a name="p238" href="#p238">page 238</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The sin functions return sin x.
<a name="7.12.4.7" href="#7.12.4.7"><b> 7.12.4.7 The tan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double tan(double x);
float tanf(float x);
long double tanl(long double x);
- Description
+<b> Description</b>
2 The tan functions return the tangent of x (measured in radians).
- Returns
+<b> Returns</b>
3 The tan functions return tan x.
<a name="7.12.5" href="#7.12.5"><b> 7.12.5 Hyperbolic functions</b></a>
<a name="7.12.5.1" href="#7.12.5.1"><b> 7.12.5.1 The acosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double acosh(double x);
float acoshf(float x);
long double acoshl(long double x);
- Description
+<b> Description</b>
2 The acosh functions compute the (nonnegative) arc hyperbolic cosine of x. A domain
error occurs for arguments less than 1.
- Returns
+<b> Returns</b>
3 The acosh functions return arcosh x in the interval [0, +(inf)].
<a name="7.12.5.2" href="#7.12.5.2"><b> 7.12.5.2 The asinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double asinh(double x);
float asinhf(float x);
long double asinhl(long double x);
- Description
+<b> Description</b>
2 The asinh functions compute the arc hyperbolic sine of x.
[<a name="p239" href="#p239">page 239</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The asinh functions return arsinh x.
<a name="7.12.5.3" href="#7.12.5.3"><b> 7.12.5.3 The atanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double atanh(double x);
float atanhf(float x);
long double atanhl(long double x);
- Description
+<b> Description</b>
2 The atanh functions compute the arc hyperbolic tangent of x. A domain error occurs
for arguments not in the interval [-1, +1]. A pole error may occur if the argument equals
-1 or +1.
- Returns
+<b> Returns</b>
3 The atanh functions return artanh x.
<a name="7.12.5.4" href="#7.12.5.4"><b> 7.12.5.4 The cosh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double cosh(double x);
float coshf(float x);
long double coshl(long double x);
- Description
+<b> Description</b>
2 The cosh functions compute the hyperbolic cosine of x. A range error occurs if the
magnitude of x is too large.
- Returns
+<b> Returns</b>
3 The cosh functions return cosh x.
<a name="7.12.5.5" href="#7.12.5.5"><b> 7.12.5.5 The sinh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double sinh(double x);
float sinhf(float x);
long double sinhl(long double x);
- Description
+<b> Description</b>
2 The sinh functions compute the hyperbolic sine of x. A range error occurs if the
magnitude of x is too large.
[<a name="p240" href="#p240">page 240</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The sinh functions return sinh x.
<a name="7.12.5.6" href="#7.12.5.6"><b> 7.12.5.6 The tanh functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double tanh(double x);
float tanhf(float x);
long double tanhl(long double x);
- Description
+<b> Description</b>
2 The tanh functions compute the hyperbolic tangent of x.
- Returns
+<b> Returns</b>
3 The tanh functions return tanh x.
<a name="7.12.6" href="#7.12.6"><b> 7.12.6 Exponential and logarithmic functions</b></a>
<a name="7.12.6.1" href="#7.12.6.1"><b> 7.12.6.1 The exp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double exp(double x);
float expf(float x);
long double expl(long double x);
- Description
+<b> Description</b>
2 The exp functions compute the base-e exponential of x. A range error occurs if the
magnitude of x is too large.
- Returns
+<b> Returns</b>
3 The exp functions return ex .
<a name="7.12.6.2" href="#7.12.6.2"><b> 7.12.6.2 The exp2 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double exp2(double x);
float exp2f(float x);
long double exp2l(long double x);
- Description
+<b> Description</b>
2 The exp2 functions compute the base-2 exponential of x. A range error occurs if the
magnitude of x is too large.
[<a name="p241" href="#p241">page 241</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The exp2 functions return 2x .
<a name="7.12.6.3" href="#7.12.6.3"><b> 7.12.6.3 The expm1 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double expm1(double x);
float expm1f(float x);
long double expm1l(long double x);
- Description
+<b> Description</b>
2 The expm1 functions compute the base-e exponential of the argument, minus 1. A range
error occurs if x is too large.234)
- Returns
+<b> Returns</b>
3 The expm1 functions return ex - 1.
<a name="7.12.6.4" href="#7.12.6.4"><b> 7.12.6.4 The frexp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double frexp(double value, int *exp);
float frexpf(float value, int *exp);
long double frexpl(long double value, int *exp);
- Description
+<b> Description</b>
2 The frexp functions break a floating-point number into a normalized fraction and an
integral power of 2. They store the integer in the int object pointed to by exp.
- Returns
+<b> Returns</b>
3 If value is not a floating-point number or if the integral power of 2 is outside the range
of int, the results are unspecified. Otherwise, the frexp functions return the value x,
such that x has a magnitude in the interval [1/2, 1) or zero, and value equals x x 2*exp .
[<a name="p242" href="#p242">page 242</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.6.5" href="#7.12.6.5"><b> 7.12.6.5 The ilogb functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int ilogb(double x);
int ilogbf(float x);
int ilogbl(long double x);
- Description
+<b> Description</b>
2 The ilogb functions extract the exponent of x as a signed int value. If x is zero they
compute the value FP_ILOGB0; if x is infinite they compute the value INT_MAX; if x is
a NaN they compute the value FP_ILOGBNAN; otherwise, they are equivalent to calling
the corresponding logb function and casting the returned value to type int. A domain
error or range error may occur if x is zero, infinite, or NaN. If the correct value is outside
the range of the return type, the numeric result is unspecified.
- Returns
+<b> Returns</b>
3 The ilogb functions return the exponent of x as a signed int value.
Forward references: the logb functions (<a href="#7.12.6.11">7.12.6.11</a>).
<a name="7.12.6.6" href="#7.12.6.6"><b> 7.12.6.6 The ldexp functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double ldexp(double x, int exp);
float ldexpf(float x, int exp);
long double ldexpl(long double x, int exp);
- Description
+<b> Description</b>
2 The ldexp functions multiply a floating-point number by an integral power of 2. A
range error may occur.
- Returns
+<b> Returns</b>
3 The ldexp functions return x x 2exp .
<a name="7.12.6.7" href="#7.12.6.7"><b> 7.12.6.7 The log functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log(double x);
float logf(float x);
[<a name="p243" href="#p243">page 243</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The log functions compute the base-e (natural) logarithm of x. A domain error occurs if
the argument is negative. A pole error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The log functions return loge x.
<a name="7.12.6.8" href="#7.12.6.8"><b> 7.12.6.8 The log10 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log10(double x);
float log10f(float x);
long double log10l(long double x);
- Description
+<b> Description</b>
2 The log10 functions compute the base-10 (common) logarithm of x. A domain error
occurs if the argument is negative. A pole error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The log10 functions return log10 x.
<a name="7.12.6.9" href="#7.12.6.9"><b> 7.12.6.9 The log1p functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log1p(double x);
float log1pf(float x);
long double log1pl(long double x);
- Description
+<b> Description</b>
2 The log1p functions compute the base-e (natural) logarithm of 1 plus the argument.235)
A domain error occurs if the argument is less than -1. A pole error may occur if the
argument equals -1.
- Returns
+<b> Returns</b>
3 The log1p functions return loge (1 + x).
[<a name="p244" href="#p244">page 244</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.6.10" href="#7.12.6.10"><b> 7.12.6.10 The log2 functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double log2(double x);
float log2f(float x);
long double log2l(long double x);
- Description
+<b> Description</b>
2 The log2 functions compute the base-2 logarithm of x. A domain error occurs if the
argument is less than zero. A pole error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The log2 functions return log2 x.
<a name="7.12.6.11" href="#7.12.6.11"><b> 7.12.6.11 The logb functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double logb(double x);
float logbf(float x);
long double logbl(long double x);
- Description
+<b> Description</b>
2 The logb functions extract the exponent of x, as a signed integer value in floating-point
format. If x is subnormal it is treated as though it were normalized; thus, for positive
finite x,
1 <= x x FLT_RADIX-logb(x) < FLT_RADIX
A domain error or pole error may occur if the argument is zero.
- Returns
+<b> Returns</b>
3 The logb functions return the signed exponent of x.
<a name="7.12.6.12" href="#7.12.6.12"><b> 7.12.6.12 The modf functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double modf(double value, double *iptr);
float modff(float value, float *iptr);
long double modfl(long double value, long double *iptr);
- Description
+<b> Description</b>
2 The modf functions break the argument value into integral and fractional parts, each of
which has the same type and sign as the argument. They store the integral part (in
[<a name="p245" href="#p245">page 245</a>] (<a href="#Contents">Contents</a>)
floating-point format) in the object pointed to by iptr.
- Returns
+<b> Returns</b>
3 The modf functions return the signed fractional part of value.
<a name="7.12.6.13" href="#7.12.6.13"><b> 7.12.6.13 The scalbn and scalbln functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double scalbn(double x, int n);
float scalbnf(float x, int n);
double scalbln(double x, long int n);
float scalblnf(float x, long int n);
long double scalblnl(long double x, long int n);
- Description
+<b> Description</b>
2 The scalbn and scalbln functions compute x x FLT_RADIXn efficiently, not
normally by computing FLT_RADIXn explicitly. A range error may occur.
- Returns
+<b> Returns</b>
3 The scalbn and scalbln functions return x x FLT_RADIXn .
<a name="7.12.7" href="#7.12.7"><b> 7.12.7 Power and absolute-value functions</b></a>
<a name="7.12.7.1" href="#7.12.7.1"><b> 7.12.7.1 The cbrt functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double cbrt(double x);
float cbrtf(float x);
long double cbrtl(long double x);
- Description
+<b> Description</b>
2 The cbrt functions compute the real cube root of x.
- Returns
+<b> Returns</b>
3 The cbrt functions return x1/3 .
[<a name="p246" href="#p246">page 246</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.7.2" href="#7.12.7.2"><b> 7.12.7.2 The fabs functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fabs(double x);
float fabsf(float x);
long double fabsl(long double x);
- Description
+<b> Description</b>
2 The fabs functions compute the absolute value of a floating-point number x.
- Returns
+<b> Returns</b>
3 The fabs functions return | x |.
<a name="7.12.7.3" href="#7.12.7.3"><b> 7.12.7.3 The hypot functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double hypot(double x, double y);
float hypotf(float x, float y);
long double hypotl(long double x, long double y);
- Description
+<b> Description</b>
2 The hypot functions compute the square root of the sum of the squares of x and y,
without undue overflow or underflow. A range error may occur.
3 Returns
-
-----
<a name="7.12.7.4" href="#7.12.7.4"><b> 7.12.7.4 The pow functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
- Description
+<b> Description</b>
2 The pow functions compute x raised to the power y. A domain error occurs if x is finite
and negative and y is finite and not an integer value. A range error may occur. A domain
error may occur if x is zero and y is zero. A domain error or pole error may occur if x is
[<a name="p247" href="#p247">page 247</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The pow functions return xy .
<a name="7.12.7.5" href="#7.12.7.5"><b> 7.12.7.5 The sqrt functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double sqrt(double x);
float sqrtf(float x);
long double sqrtl(long double x);
- Description
+<b> Description</b>
2 The sqrt functions compute the nonnegative square root of x. A domain error occurs if
the argument is less than zero.
- Returns
+<b> Returns</b>
3 The sqrt functions return sqrt:x.
-
-
<a name="7.12.8" href="#7.12.8"><b> 7.12.8 Error and gamma functions</b></a>
<a name="7.12.8.1" href="#7.12.8.1"><b> 7.12.8.1 The erf functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double erf(double x);
float erff(float x);
long double erfl(long double x);
- Description
+<b> Description</b>
2 The erf functions compute the error function of x.
- Returns
+<b> Returns</b>
3 2 x
(integral) e-t dt.
2
- 0
<a name="7.12.8.2" href="#7.12.8.2"><b> 7.12.8.2 The erfc functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double erfc(double x);
float erfcf(float x);
long double erfcl(long double x);
- Description
+<b> Description</b>
2 The erfc functions compute the complementary error function of x. A range error
occurs if x is too large.
[<a name="p248" href="#p248">page 248</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 2 (inf)
(integral) e-t dt.
2
- x
<a name="7.12.8.3" href="#7.12.8.3"><b> 7.12.8.3 The lgamma functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double lgamma(double x);
float lgammaf(float x);
long double lgammal(long double x);
- Description
+<b> Description</b>
2 The lgamma functions compute the natural logarithm of the absolute value of gamma of
x. A range error occurs if x is too large. A pole error may occur if x is a negative integer
or zero.
- Returns
+<b> Returns</b>
3 The lgamma functions return loge | (Gamma)(x) |.
<a name="7.12.8.4" href="#7.12.8.4"><b> 7.12.8.4 The tgamma functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double tgamma(double x);
float tgammaf(float x);
long double tgammal(long double x);
- Description
+<b> Description</b>
2 The tgamma functions compute the gamma function of x. A domain error or pole error
may occur if x is a negative integer or zero. A range error occurs if the magnitude of x is
too large and may occur if the magnitude of x is too small.
- Returns
+<b> Returns</b>
3 The tgamma functions return (Gamma)(x).
<a name="7.12.9" href="#7.12.9"><b> 7.12.9 Nearest integer functions</b></a>
<a name="7.12.9.1" href="#7.12.9.1"><b> 7.12.9.1 The ceil functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double ceil(double x);
float ceilf(float x);
long double ceill(long double x);
- Description
+<b> Description</b>
2 The ceil functions compute the smallest integer value not less than x.
- Returns
+<b> Returns</b>
3 The ceil functions return [^x^], expressed as a floating-point number.
<a name="7.12.9.2" href="#7.12.9.2"><b> 7.12.9.2 The floor functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double floor(double x);
float floorf(float x);
long double floorl(long double x);
- Description
+<b> Description</b>
2 The floor functions compute the largest integer value not greater than x.
- Returns
+<b> Returns</b>
3 The floor functions return [_x_], expressed as a floating-point number.
<a name="7.12.9.3" href="#7.12.9.3"><b> 7.12.9.3 The nearbyint functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nearbyint(double x);
float nearbyintf(float x);
long double nearbyintl(long double x);
- Description
+<b> Description</b>
2 The nearbyint functions round their argument to an integer value in floating-point
format, using the current rounding direction and without raising the ''inexact'' floating-
point exception.
[<a name="p250" href="#p250">page 250</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The nearbyint functions return the rounded integer value.
<a name="7.12.9.4" href="#7.12.9.4"><b> 7.12.9.4 The rint functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double rint(double x);
float rintf(float x);
long double rintl(long double x);
- Description
+<b> Description</b>
2 The rint functions differ from the nearbyint functions (<a href="#7.12.9.3">7.12.9.3</a>) only in that the
rint functions may raise the ''inexact'' floating-point exception if the result differs in
value from the argument.
- Returns
+<b> Returns</b>
3 The rint functions return the rounded integer value.
<a name="7.12.9.5" href="#7.12.9.5"><b> 7.12.9.5 The lrint and llrint functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
long int lrint(double x);
long int lrintf(float x);
long long int llrint(double x);
long long int llrintf(float x);
long long int llrintl(long double x);
- Description
+<b> Description</b>
2 The lrint and llrint functions round their argument to the nearest integer value,
rounding according to the current rounding direction. If the rounded value is outside the
range of the return type, the numeric result is unspecified and a domain error or range
error may occur.
- Returns
+<b> Returns</b>
3 The lrint and llrint functions return the rounded integer value.
[<a name="p251" href="#p251">page 251</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.9.6" href="#7.12.9.6"><b> 7.12.9.6 The round functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double round(double x);
float roundf(float x);
long double roundl(long double x);
- Description
+<b> Description</b>
2 The round functions round their argument to the nearest integer value in floating-point
format, rounding halfway cases away from zero, regardless of the current rounding
direction.
- Returns
+<b> Returns</b>
3 The round functions return the rounded integer value.
<a name="7.12.9.7" href="#7.12.9.7"><b> 7.12.9.7 The lround and llround functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
long int lround(double x);
long int lroundf(float x);
long long int llround(double x);
long long int llroundf(float x);
long long int llroundl(long double x);
- Description
+<b> Description</b>
2 The lround and llround functions round their argument to the nearest integer value,
rounding halfway cases away from zero, regardless of the current rounding direction. If
the rounded value is outside the range of the return type, the numeric result is unspecified
and a domain error or range error may occur.
- Returns
+<b> Returns</b>
3 The lround and llround functions return the rounded integer value.
<a name="7.12.9.8" href="#7.12.9.8"><b> 7.12.9.8 The trunc functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double trunc(double x);
float truncf(float x);
[<a name="p252" href="#p252">page 252</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The trunc functions round their argument to the integer value, in floating format,
nearest to but no larger in magnitude than the argument.
- Returns
+<b> Returns</b>
3 The trunc functions return the truncated integer value.
<a name="7.12.10" href="#7.12.10"><b> 7.12.10 Remainder functions</b></a>
<a name="7.12.10.1" href="#7.12.10.1"><b> 7.12.10.1 The fmod functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fmod(double x, double y);
float fmodf(float x, float y);
long double fmodl(long double x, long double y);
- Description
+<b> Description</b>
2 The fmod functions compute the floating-point remainder of x/y.
- Returns
+<b> Returns</b>
3 The fmod functions return the value x - ny, for some integer n such that, if y is nonzero,
the result has the same sign as x and magnitude less than the magnitude of y. If y is zero,
whether a domain error occurs or the fmod functions return zero is implementation-
defined.
<a name="7.12.10.2" href="#7.12.10.2"><b> 7.12.10.2 The remainder functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double remainder(double x, double y);
float remainderf(float x, float y);
long double remainderl(long double x, long double y);
- Description
+<b> Description</b>
2 The remainder functions compute the remainder x REM y required by IEC 60559.236)
[<a name="p253" href="#p253">page 253</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The remainder functions return x REM y. If y is zero, whether a domain error occurs
or the functions return zero is implementation defined.
<a name="7.12.10.3" href="#7.12.10.3"><b> 7.12.10.3 The remquo functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double remquo(double x, double y, int *quo);
float remquof(float x, float y, int *quo);
long double remquol(long double x, long double y,
int *quo);
- Description
+<b> Description</b>
2 The remquo functions compute the same remainder as the remainder functions. In
the object pointed to by quo they store a value whose sign is the sign of x/y and whose
magnitude is congruent modulo 2n to the magnitude of the integral quotient of x/y, where
n is an implementation-defined integer greater than or equal to 3.
- Returns
+<b> Returns</b>
3 The remquo functions return x REM y. If y is zero, the value stored in the object
pointed to by quo is unspecified and whether a domain error occurs or the functions
return zero is implementation defined.
<a name="7.12.11" href="#7.12.11"><b> 7.12.11 Manipulation functions</b></a>
<a name="7.12.11.1" href="#7.12.11.1"><b> 7.12.11.1 The copysign functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double copysign(double x, double y);
float copysignf(float x, float y);
long double copysignl(long double x, long double y);
- Description
+<b> Description</b>
2 The copysign functions produce a value with the magnitude of x and the sign of y.
They produce a NaN (with the sign of y) if x is a NaN. On implementations that
represent a signed zero but do not treat negative zero consistently in arithmetic
operations, the copysign functions regard the sign of zero as positive.
- Returns
+<b> Returns</b>
3 The copysign functions return a value with the magnitude of x and the sign of y.
[<a name="p254" href="#p254">page 254</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.11.2" href="#7.12.11.2"><b> 7.12.11.2 The nan functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nan(const char *tagp);
float nanf(const char *tagp);
long double nanl(const char *tagp);
- Description
+<b> Description</b>
2 The call nan("n-char-sequence") is equivalent to strtod("NAN(n-char-
sequence)", (char**) NULL); the call nan("") is equivalent to
strtod("NAN()", (char**) NULL). If tagp does not point to an n-char
sequence or an empty string, the call is equivalent to strtod("NAN", (char**)
NULL). Calls to nanf and nanl are equivalent to the corresponding calls to strtof
and strtold.
- Returns
+<b> Returns</b>
3 The nan functions return a quiet NaN, if available, with content indicated through tagp.
If the implementation does not support quiet NaNs, the functions return zero.
Forward references: the strtod, strtof, and strtold functions (<a href="#7.22.1.3">7.22.1.3</a>).
<a name="7.12.11.3" href="#7.12.11.3"><b> 7.12.11.3 The nextafter functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nextafter(double x, double y);
float nextafterf(float x, float y);
long double nextafterl(long double x, long double y);
- Description
+<b> Description</b>
2 The nextafter functions determine the next representable value, in the type of the
function, after x in the direction of y, where x and y are first converted to the type of the
function.237) The nextafter functions return y if x equals y. A range error may occur
if the magnitude of x is the largest finite value representable in the type and the result is
infinite or not representable in the type.
- Returns
+<b> Returns</b>
3 The nextafter functions return the next representable value in the specified format
after x in the direction of y.
[<a name="p255" href="#p255">page 255</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.11.4" href="#7.12.11.4"><b> 7.12.11.4 The nexttoward functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double nexttoward(double x, long double y);
float nexttowardf(float x, long double y);
long double nexttowardl(long double x, long double y);
- Description
+<b> Description</b>
2 The nexttoward functions are equivalent to the nextafter functions except that the
second parameter has type long double and the functions return y converted to the
type of the function if x equals y.238)
<a name="7.12.12" href="#7.12.12"><b> 7.12.12 Maximum, minimum, and positive difference functions</b></a>
<a name="7.12.12.1" href="#7.12.12.1"><b> 7.12.12.1 The fdim functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fdim(double x, double y);
float fdimf(float x, float y);
long double fdiml(long double x, long double y);
- Description
+<b> Description</b>
2 The fdim functions determine the positive difference between their arguments:
{x - y if x > y
{
{+0 if x <= y
A range error may occur.
- Returns
+<b> Returns</b>
3 The fdim functions return the positive difference value.
<a name="7.12.12.2" href="#7.12.12.2"><b> 7.12.12.2 The fmax functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fmax(double x, double y);
float fmaxf(float x, float y);
[<a name="p256" href="#p256">page 256</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The fmax functions determine the maximum numeric value of their arguments.239)
- Returns
+<b> Returns</b>
3 The fmax functions return the maximum numeric value of their arguments.
<a name="7.12.12.3" href="#7.12.12.3"><b> 7.12.12.3 The fmin functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fmin(double x, double y);
float fminf(float x, float y);
long double fminl(long double x, long double y);
- Description
+<b> Description</b>
2 The fmin functions determine the minimum numeric value of their arguments.240)
- Returns
+<b> Returns</b>
3 The fmin functions return the minimum numeric value of their arguments.
<a name="7.12.13" href="#7.12.13"><b> 7.12.13 Floating multiply-add</b></a>
<a name="7.12.13.1" href="#7.12.13.1"><b> 7.12.13.1 The fma functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
double fma(double x, double y, double z);
float fmaf(float x, float y, float z);
long double fmal(long double x, long double y,
long double z);
- Description
+<b> Description</b>
2 The fma functions compute (x x y) + z, rounded as one ternary operation: they compute
the value (as if) to infinite precision and round once to the result format, according to the
current rounding mode. A range error may occur.
- Returns
+<b> Returns</b>
3 The fma functions return (x x y) + z, rounded as one ternary operation.
the synopses in this subclause, real-floating indicates that the argument shall be an
expression of real floating type242) (both arguments need not have the same type).243)
<a name="7.12.14.1" href="#7.12.14.1"><b> 7.12.14.1 The isgreater macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isgreater(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isgreater macro determines whether its first argument is greater than its second
argument. The value of isgreater(x, y) is always equal to (x) > (y); however,
unlike (x) > (y), isgreater(x, y) does not raise the ''invalid'' floating-point
exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The isgreater macro returns the value of (x) > (y).
<a name="7.12.14.2" href="#7.12.14.2"><b> 7.12.14.2 The isgreaterequal macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isgreaterequal(real-floating x, real-floating y);
[<a name="p258" href="#p258">page 258</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The isgreaterequal macro determines whether its first argument is greater than or
equal to its second argument. The value of isgreaterequal(x, y) is always equal
to (x) >= (y); however, unlike (x) >= (y), isgreaterequal(x, y) does
not raise the ''invalid'' floating-point exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The isgreaterequal macro returns the value of (x) >= (y).
<a name="7.12.14.3" href="#7.12.14.3"><b> 7.12.14.3 The isless macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isless(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isless macro determines whether its first argument is less than its second
argument. The value of isless(x, y) is always equal to (x) < (y); however,
unlike (x) < (y), isless(x, y) does not raise the ''invalid'' floating-point
exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The isless macro returns the value of (x) < (y).
<a name="7.12.14.4" href="#7.12.14.4"><b> 7.12.14.4 The islessequal macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int islessequal(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The islessequal macro determines whether its first argument is less than or equal to
its second argument. The value of islessequal(x, y) is always equal to
(x) <= (y); however, unlike (x) <= (y), islessequal(x, y) does not raise
the ''invalid'' floating-point exception when x and y are unordered.
- Returns
+<b> Returns</b>
3 The islessequal macro returns the value of (x) <= (y).
[<a name="p259" href="#p259">page 259</a>] (<a href="#Contents">Contents</a>)
<a name="7.12.14.5" href="#7.12.14.5"><b> 7.12.14.5 The islessgreater macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int islessgreater(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The islessgreater macro determines whether its first argument is less than or
greater than its second argument. The islessgreater(x, y) macro is similar to
(x) < (y) || (x) > (y); however, islessgreater(x, y) does not raise
the ''invalid'' floating-point exception when x and y are unordered (nor does it evaluate x
and y twice).
- Returns
+<b> Returns</b>
3 The islessgreater macro returns the value of (x) < (y) || (x) > (y).
<a name="7.12.14.6" href="#7.12.14.6"><b> 7.12.14.6 The isunordered macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.12"><math.h></a>
int isunordered(real-floating x, real-floating y);
- Description
+<b> Description</b>
2 The isunordered macro determines whether its arguments are unordered.
- Returns
+<b> Returns</b>
3 The isunordered macro returns 1 if its arguments are unordered and 0 otherwise.
program defines an external identifier with the name setjmp, the behavior is undefined.
<a name="7.13.1" href="#7.13.1"><b> 7.13.1 Save calling environment</b></a>
<a name="7.13.1.1" href="#7.13.1.1"><b> 7.13.1.1 The setjmp macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.13"><setjmp.h></a>
int setjmp(jmp_buf env);
- Description
+<b> Description</b>
2 The setjmp macro saves its calling environment in its jmp_buf argument for later use
by the longjmp function.
- Returns
+<b> Returns</b>
3 If the return is from a direct invocation, the setjmp macro returns the value zero. If the
return is from a call to the longjmp function, the setjmp macro returns a nonzero
value.
5 If the invocation appears in any other context, the behavior is undefined.
<a name="7.13.2" href="#7.13.2"><b> 7.13.2 Restore calling environment</b></a>
<a name="7.13.2.1" href="#7.13.2.1"><b> 7.13.2.1 The longjmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.13"><setjmp.h></a>
_Noreturn void longjmp(jmp_buf env, int val);
- Description
+<b> Description</b>
2 The longjmp function restores the environment saved by the most recent invocation of
the setjmp macro in the same invocation of the program with the corresponding
jmp_buf argument. If there has been no such invocation, or if the function containing
invocation of the corresponding setjmp macro that do not have volatile-qualified type
and have been changed between the setjmp invocation and longjmp call are
indeterminate.
- Returns
+<b> Returns</b>
4 After longjmp is completed, program execution continues as if the corresponding
invocation of the setjmp macro had just returned the value specified by val. The
longjmp function cannot cause the setjmp macro to return the value 0; if val is 0,
<a name="7.14.1" href="#7.14.1"><b> 7.14.1 Specify signal handling</b></a>
<a name="7.14.1.1" href="#7.14.1.1"><b> 7.14.1.1 The signal function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.14"><signal.h></a>
void (*signal(int sig, void (*func)(int)))(int);
- Description
+<b> Description</b>
2 The signal function chooses one of three ways in which receipt of the signal number
sig is to be subsequently handled. If the value of func is SIG_DFL, default handling
for that signal will occur. If the value of func is SIG_IGN, the signal will be ignored.
signal(sig, SIG_DFL);
is executed for all other signals defined by the implementation.
7 The implementation shall behave as if no library function calls the signal function.
- Returns
+<b> Returns</b>
8 If the request can be honored, the signal function returns the value of func for the
most recent successful call to signal for the specified signal sig. Otherwise, a value of
SIG_ERR is returned and a positive value is stored in errno.
_Exit function (<a href="#7.22.4.5">7.22.4.5</a>), the quick_exit function (<a href="#7.22.4.7">7.22.4.7</a>).
<a name="7.14.2" href="#7.14.2"><b> 7.14.2 Send signal</b></a>
<a name="7.14.2.1" href="#7.14.2.1"><b> 7.14.2.1 The raise function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.14"><signal.h></a>
int raise(int sig);
- Description
+<b> Description</b>
2 The raise function carries out the actions described in <a href="#7.14.1.1">7.14.1.1</a> for the signal sig. If a
signal handler is called, the raise function shall not return until after the signal handler
does.
- Returns
+<b> Returns</b>
3 The raise function returns zero if successful, nonzero if unsuccessful.
shall be matched by a corresponding invocation of the va_end macro in the same
function.
<a name="7.16.1.1" href="#7.16.1.1"><b> 7.16.1.1 The va_arg macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
type va_arg(va_list ap, type);
- Description
+<b> Description</b>
2 The va_arg macro expands to an expression that has the specified type and the value of
the next argument in the call. The parameter ap shall have been initialized by the
va_start or va_copy macro (without an intervening invocation of the va_end
-- one type is a signed integer type, the other type is the corresponding unsigned integer
type, and the value is representable in both types;
-- one type is pointer to void and the other is a pointer to a character type.
- Returns
+<b> Returns</b>
3 The first invocation of the va_arg macro after that of the va_start macro returns the
value of the argument after that specified by parmN . Successive invocations return the
values of the remaining arguments in succession.
<a name="7.16.1.2" href="#7.16.1.2"><b> 7.16.1.2 The va_copy macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
void va_copy(va_list dest, va_list src);
- Description
+<b> Description</b>
2 The va_copy macro initializes dest as a copy of src, as if the va_start macro had
been applied to dest followed by the same sequence of uses of the va_arg macro as
had previously been used to reach the present state of src. Neither the va_copy nor
va_start macro shall be invoked to reinitialize dest without an intervening
invocation of the va_end macro for the same dest.
- Returns
+<b> Returns</b>
3 The va_copy macro returns no value.
<a name="7.16.1.3" href="#7.16.1.3"><b> 7.16.1.3 The va_end macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
void va_end(va_list ap);
- Description
+<b> Description</b>
2 The va_end macro facilitates a normal return from the function whose variable
argument list was referred to by the expansion of the va_start macro, or the function
containing the expansion of the va_copy macro, that initialized the va_list ap. The
by the va_start or va_copy macro). If there is no corresponding invocation of the
va_start or va_copy macro, or if the va_end macro is not invoked before the
return, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The va_end macro returns no value.
<a name="7.16.1.4" href="#7.16.1.4"><b> 7.16.1.4 The va_start macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
void va_start(va_list ap, parmN);
- Description
+<b> Description</b>
2 The va_start macro shall be invoked before any access to the unnamed arguments.
3 The va_start macro initializes ap for subsequent use by the va_arg and va_end
macros. Neither the va_start nor va_copy macro shall be invoked to reinitialize ap
parmN is declared with the register storage class, with a function or array type, or
with a type that is not compatible with the type that results after application of the default
argument promotions, the behavior is undefined.
- Returns
+<b> Returns</b>
5 The va_start macro returns no value.
6 EXAMPLE 1 The function f1 gathers into an array a list of arguments that are pointers to strings (but not
more than MAXARGS arguments), then passes the array as a single argument to function f2. The number of
<a name="7.17.2" href="#7.17.2"><b> 7.17.2 Initialization</b></a>
<a name="7.17.2.1" href="#7.17.2.1"><b> 7.17.2.1 The ATOMIC_VAR_INIT macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
#define ATOMIC_VAR_INIT(C value)
- Description
+<b> Description</b>
2 The ATOMIC_VAR_INIT macro expands to a token sequence suitable for initializing an
atomic object of a type that is initialization-compatible with value. An atomic object
with automatic storage duration that is not explicitly initialized using
atomic_int guide = ATOMIC_VAR_INIT(42);
<a name="7.17.2.2" href="#7.17.2.2"><b> 7.17.2.2 The atomic_init generic function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
void atomic_init(volatile A *obj, C value);
- Description
+<b> Description</b>
2 The atomic_init generic function initializes the atomic object pointed to by obj to
the value value, while also initializing any additional state that the implementation
might need to carry for the atomic object.
3 Although this function initializes an atomic object, it does not avoid data races;
concurrent access to the variable being initialized, even via an atomic operation,
constitutes a data race.
- Returns
+<b> Returns</b>
4 The atomic_init generic function returns no value.
5 EXAMPLE
atomic_int guide;
16 Implementations should make atomic stores visible to atomic loads within a reasonable
amount of time.
<a name="7.17.3.1" href="#7.17.3.1"><b> 7.17.3.1 The kill_dependency macro</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
type kill_dependency(type y);
- Description
+<b> Description</b>
2 The kill_dependency macro terminates a dependency chain; the argument does not
carry a dependency to the return value.
[<a name="p276" href="#p276">page 276</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The kill_dependency macro returns the value of y.
<a name="7.17.4" href="#7.17.4"><b> 7.17.4 Fences</b></a>
1 This subclause introduces synchronization primitives called fences. Fences can have
sequenced before B and reads the value written by A or a value written by any side effect
in the release sequence headed by A.
<a name="7.17.4.1" href="#7.17.4.1"><b> 7.17.4.1 The atomic_thread_fence function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
void atomic_thread_fence(memory_order order);
- Description
+<b> Description</b>
2 Depending on the value of order, this operation:
-- has no effects, if order == memory_order_relaxed;
-- is an acquire fence, if order == memory_order_acquire or order ==
[<a name="p277" href="#p277">page 277</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The atomic_thread_fence function returns no value.
<a name="7.17.4.2" href="#7.17.4.2"><b> 7.17.4.2 The atomic_signal_fence function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
void atomic_signal_fence(memory_order order);
- Description
+<b> Description</b>
2 Equivalent to atomic_thread_fence(order), except that ''synchronizes with''
relationships are established only between a thread and a signal handler executed in the
same thread.
atomic_thread_fence, but the hardware fence instructions that atomic_thread_fence would
have inserted are not emitted.
- Returns
+<b> Returns</b>
5 The atomic_signal_fence function returns no value.
<a name="7.17.5" href="#7.17.5"><b> 7.17.5 Lock-free property</b></a>
1 The atomic lock-free macros indicate the lock-free property of integer and address atomic
process more than once and memory shared between two processes.
<a name="7.17.5.1" href="#7.17.5.1"><b> 7.17.5.1 The atomic_is_lock_free generic function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
_Bool atomic_is_lock_free(atomic_type const volatile *obj);
- Description
+<b> Description</b>
2 The atomic_is_lock_free generic function indicates whether or not the object
pointed to by obj is lock-free. atomic_type can be any atomic type.
- Returns
+<b> Returns</b>
3 The atomic_is_lock_free generic function returns nonzero (true) if and only if the
object's operations are lock-free. The result of a lock-free query on one object cannot be
1 There are only a few kinds of operations on atomic types, though there are many
instances of those kinds. This subclause specifies each general kind.
<a name="7.17.7.1" href="#7.17.7.1"><b> 7.17.7.1 The atomic_store generic functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
void atomic_store(volatile A *object, C desired);
void atomic_store_explicit(volatile A *object,
C desired, memory_order order);
- Description
+<b> Description</b>
2 The order argument shall not be memory_order_acquire,
memory_order_consume, nor memory_order_acq_rel. Atomically replace the
value pointed to by object with the value of desired. Memory is affected according
to the value of order.
- Returns
+<b> Returns</b>
3 The atomic_store generic functions return no value.
<a name="7.17.7.2" href="#7.17.7.2"><b> 7.17.7.2 The atomic_load generic functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
C atomic_load(volatile A *object);
C atomic_load_explicit(volatile A *object,
memory_order order);
- Description
+<b> Description</b>
2 The order argument shall not be memory_order_release nor
memory_order_acq_rel. Memory is affected according to the value of order.
- Returns
+<b> Returns</b>
Atomically returns the value pointed to by object.
[<a name="p281" href="#p281">page 281</a>] (<a href="#Contents">Contents</a>)
<a name="7.17.7.3" href="#7.17.7.3"><b> 7.17.7.3 The atomic_exchange generic functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
C atomic_exchange(volatile A *object, C desired);
C atomic_exchange_explicit(volatile A *object,
C desired, memory_order order);
- Description
+<b> Description</b>
2 Atomically replace the value pointed to by object with desired. Memory is affected
according to the value of order. These operations are read-modify-write operations
(<a href="#5.1.2.4">5.1.2.4</a>).
- Returns
+<b> Returns</b>
3 Atomically returns the value pointed to by object immediately before the effects.
<a name="7.17.7.4" href="#7.17.7.4"><b> 7.17.7.4 The atomic_compare_exchange generic functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
_Bool atomic_compare_exchange_strong(volatile A *object,
C *expected, C desired);
_Bool atomic_compare_exchange_weak_explicit(
volatile A *object, C *expected, C desired,
memory_order success, memory_order failure);
- Description
+<b> Description</b>
2 The failure argument shall not be memory_order_release nor
memory_order_acq_rel. The failure argument shall be no stronger than the
success argument. Atomically, compares the value pointed to by object for equality
platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the
strong one is preferable.
- Returns
+<b> Returns</b>
7 The result of the comparison.
<a name="7.17.7.5" href="#7.17.7.5"><b> 7.17.7.5 The atomic_fetch and modify generic functions</b></a>
1 The following operations perform arithmetic and bitwise computations. All of these
or | bitwise inclusive or
xor ^ bitwise exclusive or
and & bitwise and
- Synopsis
+<b> Synopsis</b>
2 #include <a href="#7.17"><stdatomic.h></a>
C atomic_fetch_key(volatile A *object, M operand);
C atomic_fetch_key_explicit(volatile A *object,
M operand, memory_order order);
- Description
+<b> Description</b>
3 Atomically replaces the value pointed to by object with the result of the computation
applied to the value pointed to by object and the given operand. Memory is affected
according to the value of order. These operations are atomic read-modify-write
complement representation with silent wrap-around on overflow; there are no undefined
results. For address types, the result may be an undefined address, but the operations
otherwise have no undefined behavior.
- Returns
+<b> Returns</b>
4 Atomically, the value pointed to by object immediately before the effects.
5 NOTE The operation of the atomic_fetch and modify generic functions are nearly equivalent to the
operation of the corresponding op= compound assignment operators. The only differences are that the
atomic_flag guard = ATOMIC_FLAG_INIT;
<a name="7.17.8.1" href="#7.17.8.1"><b> 7.17.8.1 The atomic_flag_test_and_set functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
bool atomic_flag_test_and_set(
volatile atomic_flag *object);
bool atomic_flag_test_and_set_explicit(
volatile atomic_flag *object, memory_order order);
- Description
+<b> Description</b>
2 Atomically sets the value pointed to by object to true. Memory is affected according
to the value of order. These operations are atomic read-modify-write operations
(<a href="#5.1.2.4">5.1.2.4</a>).
[<a name="p284" href="#p284">page 284</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 Atomically, the value of the object immediately before the effects.
<a name="7.17.8.2" href="#7.17.8.2"><b> 7.17.8.2 The atomic_flag_clear functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.17"><stdatomic.h></a>
void atomic_flag_clear(volatile atomic_flag *object);
void atomic_flag_clear_explicit(
volatile atomic_flag *object, memory_order order);
- Description
+<b> Description</b>
2 The order argument shall not be memory_order_acquire nor
memory_order_acq_rel. Atomically sets the value pointed to by object to false.
Memory is affected according to the value of order.
- Returns
+<b> Returns</b>
3 The atomic_flag_clear functions return no value.
(<a href="#7.28.6.3.2">7.28.6.3.2</a>), the wcrtomb function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
<a name="7.21.4" href="#7.21.4"><b> 7.21.4 Operations on files</b></a>
<a name="7.21.4.1" href="#7.21.4.1"><b> 7.21.4.1 The remove function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int remove(const char *filename);
- Description
+<b> Description</b>
2 The remove function causes the file whose name is the string pointed to by filename
to be no longer accessible by that name. A subsequent attempt to open that file using that
name will fail, unless it is created anew. If the file is open, the behavior of the remove
function is implementation-defined.
- Returns
+<b> Returns</b>
3 The remove function returns zero if the operation succeeds, nonzero if it fails.
<a name="7.21.4.2" href="#7.21.4.2"><b> 7.21.4.2 The rename function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int rename(const char *old, const char *new);
- Description
+<b> Description</b>
2 The rename function causes the file whose name is the string pointed to by old to be
henceforth known by the name given by the string pointed to by new. The file named
old is no longer accessible by that name. If a file named by the string pointed to by new
[<a name="p302" href="#p302">page 302</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The rename function returns zero if the operation succeeds, nonzero if it fails,262) in
which case if the file existed previously it is still known by its original name.
<a name="7.21.4.3" href="#7.21.4.3"><b> 7.21.4.3 The tmpfile function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
FILE *tmpfile(void);
- Description
+<b> Description</b>
2 The tmpfile function creates a temporary binary file that is different from any other
existing file and that will automatically be removed when it is closed or at program
termination. If the program terminates abnormally, whether an open temporary file is
program (this limit may be shared with tmpnam) and there should be no limit on the
number simultaneously open other than this limit and any limit on the number of open
files (FOPEN_MAX).
- Returns
+<b> Returns</b>
4 The tmpfile function returns a pointer to the stream of the file that it created. If the file
cannot be created, the tmpfile function returns a null pointer.
Forward references: the fopen function (<a href="#7.21.5.3">7.21.5.3</a>).
<a name="7.21.4.4" href="#7.21.4.4"><b> 7.21.4.4 The tmpnam function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
char *tmpnam(char *s);
- Description
+<b> Description</b>
2 The tmpnam function generates a string that is a valid file name and that is not the same
as the name of an existing file.263) The function is potentially capable of generating at
4 Calls to the tmpnam function with a null pointer argument may introduce data races with
each other. The implementation shall behave as if no library function calls the tmpnam
function.
- Returns
+<b> Returns</b>
5 If no suitable string can be generated, the tmpnam function returns a null pointer.
Otherwise, if the argument is a null pointer, the tmpnam function leaves its result in an
internal static object and returns a pointer to that object (subsequent calls to the tmpnam
6 The value of the macro TMP_MAX shall be at least 25.
<a name="7.21.5" href="#7.21.5"><b> 7.21.5 File access functions</b></a>
<a name="7.21.5.1" href="#7.21.5.1"><b> 7.21.5.1 The fclose function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fclose(FILE *stream);
- Description
+<b> Description</b>
2 A successful call to the fclose function causes the stream pointed to by stream to be
flushed and the associated file to be closed. Any unwritten buffered data for the stream
are delivered to the host environment to be written to the file; any unread buffered data
are discarded. Whether or not the call succeeds, the stream is disassociated from the file
and any buffer set by the setbuf or setvbuf function is disassociated from the stream
(and deallocated if it was automatically allocated).
- Returns
+<b> Returns</b>
3 The fclose function returns zero if the stream was successfully closed, or EOF if any
errors were detected.
[<a name="p304" href="#p304">page 304</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.5.2" href="#7.21.5.2"><b> 7.21.5.2 The fflush function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fflush(FILE *stream);
- Description
+<b> Description</b>
2 If stream points to an output stream or an update stream in which the most recent
operation was not input, the fflush function causes any unwritten data for that stream
to be delivered to the host environment to be written to the file; otherwise, the behavior is
undefined.
3 If stream is a null pointer, the fflush function performs this flushing action on all
streams for which the behavior is defined above.
- Returns
+<b> Returns</b>
4 The fflush function sets the error indicator for the stream and returns EOF if a write
error occurs, otherwise it returns zero.
Forward references: the fopen function (<a href="#7.21.5.3">7.21.5.3</a>).
<a name="7.21.5.3" href="#7.21.5.3"><b> 7.21.5.3 The fopen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
FILE *fopen(const char * restrict filename,
const char * restrict mode);
- Description
+<b> Description</b>
2 The fopen function opens the file whose name is the string pointed to by filename,
and associates a stream with it.
3 The argument mode points to a string. If the string is one of the following, the file is
binary stream in some implementations.
8 When opened, a stream is fully buffered if and only if it can be determined not to refer to
an interactive device. The error and end-of-file indicators for the stream are cleared.
- Returns
+<b> Returns</b>
9 The fopen function returns a pointer to the object controlling the stream. If the open
operation fails, fopen returns a null pointer.
Forward references: file positioning functions (<a href="#7.21.9">7.21.9</a>).
[<a name="p306" href="#p306">page 306</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.5.4" href="#7.21.5.4"><b> 7.21.5.4 The freopen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
FILE *freopen(const char * restrict filename,
const char * restrict mode,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The freopen function opens the file whose name is the string pointed to by filename
and associates the stream pointed to by stream with it. The mode argument is used just
as in the fopen function.265)
4 The freopen function first attempts to close any file that is associated with the specified
stream. Failure to close the file is ignored. The error and end-of-file indicators for the
stream are cleared.
- Returns
+<b> Returns</b>
5 The freopen function returns a null pointer if the open operation fails. Otherwise,
freopen returns the value of stream.
<a name="7.21.5.5" href="#7.21.5.5"><b> 7.21.5.5 The setbuf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
void setbuf(FILE * restrict stream,
char * restrict buf);
- Description
+<b> Description</b>
2 Except that it returns no value, the setbuf function is equivalent to the setvbuf
function invoked with the values _IOFBF for mode and BUFSIZ for size, or (if buf
is a null pointer), with the value _IONBF for mode.
[<a name="p307" href="#p307">page 307</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The setbuf function returns no value.
Forward references: the setvbuf function (<a href="#7.21.5.6">7.21.5.6</a>).
<a name="7.21.5.6" href="#7.21.5.6"><b> 7.21.5.6 The setvbuf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int setvbuf(FILE * restrict stream,
char * restrict buf,
int mode, size_t size);
- Description
+<b> Description</b>
2 The setvbuf function may be used only after the stream pointed to by stream has
been associated with an open file and before any other operation (other than an
unsuccessful call to setvbuf) is performed on the stream. The argument mode
specifies the size of the array; otherwise, size may determine the size of a buffer
allocated by the setvbuf function. The contents of the array at any time are
indeterminate.
- Returns
+<b> Returns</b>
3 The setvbuf function returns zero on success, or nonzero if an invalid value is given
for mode or if the request cannot be honored.
1 The formatted input/output functions shall behave as if there is a sequence point after the
actions associated with each specifier.267)
<a name="7.21.6.1" href="#7.21.6.1"><b> 7.21.6.1 The fprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fprintf(FILE * restrict stream,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The fprintf function writes output to the stream pointed to by stream, under control
of the string pointed to by format that specifies how subsequent arguments are
converted for output. If there are insufficient arguments for the format, the behavior is
of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that
the error should have a correct sign for the current rounding direction.
- Returns
+<b> Returns</b>
14 The fprintf function returns the number of characters transmitted, or a negative value
if an output or encoding error occurred.
Environmental limits
[<a name="p316" href="#p316">page 316</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.6.2" href="#7.21.6.2"><b> 7.21.6.2 The fscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fscanf(FILE * restrict stream,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The fscanf function reads input from the stream pointed to by stream, under control
of the string pointed to by format that specifies the admissible input sequences and how
they are to be converted for assignment, using subsequent arguments as pointers to the
15 Trailing white space (including new-line characters) is left unread unless matched by a
directive. The success of literal matches and suppressed assignments is not directly
determinable other than via the %n directive.
- Returns
+<b> Returns</b>
16 The fscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the function returns the
number of input items assigned, which can be fewer than provided for, or even zero, in
strtol, strtoll, strtoul, and strtoull functions (<a href="#7.22.1.4">7.22.1.4</a>), conversion state
(<a href="#7.28.6">7.28.6</a>), the wcrtomb function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
<a name="7.21.6.3" href="#7.21.6.3"><b> 7.21.6.3 The printf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int printf(const char * restrict format, ...);
- Description
+<b> Description</b>
2 The printf function is equivalent to fprintf with the argument stdout interposed
before the arguments to printf.
- Returns
+<b> Returns</b>
3 The printf function returns the number of characters transmitted, or a negative value if
an output or encoding error occurred.
<a name="7.21.6.4" href="#7.21.6.4"><b> 7.21.6.4 The scanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int scanf(const char * restrict format, ...);
- Description
+<b> Description</b>
2 The scanf function is equivalent to fscanf with the argument stdin interposed
before the arguments to scanf.
[<a name="p324" href="#p324">page 324</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The scanf function returns the value of the macro EOF if an input failure occurs before
the first conversion (if any) has completed. Otherwise, the scanf function returns the
number of input items assigned, which can be fewer than provided for, or even zero, in
the event of an early matching failure.
<a name="7.21.6.5" href="#7.21.6.5"><b> 7.21.6.5 The snprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int snprintf(char * restrict s, size_t n,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The snprintf function is equivalent to fprintf, except that the output is written into
an array (specified by argument s) rather than to a stream. If n is zero, nothing is written,
and s may be a null pointer. Otherwise, output characters beyond the n-1st are
discarded rather than being written to the array, and a null character is written at the end
of the characters actually written into the array. If copying takes place between objects
that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The snprintf function returns the number of characters that would have been written
had n been sufficiently large, not counting the terminating null character, or a negative
value if an encoding error occurred. Thus, the null-terminated output has been
completely written if and only if the returned value is nonnegative and less than n.
<a name="7.21.6.6" href="#7.21.6.6"><b> 7.21.6.6 The sprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int sprintf(char * restrict s,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The sprintf function is equivalent to fprintf, except that the output is written into
an array (specified by the argument s) rather than to a stream. A null character is written
at the end of the characters written; it is not counted as part of the returned value. If
copying takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The sprintf function returns the number of characters written in the array, not
counting the terminating null character, or a negative value if an encoding error occurred.
[<a name="p325" href="#p325">page 325</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.6.7" href="#7.21.6.7"><b> 7.21.6.7 The sscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int sscanf(const char * restrict s,
const char * restrict format, ...);
- Description
+<b> Description</b>
2 The sscanf function is equivalent to fscanf, except that input is obtained from a
string (specified by the argument s) rather than from a stream. Reaching the end of the
string is equivalent to encountering end-of-file for the fscanf function. If copying
takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The sscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the sscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.21.6.8" href="#7.21.6.8"><b> 7.21.6.8 The vfprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vfprintf(FILE * restrict stream,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfprintf function is equivalent to fprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfprintf function does not invoke the
va_end macro.281)
- Returns
+<b> Returns</b>
3 The vfprintf function returns the number of characters transmitted, or a negative
value if an output or encoding error occurred.
4 EXAMPLE The following shows the use of the vfprintf function in a general error-reporting routine.
}
<a name="7.21.6.9" href="#7.21.6.9"><b> 7.21.6.9 The vfscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vfscanf(FILE * restrict stream,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfscanf function is equivalent to fscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfscanf function does not invoke the
va_end macro.281)
- Returns
+<b> Returns</b>
3 The vfscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the vfscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.21.6.10" href="#7.21.6.10"><b> 7.21.6.10 The vprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vprintf(const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vprintf function is equivalent to printf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vprintf function does not invoke the
va_end macro.281)
- Returns
+<b> Returns</b>
3 The vprintf function returns the number of characters transmitted, or a negative value
if an output or encoding error occurred.
<a name="7.21.6.11" href="#7.21.6.11"><b> 7.21.6.11 The vscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vscanf(const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vscanf function is equivalent to scanf, with the variable argument list replaced
by arg, which shall have been initialized by the va_start macro (and possibly
subsequent va_arg calls). The vscanf function does not invoke the va_end
macro.281)
- Returns
+<b> Returns</b>
3 The vscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the vscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.21.6.12" href="#7.21.6.12"><b> 7.21.6.12 The vsnprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vsnprintf(char * restrict s, size_t n,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vsnprintf function is equivalent to snprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsnprintf function does not invoke the
[<a name="p328" href="#p328">page 328</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The vsnprintf function returns the number of characters that would have been written
had n been sufficiently large, not counting the terminating null character, or a negative
value if an encoding error occurred. Thus, the null-terminated output has been
completely written if and only if the returned value is nonnegative and less than n.
<a name="7.21.6.13" href="#7.21.6.13"><b> 7.21.6.13 The vsprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vsprintf(char * restrict s,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vsprintf function is equivalent to sprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsprintf function does not invoke the
va_end macro.281) If copying takes place between objects that overlap, the behavior is
undefined.
- Returns
+<b> Returns</b>
3 The vsprintf function returns the number of characters written in the array, not
counting the terminating null character, or a negative value if an encoding error occurred.
<a name="7.21.6.14" href="#7.21.6.14"><b> 7.21.6.14 The vsscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
int vsscanf(const char * restrict s,
const char * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vsscanf function is equivalent to sscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsscanf function does not invoke the
va_end macro.281)
- Returns
+<b> Returns</b>
3 The vsscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the vsscanf function
[<a name="p329" href="#p329">page 329</a>] (<a href="#Contents">Contents</a>)
zero, in the event of an early matching failure.
<a name="7.21.7" href="#7.21.7"><b> 7.21.7 Character input/output functions</b></a>
<a name="7.21.7.1" href="#7.21.7.1"><b> 7.21.7.1 The fgetc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fgetc(FILE *stream);
- Description
+<b> Description</b>
2 If the end-of-file indicator for the input stream pointed to by stream is not set and a
next character is present, the fgetc function obtains that character as an unsigned
char converted to an int and advances the associated file position indicator for the
stream (if defined).
- Returns
+<b> Returns</b>
3 If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
of-file indicator for the stream is set and the fgetc function returns EOF. Otherwise, the
fgetc function returns the next character from the input stream pointed to by stream.
If a read error occurs, the error indicator for the stream is set and the fgetc function
returns EOF.282)
<a name="7.21.7.2" href="#7.21.7.2"><b> 7.21.7.2 The fgets function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
char *fgets(char * restrict s, int n,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fgets function reads at most one less than the number of characters specified by n
from the stream pointed to by stream into the array pointed to by s. No additional
characters are read after a new-line character (which is retained) or after end-of-file. A
null character is written immediately after the last character read into the array.
- Returns
+<b> Returns</b>
3 The fgets function returns s if successful. If end-of-file is encountered and no
characters have been read into the array, the contents of the array remain unchanged and a
null pointer is returned. If a read error occurs during the operation, the array contents are
[<a name="p330" href="#p330">page 330</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.7.3" href="#7.21.7.3"><b> 7.21.7.3 The fputc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fputc(int c, FILE *stream);
- Description
+<b> Description</b>
2 The fputc function writes the character specified by c (converted to an unsigned
char) to the output stream pointed to by stream, at the position indicated by the
associated file position indicator for the stream (if defined), and advances the indicator
appropriately. If the file cannot support positioning requests, or if the stream was opened
with append mode, the character is appended to the output stream.
- Returns
+<b> Returns</b>
3 The fputc function returns the character written. If a write error occurs, the error
indicator for the stream is set and fputc returns EOF.
<a name="7.21.7.4" href="#7.21.7.4"><b> 7.21.7.4 The fputs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fputs(const char * restrict s,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fputs function writes the string pointed to by s to the stream pointed to by
stream. The terminating null character is not written.
- Returns
+<b> Returns</b>
3 The fputs function returns EOF if a write error occurs; otherwise it returns a
nonnegative value.
<a name="7.21.7.5" href="#7.21.7.5"><b> 7.21.7.5 The getc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int getc(FILE *stream);
- Description
+<b> Description</b>
2 The getc function is equivalent to fgetc, except that if it is implemented as a macro, it
may evaluate stream more than once, so the argument should never be an expression
with side effects.
[<a name="p331" href="#p331">page 331</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The getc function returns the next character from the input stream pointed to by
stream. If the stream is at end-of-file, the end-of-file indicator for the stream is set and
getc returns EOF. If a read error occurs, the error indicator for the stream is set and
getc returns EOF.
<a name="7.21.7.6" href="#7.21.7.6"><b> 7.21.7.6 The getchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int getchar(void);
- Description
+<b> Description</b>
2 The getchar function is equivalent to getc with the argument stdin.
- Returns
+<b> Returns</b>
3 The getchar function returns the next character from the input stream pointed to by
stdin. If the stream is at end-of-file, the end-of-file indicator for the stream is set and
getchar returns EOF. If a read error occurs, the error indicator for the stream is set and
getchar returns EOF. *
<a name="7.21.7.7" href="#7.21.7.7"><b> 7.21.7.7 The putc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int putc(int c, FILE *stream);
- Description
+<b> Description</b>
2 The putc function is equivalent to fputc, except that if it is implemented as a macro, it
may evaluate stream more than once, so that argument should never be an expression
with side effects.
- Returns
+<b> Returns</b>
3 The putc function returns the character written. If a write error occurs, the error
indicator for the stream is set and putc returns EOF.
<a name="7.21.7.8" href="#7.21.7.8"><b> 7.21.7.8 The putchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int putchar(int c);
- Description
+<b> Description</b>
2 The putchar function is equivalent to putc with the second argument stdout.
[<a name="p332" href="#p332">page 332</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The putchar function returns the character written. If a write error occurs, the error
indicator for the stream is set and putchar returns EOF.
<a name="7.21.7.9" href="#7.21.7.9"><b> 7.21.7.9 The puts function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int puts(const char *s);
- Description
+<b> Description</b>
2 The puts function writes the string pointed to by s to the stream pointed to by stdout,
and appends a new-line character to the output. The terminating null character is not
written.
- Returns
+<b> Returns</b>
3 The puts function returns EOF if a write error occurs; otherwise it returns a nonnegative
value.
<a name="7.21.7.10" href="#7.21.7.10"><b> 7.21.7.10 The ungetc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int ungetc(int c, FILE *stream);
- Description
+<b> Description</b>
2 The ungetc function pushes the character specified by c (converted to an unsigned
char) back onto the input stream pointed to by stream. Pushed-back characters will be
returned by subsequent reads on that stream in the reverse order of their pushing. A
For a binary stream, its file position indicator is decremented by each successful call to
the ungetc function; if its value was zero before a call, it is indeterminate after the
call.283)
- Returns
+<b> Returns</b>
6 The ungetc function returns the character pushed back after conversion, or EOF if the
operation fails.
Forward references: file positioning functions (<a href="#7.21.9">7.21.9</a>).
<a name="7.21.8" href="#7.21.8"><b> 7.21.8 Direct input/output functions</b></a>
<a name="7.21.8.1" href="#7.21.8.1"><b> 7.21.8.1 The fread function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
size_t fread(void * restrict ptr,
size_t size, size_t nmemb,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fread function reads, into the array pointed to by ptr, up to nmemb elements
whose size is specified by size, from the stream pointed to by stream. For each
object, size calls are made to the fgetc function and the results stored, in the order
indicator for the stream (if defined) is advanced by the number of characters successfully
read. If an error occurs, the resulting value of the file position indicator for the stream is
indeterminate. If a partial element is read, its value is indeterminate.
- Returns
+<b> Returns</b>
3 The fread function returns the number of elements successfully read, which may be
less than nmemb if a read error or end-of-file is encountered. If size or nmemb is zero,
fread returns zero and the contents of the array and the state of the stream remain
[<a name="p334" href="#p334">page 334</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.8.2" href="#7.21.8.2"><b> 7.21.8.2 The fwrite function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
size_t fwrite(const void * restrict ptr,
size_t size, size_t nmemb,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fwrite function writes, from the array pointed to by ptr, up to nmemb elements
whose size is specified by size, to the stream pointed to by stream. For each object,
size calls are made to the fputc function, taking the values (in order) from an array of
stream (if defined) is advanced by the number of characters successfully written. If an
error occurs, the resulting value of the file position indicator for the stream is
indeterminate.
- Returns
+<b> Returns</b>
3 The fwrite function returns the number of elements successfully written, which will be
less than nmemb only if a write error is encountered. If size or nmemb is zero,
fwrite returns zero and the state of the stream remains unchanged.
<a name="7.21.9" href="#7.21.9"><b> 7.21.9 File positioning functions</b></a>
<a name="7.21.9.1" href="#7.21.9.1"><b> 7.21.9.1 The fgetpos function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fgetpos(FILE * restrict stream,
fpos_t * restrict pos);
- Description
+<b> Description</b>
2 The fgetpos function stores the current values of the parse state (if any) and file
position indicator for the stream pointed to by stream in the object pointed to by pos.
The values stored contain unspecified information usable by the fsetpos function for
repositioning the stream to its position at the time of the call to the fgetpos function.
- Returns
+<b> Returns</b>
3 If successful, the fgetpos function returns zero; on failure, the fgetpos function
returns nonzero and stores an implementation-defined positive value in errno.
Forward references: the fsetpos function (<a href="#7.21.9.3">7.21.9.3</a>).
[<a name="p335" href="#p335">page 335</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.9.2" href="#7.21.9.2"><b> 7.21.9.2 The fseek function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fseek(FILE *stream, long int offset, int whence);
- Description
+<b> Description</b>
2 The fseek function sets the file position indicator for the stream pointed to by stream.
If a read or write error occurs, the error indicator for the stream is set and fseek fails.
3 For a binary stream, the new position, measured in characters from the beginning of the
effects of the ungetc function on the stream, clears the end-of-file indicator for the
stream, and then establishes the new position. After a successful fseek call, the next
operation on an update stream may be either input or output.
- Returns
+<b> Returns</b>
6 The fseek function returns nonzero only for a request that cannot be satisfied.
Forward references: the ftell function (<a href="#7.21.9.4">7.21.9.4</a>).
<a name="7.21.9.3" href="#7.21.9.3"><b> 7.21.9.3 The fsetpos function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int fsetpos(FILE *stream, const fpos_t *pos);
- Description
+<b> Description</b>
2 The fsetpos function sets the mbstate_t object (if any) and file position indicator
for the stream pointed to by stream according to the value of the object pointed to by
pos, which shall be a value obtained from an earlier successful call to the fgetpos
[<a name="p336" href="#p336">page 336</a>] (<a href="#Contents">Contents</a>)
update stream may be either input or output.
- Returns
+<b> Returns</b>
4 If successful, the fsetpos function returns zero; on failure, the fsetpos function
returns nonzero and stores an implementation-defined positive value in errno.
<a name="7.21.9.4" href="#7.21.9.4"><b> 7.21.9.4 The ftell function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
long int ftell(FILE *stream);
- Description
+<b> Description</b>
2 The ftell function obtains the current value of the file position indicator for the stream
pointed to by stream. For a binary stream, the value is the number of characters from
the beginning of the file. For a text stream, its file position indicator contains unspecified
stream to its position at the time of the ftell call; the difference between two such
return values is not necessarily a meaningful measure of the number of characters written
or read.
- Returns
+<b> Returns</b>
3 If successful, the ftell function returns the current value of the file position indicator
for the stream. On failure, the ftell function returns -1L and stores an
implementation-defined positive value in errno.
<a name="7.21.9.5" href="#7.21.9.5"><b> 7.21.9.5 The rewind function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
void rewind(FILE *stream);
- Description
+<b> Description</b>
2 The rewind function sets the file position indicator for the stream pointed to by
stream to the beginning of the file. It is equivalent to
(void)fseek(stream, 0L, SEEK_SET)
except that the error indicator for the stream is also cleared.
- Returns
+<b> Returns</b>
3 The rewind function returns no value.
<a name="7.21.10" href="#7.21.10"><b> 7.21.10 Error-handling functions</b></a>
<a name="7.21.10.1" href="#7.21.10.1"><b> 7.21.10.1 The clearerr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
void clearerr(FILE *stream);
- Description
+<b> Description</b>
2 The clearerr function clears the end-of-file and error indicators for the stream pointed
to by stream.
- Returns
+<b> Returns</b>
3 The clearerr function returns no value.
<a name="7.21.10.2" href="#7.21.10.2"><b> 7.21.10.2 The feof function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int feof(FILE *stream);
- Description
+<b> Description</b>
2 The feof function tests the end-of-file indicator for the stream pointed to by stream.
- Returns
+<b> Returns</b>
3 The feof function returns nonzero if and only if the end-of-file indicator is set for
stream.
<a name="7.21.10.3" href="#7.21.10.3"><b> 7.21.10.3 The ferror function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
int ferror(FILE *stream);
- Description
+<b> Description</b>
2 The ferror function tests the error indicator for the stream pointed to by stream.
- Returns
+<b> Returns</b>
3 The ferror function returns nonzero if and only if the error indicator is set for
stream.
[<a name="p338" href="#p338">page 338</a>] (<a href="#Contents">Contents</a>)
<a name="7.21.10.4" href="#7.21.10.4"><b> 7.21.10.4 The perror function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
void perror(const char *s);
- Description
+<b> Description</b>
2 The perror function maps the error number in the integer expression errno to an
error message. It writes a sequence of characters to the standard error stream thus: first
(if s is not a null pointer and the character pointed to by s is not the null character), the
string pointed to by s followed by a colon (:) and a space; then an appropriate error
message string followed by a new-line character. The contents of the error message
strings are the same as those returned by the strerror function with argument errno.
- Returns
+<b> Returns</b>
3 The perror function returns no value.
Forward references: the strerror function (<a href="#7.23.6.2">7.23.6.2</a>).
expression errno on an error. If the value of the result cannot be represented, the
behavior is undefined.
<a name="7.22.1.1" href="#7.22.1.1"><b> 7.22.1.1 The atof function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
double atof(const char *nptr);
- Description
+<b> Description</b>
2 The atof function converts the initial portion of the string pointed to by nptr to
double representation. Except for the behavior on error, it is equivalent to
strtod(nptr, (char **)NULL)
- Returns
+<b> Returns</b>
3 The atof function returns the converted value.
Forward references: the strtod, strtof, and strtold functions (<a href="#7.22.1.3">7.22.1.3</a>).
<a name="7.22.1.2" href="#7.22.1.2"><b> 7.22.1.2 The atoi, atol, and atoll functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int atoi(const char *nptr);
long int atol(const char *nptr);
long long int atoll(const char *nptr);
- Description
+<b> Description</b>
2 The atoi, atol, and atoll functions convert the initial portion of the string pointed
to by nptr to int, long int, and long long int representation, respectively.
Except for the behavior on error, they are equivalent to
atoi: (int)strtol(nptr, (char **)NULL, 10)
atol: strtol(nptr, (char **)NULL, 10)
atoll: strtoll(nptr, (char **)NULL, 10)
- Returns
+<b> Returns</b>
3 The atoi, atol, and atoll functions return the converted value.
Forward references: the strtol, strtoll, strtoul, and strtoull functions
(<a href="#7.22.1.4">7.22.1.4</a>).
[<a name="p341" href="#p341">page 341</a>] (<a href="#Contents">Contents</a>)
<a name="7.22.1.3" href="#7.22.1.3"><b> 7.22.1.3 The strtod, strtof, and strtold functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
double strtod(const char * restrict nptr,
char ** restrict endptr);
char ** restrict endptr);
long double strtold(const char * restrict nptr,
char ** restrict endptr);
- Description
+<b> Description</b>
2 The strtod, strtof, and strtold functions convert the initial portion of the string
pointed to by nptr to double, float, and long double representation,
respectively. First, they decompose the input string into three parts: an initial, possibly
stipulation that the error with respect to D should have a correct sign for the current
rounding direction.287)
- Returns
+<b> Returns</b>
10 The functions return the converted value, if any. If no conversion could be performed,
zero is returned. If the correct value overflows and default rounding is in effect (<a href="#7.12.1">7.12.1</a>),
plus or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the
no greater than the smallest normalized positive number in the return type; whether
errno acquires the value ERANGE is implementation-defined.
<a name="7.22.1.4" href="#7.22.1.4"><b> 7.22.1.4 The strtol, strtoll, strtoul, and strtoull functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
long int strtol(
const char * restrict nptr,
const char * restrict nptr,
char ** restrict endptr,
int base);
- Description
+<b> Description</b>
2 The strtol, strtoll, strtoul, and strtoull functions convert the initial
portion of the string pointed to by nptr to long int, long long int, unsigned
long int, and unsigned long long int representation, respectively. First,
7 If the subject sequence is empty or does not have the expected form, no conversion is
performed; the value of nptr is stored in the object pointed to by endptr, provided
that endptr is not a null pointer.
- Returns
+<b> Returns</b>
8 The strtol, strtoll, strtoul, and strtoull functions return the converted
value, if any. If no conversion could be performed, zero is returned. If the correct value
is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,
<a name="7.22.2" href="#7.22.2"><b> 7.22.2 Pseudo-random sequence generation functions</b></a>
<a name="7.22.2.1" href="#7.22.2.1"><b> 7.22.2.1 The rand function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int rand(void);
- Description
+<b> Description</b>
2 The rand function computes a sequence of pseudo-random integers in the range 0 to
RAND_MAX.288)
3 The rand function is not required to avoid data races. The implementation shall behave
as if no library function calls the rand function.
- Returns
+<b> Returns</b>
4 The rand function returns a pseudo-random integer.
Environmental limits
5 The value of the RAND_MAX macro shall be at least 32767.
<a name="7.22.2.2" href="#7.22.2.2"><b> 7.22.2.2 The srand function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void srand(unsigned int seed);
- Description
+<b> Description</b>
2 The srand function uses the argument as a seed for a new sequence of pseudo-random
numbers to be returned by subsequent calls to rand. If srand is then called with the
same seed value, the sequence of pseudo-random numbers shall be repeated. If rand is
called before any calls to srand have been made, the same sequence shall be generated
as when srand is first called with a seed value of 1.
3 The implementation shall behave as if no library function calls the srand function.
- Returns
+<b> Returns</b>
4 The srand function returns no value.
is returned, or the behavior is as if the size were some nonzero value, except that the
returned pointer shall not be used to access an object.
<a name="7.22.3.1" href="#7.22.3.1"><b> 7.22.3.1 The aligned_alloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void *aligned_alloc(size_t alignment, size_t size);
- Description
+<b> Description</b>
2 The aligned_alloc function allocates space for an object whose alignment is
specified by alignment, whose size is specified by size, and whose value is
indeterminate. The value of alignment shall be a valid alignment supported by the
implementation and the value of size shall be an integral multiple of alignment.
- Returns
+<b> Returns</b>
3 The aligned_alloc function returns either a null pointer or a pointer to the allocated
space.
[<a name="p347" href="#p347">page 347</a>] (<a href="#Contents">Contents</a>)
<a name="7.22.3.2" href="#7.22.3.2"><b> 7.22.3.2 The calloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void *calloc(size_t nmemb, size_t size);
- Description
+<b> Description</b>
2 The calloc function allocates space for an array of nmemb objects, each of whose size
is size. The space is initialized to all bits zero.289)
- Returns
+<b> Returns</b>
3 The calloc function returns either a null pointer or a pointer to the allocated space.
<a name="7.22.3.3" href="#7.22.3.3"><b> 7.22.3.3 The free function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void free(void *ptr);
- Description
+<b> Description</b>
2 The free function causes the space pointed to by ptr to be deallocated, that is, made
available for further allocation. If ptr is a null pointer, no action occurs. Otherwise, if
the argument does not match a pointer earlier returned by a memory management
function, or if the space has been deallocated by a call to free or realloc, the
behavior is undefined.
- Returns
+<b> Returns</b>
3 The free function returns no value.
<a name="7.22.3.4" href="#7.22.3.4"><b> 7.22.3.4 The malloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void *malloc(size_t size);
- Description
+<b> Description</b>
2 The malloc function allocates space for an object whose size is specified by size and
whose value is indeterminate.
[<a name="p348" href="#p348">page 348</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The malloc function returns either a null pointer or a pointer to the allocated space.
<a name="7.22.3.5" href="#7.22.3.5"><b> 7.22.3.5 The realloc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void *realloc(void *ptr, size_t size);
- Description
+<b> Description</b>
2 The realloc function deallocates the old object pointed to by ptr and returns a
pointer to a new object that has the size specified by size. The contents of the new
object shall be the same as that of the old object prior to deallocation, up to the lesser of
management function, or if the space has been deallocated by a call to the free or
realloc function, the behavior is undefined. If memory for the new object cannot be
allocated, the old object is not deallocated and its value is unchanged.
- Returns
+<b> Returns</b>
4 The realloc function returns a pointer to the new object (which may have the same
value as a pointer to the old object), or a null pointer if the new object could not be
allocated.
<a name="7.22.4" href="#7.22.4"><b> 7.22.4 Communication with the environment</b></a>
<a name="7.22.4.1" href="#7.22.4.1"><b> 7.22.4.1 The abort function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
_Noreturn void abort(void);
- Description
+<b> Description</b>
2 The abort function causes abnormal program termination to occur, unless the signal
SIGABRT is being caught and the signal handler does not return. Whether open streams
with unwritten buffered data are flushed, open streams are closed, or temporary files are
[<a name="p349" href="#p349">page 349</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The abort function does not return to its caller.
<a name="7.22.4.2" href="#7.22.4.2"><b> 7.22.4.2 The atexit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int atexit(void (*func)(void));
- Description
+<b> Description</b>
2 The atexit function registers the function pointed to by func, to be called without
arguments at normal program termination.290)
Environmental limits
3 The implementation shall support the registration of at least 32 functions.
- Returns
+<b> Returns</b>
4 The atexit function returns zero if the registration succeeds, nonzero if it fails.
Forward references: the at_quick_exit function (<a href="#7.22.4.3">7.22.4.3</a>), the exit function
(<a href="#7.22.4.4">7.22.4.4</a>).
<a name="7.22.4.3" href="#7.22.4.3"><b> 7.22.4.3 The at_quick_exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int at_quick_exit(void (*func)(void));
- Description
+<b> Description</b>
2 The at_quick_exit function registers the function pointed to by func, to be called
without arguments should quick_exit be called.291)
Environmental limits
3 The implementation shall support the registration of at least 32 functions.
- Returns
+<b> Returns</b>
4 The at_quick_exit function returns zero if the registration succeeds, nonzero if it
fails.
Forward references: the quick_exit function (<a href="#7.22.4.7">7.22.4.7</a>).
[<a name="p350" href="#p350">page 350</a>] (<a href="#Contents">Contents</a>)
<a name="7.22.4.4" href="#7.22.4.4"><b> 7.22.4.4 The exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
_Noreturn void exit(int status);
- Description
+<b> Description</b>
2 The exit function causes normal program termination to occur. No functions registered
by the at_quick_exit function are called. If a program calls the exit function
more than once, or calls the quick_exit function in addition to the exit function, the
returned. If the value of status is EXIT_FAILURE, an implementation-defined form
of the status unsuccessful termination is returned. Otherwise the status returned is
implementation-defined.
- Returns
+<b> Returns</b>
6 The exit function cannot return to its caller.
<a name="7.22.4.5" href="#7.22.4.5"><b> 7.22.4.5 The _Exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
_Noreturn void _Exit(int status);
- Description
+<b> Description</b>
2 The _Exit function causes normal program termination to occur and control to be
returned to the host environment. No functions registered by the atexit function, the
at_quick_exit function, or signal handlers registered by the signal function are
the exit function (<a href="#7.22.4.4">7.22.4.4</a>). Whether open streams with unwritten buffered data are
flushed, open streams are closed, or temporary files are removed is implementation-
defined.
- Returns
+<b> Returns</b>
3 The _Exit function cannot return to its caller.
<a name="7.22.4.6" href="#7.22.4.6"><b> 7.22.4.6 The getenv function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
char *getenv(const char *name);
- Description
+<b> Description</b>
2 The getenv function searches an environment list, provided by the host environment,
for a string that matches the string pointed to by name. The set of environment names
and the method for altering the environment list are implementation-defined. The
getenv function need not avoid data races with other threads of execution that modify
the environment list.293)
3 The implementation shall behave as if no library function calls the getenv function.
- Returns
+<b> Returns</b>
4 The getenv function returns a pointer to a string associated with the matched list
member. The string pointed to shall not be modified by the program, but may be
overwritten by a subsequent call to the getenv function. If the specified name cannot
be found, a null pointer is returned.
<a name="7.22.4.7" href="#7.22.4.7"><b> 7.22.4.7 The quick_exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
_Noreturn void quick_exit(int status);
- Description
+<b> Description</b>
2 The quick_exit function causes normal program termination to occur. No functions
registered by the atexit function or signal handlers registered by the signal function
are called. If a program calls the quick_exit function more than once, or calls the
made that would terminate the call to the registered function, the behavior is undefined.
4 Then control is returned to the host environment by means of the function call
_Exit(status).
- Returns
+<b> Returns</b>
5 The quick_exit function cannot return to its caller.
<a name="7.22.4.8" href="#7.22.4.8"><b> 7.22.4.8 The system function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int system(const char *string);
- Description
+<b> Description</b>
2 If string is a null pointer, the system function determines whether the host
environment has a command processor. If string is not a null pointer, the system
function passes the string pointed to by string to that command processor to be
executed in a manner which the implementation shall document; this might then cause the
program calling system to behave in a non-conforming manner or to terminate.
- Returns
+<b> Returns</b>
3 If the argument is a null pointer, the system function returns nonzero only if a
command processor is available. If the argument is not a null pointer, and the system
function does return, it returns an implementation-defined value.
comparison function, and also between any call to the comparison function and any
movement of the objects passed as arguments to that call.
<a name="7.22.5.1" href="#7.22.5.1"><b> 7.22.5.1 The bsearch function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void *bsearch(const void *key, const void *base,
size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
- Description
+<b> Description</b>
2 The bsearch function searches an array of nmemb objects, the initial element of which
is pointed to by base, for an element that matches the object pointed to by key. The
size of each element of the array is specified by size.
respectively, to be less than, to match, or to be greater than the array element. The array
shall consist of: all the elements that compare less than, all the elements that compare
equal to, and all the elements that compare greater than the key object, in that order.296)
- Returns
+<b> Returns</b>
4 The bsearch function returns a pointer to a matching element of the array, or a null
pointer if no match is found. If two elements compare as equal, which element is
matched is unspecified.
<a name="7.22.5.2" href="#7.22.5.2"><b> 7.22.5.2 The qsort function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
void qsort(void *base, size_t nmemb, size_t size,
int (*compar)(const void *, const void *));
- Description
+<b> Description</b>
2 The qsort function sorts an array of nmemb objects, the initial element of which is
pointed to by base. The size of each object is specified by size.
3 The contents of the array are sorted into ascending order according to a comparison
greater than zero if the first argument is considered to be respectively less than, equal to,
or greater than the second.
4 If two elements compare as equal, their order in the resulting sorted array is unspecified.
- Returns
+<b> Returns</b>
5 The qsort function returns no value.
<a name="7.22.6" href="#7.22.6"><b> 7.22.6 Integer arithmetic functions</b></a>
<a name="7.22.6.1" href="#7.22.6.1"><b> 7.22.6.1 The abs, labs and llabs functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int abs(int j);
long int labs(long int j);
long long int llabs(long long int j);
- Description
+<b> Description</b>
2 The abs, labs, and llabs functions compute the absolute value of an integer j. If the
result cannot be represented, the behavior is undefined.297)
- Returns
+<b> Returns</b>
3 The abs, labs, and llabs, functions return the absolute value.
[<a name="p355" href="#p355">page 355</a>] (<a href="#Contents">Contents</a>)
<a name="7.22.6.2" href="#7.22.6.2"><b> 7.22.6.2 The div, ldiv, and lldiv functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
div_t div(int numer, int denom);
ldiv_t ldiv(long int numer, long int denom);
lldiv_t lldiv(long long int numer, long long int denom);
- Description
+<b> Description</b>
2 The div, ldiv, and lldiv, functions compute numer / denom and numer %
denom in a single operation.
- Returns
+<b> Returns</b>
3 The div, ldiv, and lldiv functions return a structure of type div_t, ldiv_t, and
lldiv_t, respectively, comprising both the quotient and the remainder. The structures
shall contain (in either order) the members quot (the quotient) and rem (the remainder),
if encodings have state dependency, and zero otherwise.298) Changing the LC_CTYPE
category causes the conversion state of these functions to be indeterminate.
<a name="7.22.7.1" href="#7.22.7.1"><b> 7.22.7.1 The mblen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int mblen(const char *s, size_t n);
- Description
+<b> Description</b>
2 If s is not a null pointer, the mblen function determines the number of bytes contained
in the multibyte character pointed to by s. Except that the conversion state of the
mbtowc function is not affected, it is equivalent to
mbtowc((wchar_t *)0, (const char *)0, 0);
mbtowc((wchar_t *)0, s, n);
3 The implementation shall behave as if no library function calls the mblen function.
- Returns
+<b> Returns</b>
4 If s is a null pointer, the mblen function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the mblen function either returns 0 (if s points to the null character),
multibyte character).
Forward references: the mbtowc function (<a href="#7.22.7.2">7.22.7.2</a>).
<a name="7.22.7.2" href="#7.22.7.2"><b> 7.22.7.2 The mbtowc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int mbtowc(wchar_t * restrict pwc,
const char * restrict s,
size_t n);
- Description
+<b> Description</b>
2 If s is not a null pointer, the mbtowc function inspects at most n bytes beginning with
the byte pointed to by s to determine the number of bytes needed to complete the next
multibyte character (including any shift sequences). If the function determines that the
the object pointed to by pwc. If the corresponding wide character is the null wide
character, the function is left in the initial conversion state.
3 The implementation shall behave as if no library function calls the mbtowc function.
- Returns
+<b> Returns</b>
4 If s is a null pointer, the mbtowc function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the mbtowc function either returns 0 (if s points to the null character),
[<a name="p357" href="#p357">page 357</a>] (<a href="#Contents">Contents</a>)
<a name="7.22.7.3" href="#7.22.7.3"><b> 7.22.7.3 The wctomb function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
int wctomb(char *s, wchar_t wc);
- Description
+<b> Description</b>
2 The wctomb function determines the number of bytes needed to represent the multibyte
character corresponding to the wide character given by wc (including any shift
sequences), and stores the multibyte character representation in the array whose first
sequence needed to restore the initial shift state, and the function is left in the initial
conversion state.
3 The implementation shall behave as if no library function calls the wctomb function.
- Returns
+<b> Returns</b>
4 If s is a null pointer, the wctomb function returns a nonzero or zero value, if multibyte
character encodings, respectively, do or do not have state-dependent encodings. If s is
not a null pointer, the wctomb function returns -1 if the value of wc does not correspond
1 The behavior of the multibyte string functions is affected by the LC_CTYPE category of
the current locale.
<a name="7.22.8.1" href="#7.22.8.1"><b> 7.22.8.1 The mbstowcs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
size_t mbstowcs(wchar_t * restrict pwcs,
const char * restrict s,
size_t n);
- Description
+<b> Description</b>
2 The mbstowcs function converts a sequence of multibyte characters that begins in the
initial shift state from the array pointed to by s into a sequence of corresponding wide
characters and stores not more than n wide characters into the array pointed to by pwcs.
not affected.
3 No more than n elements will be modified in the array pointed to by pwcs. If copying
takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
4 If an invalid multibyte character is encountered, the mbstowcs function returns
(size_t)(-1). Otherwise, the mbstowcs function returns the number of array
elements modified, not including a terminating null wide character, if any.299)
<a name="7.22.8.2" href="#7.22.8.2"><b> 7.22.8.2 The wcstombs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
size_t wcstombs(char * restrict s,
const wchar_t * restrict pwcs,
size_t n);
- Description
+<b> Description</b>
2 The wcstombs function converts a sequence of wide characters from the array pointed
to by pwcs into a sequence of corresponding multibyte characters that begins in the
initial shift state, and stores these multibyte characters into the array pointed to by s,
function, except that the conversion state of the wctomb function is not affected.
3 No more than n bytes will be modified in the array pointed to by s. If copying takes place
between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
4 If a wide character is encountered that does not correspond to a valid multibyte character,
the wcstombs function returns (size_t)(-1). Otherwise, the wcstombs function
returns the number of bytes modified, not including a terminating null character, if
different value).
<a name="7.23.2" href="#7.23.2"><b> 7.23.2 Copying functions</b></a>
<a name="7.23.2.1" href="#7.23.2.1"><b> 7.23.2.1 The memcpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
void *memcpy(void * restrict s1,
const void * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The memcpy function copies n characters from the object pointed to by s2 into the
object pointed to by s1. If copying takes place between objects that overlap, the behavior
is undefined.
- Returns
+<b> Returns</b>
3 The memcpy function returns the value of s1.
[<a name="p360" href="#p360">page 360</a>] (<a href="#Contents">Contents</a>)
<a name="7.23.2.2" href="#7.23.2.2"><b> 7.23.2.2 The memmove function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
void *memmove(void *s1, const void *s2, size_t n);
- Description
+<b> Description</b>
2 The memmove function copies n characters from the object pointed to by s2 into the
object pointed to by s1. Copying takes place as if the n characters from the object
pointed to by s2 are first copied into a temporary array of n characters that does not
overlap the objects pointed to by s1 and s2, and then the n characters from the
temporary array are copied into the object pointed to by s1.
- Returns
+<b> Returns</b>
3 The memmove function returns the value of s1.
<a name="7.23.2.3" href="#7.23.2.3"><b> 7.23.2.3 The strcpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strcpy(char * restrict s1,
const char * restrict s2);
- Description
+<b> Description</b>
2 The strcpy function copies the string pointed to by s2 (including the terminating null
character) into the array pointed to by s1. If copying takes place between objects that
overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The strcpy function returns the value of s1.
<a name="7.23.2.4" href="#7.23.2.4"><b> 7.23.2.4 The strncpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strncpy(char * restrict s1,
const char * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The strncpy function copies not more than n characters (characters that follow a null
character are not copied) from the array pointed to by s2 to the array pointed to by
3 If the array pointed to by s2 is a string that is shorter than n characters, null characters
are appended to the copy in the array pointed to by s1, until n characters in all have been
written.
- Returns
+<b> Returns</b>
4 The strncpy function returns the value of s1.
<a name="7.23.3" href="#7.23.3"><b> 7.23.3 Concatenation functions</b></a>
<a name="7.23.3.1" href="#7.23.3.1"><b> 7.23.3.1 The strcat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strcat(char * restrict s1,
const char * restrict s2);
- Description
+<b> Description</b>
2 The strcat function appends a copy of the string pointed to by s2 (including the
terminating null character) to the end of the string pointed to by s1. The initial character
of s2 overwrites the null character at the end of s1. If copying takes place between
objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The strcat function returns the value of s1.
<a name="7.23.3.2" href="#7.23.3.2"><b> 7.23.3.2 The strncat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strncat(char * restrict s1,
const char * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The strncat function appends not more than n characters (a null character and
characters that follow it are not appended) from the array pointed to by s2 to the end of
the string pointed to by s1. The initial character of s2 overwrites the null character at the
[<a name="p362" href="#p362">page 362</a>] (<a href="#Contents">Contents</a>)
takes place between objects that overlap, the behavior is undefined.
- Returns
+<b> Returns</b>
3 The strncat function returns the value of s1.
Forward references: the strlen function (<a href="#7.23.6.3">7.23.6.3</a>).
<a name="7.23.4" href="#7.23.4"><b> 7.23.4 Comparison functions</b></a>
pair of characters (both interpreted as unsigned char) that differ in the objects being
compared.
<a name="7.23.4.1" href="#7.23.4.1"><b> 7.23.4.1 The memcmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
int memcmp(const void *s1, const void *s2, size_t n);
- Description
+<b> Description</b>
2 The memcmp function compares the first n characters of the object pointed to by s1 to
the first n characters of the object pointed to by s2.303)
- Returns
+<b> Returns</b>
3 The memcmp function returns an integer greater than, equal to, or less than zero,
accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
pointed to by s2.
<a name="7.23.4.2" href="#7.23.4.2"><b> 7.23.4.2 The strcmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
int strcmp(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strcmp function compares the string pointed to by s1 to the string pointed to by
s2.
- Returns
+<b> Returns</b>
3 The strcmp function returns an integer greater than, equal to, or less than zero,
accordingly as the string pointed to by s1 is greater than, equal to, or less than the string
pointed to by s2.
<a name="7.23.4.3" href="#7.23.4.3"><b> 7.23.4.3 The strcoll function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
int strcoll(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strcoll function compares the string pointed to by s1 to the string pointed to by
s2, both interpreted as appropriate to the LC_COLLATE category of the current locale.
- Returns
+<b> Returns</b>
3 The strcoll function returns an integer greater than, equal to, or less than zero,
accordingly as the string pointed to by s1 is greater than, equal to, or less than the string
pointed to by s2 when both are interpreted as appropriate to the current locale.
<a name="7.23.4.4" href="#7.23.4.4"><b> 7.23.4.4 The strncmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
int strncmp(const char *s1, const char *s2, size_t n);
- Description
+<b> Description</b>
2 The strncmp function compares not more than n characters (characters that follow a
null character are not compared) from the array pointed to by s1 to the array pointed to
by s2.
- Returns
+<b> Returns</b>
3 The strncmp function returns an integer greater than, equal to, or less than zero,
accordingly as the possibly null-terminated array pointed to by s1 is greater than, equal
to, or less than the possibly null-terminated array pointed to by s2.
<a name="7.23.4.5" href="#7.23.4.5"><b> 7.23.4.5 The strxfrm function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
size_t strxfrm(char * restrict s1,
const char * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The strxfrm function transforms the string pointed to by s2 and places the resulting
string into the array pointed to by s1. The transformation is such that if the strcmp
function is applied to two transformed strings, it returns a value greater than, equal to, or
pointed to by s1, including the terminating null character. If n is zero, s1 is permitted to
be a null pointer. If copying takes place between objects that overlap, the behavior is
undefined.
- Returns
+<b> Returns</b>
3 The strxfrm function returns the length of the transformed string (not including the
terminating null character). If the value returned is n or more, the contents of the array
pointed to by s1 are indeterminate.
<a name="7.23.5" href="#7.23.5"><b> 7.23.5 Search functions</b></a>
<a name="7.23.5.1" href="#7.23.5.1"><b> 7.23.5.1 The memchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
void *memchr(const void *s, int c, size_t n);
- Description
+<b> Description</b>
2 The memchr function locates the first occurrence of c (converted to an unsigned
char) in the initial n characters (each interpreted as unsigned char) of the object
pointed to by s. The implementation shall behave as if it reads the characters sequentially
and stops as soon as a matching character is found.
- Returns
+<b> Returns</b>
3 The memchr function returns a pointer to the located character, or a null pointer if the
character does not occur in the object.
<a name="7.23.5.2" href="#7.23.5.2"><b> 7.23.5.2 The strchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strchr(const char *s, int c);
- Description
+<b> Description</b>
2 The strchr function locates the first occurrence of c (converted to a char) in the
string pointed to by s. The terminating null character is considered to be part of the
string.
[<a name="p365" href="#p365">page 365</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The strchr function returns a pointer to the located character, or a null pointer if the
character does not occur in the string.
<a name="7.23.5.3" href="#7.23.5.3"><b> 7.23.5.3 The strcspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
size_t strcspn(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strcspn function computes the length of the maximum initial segment of the string
pointed to by s1 which consists entirely of characters not from the string pointed to by
s2.
- Returns
+<b> Returns</b>
3 The strcspn function returns the length of the segment.
<a name="7.23.5.4" href="#7.23.5.4"><b> 7.23.5.4 The strpbrk function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strpbrk(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strpbrk function locates the first occurrence in the string pointed to by s1 of any
character from the string pointed to by s2.
- Returns
+<b> Returns</b>
3 The strpbrk function returns a pointer to the character, or a null pointer if no character
from s2 occurs in s1.
<a name="7.23.5.5" href="#7.23.5.5"><b> 7.23.5.5 The strrchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strrchr(const char *s, int c);
- Description
+<b> Description</b>
2 The strrchr function locates the last occurrence of c (converted to a char) in the
string pointed to by s. The terminating null character is considered to be part of the
string.
[<a name="p366" href="#p366">page 366</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The strrchr function returns a pointer to the character, or a null pointer if c does not
occur in the string.
<a name="7.23.5.6" href="#7.23.5.6"><b> 7.23.5.6 The strspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
size_t strspn(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strspn function computes the length of the maximum initial segment of the string
pointed to by s1 which consists entirely of characters from the string pointed to by s2.
- Returns
+<b> Returns</b>
3 The strspn function returns the length of the segment.
<a name="7.23.5.7" href="#7.23.5.7"><b> 7.23.5.7 The strstr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strstr(const char *s1, const char *s2);
- Description
+<b> Description</b>
2 The strstr function locates the first occurrence in the string pointed to by s1 of the
sequence of characters (excluding the terminating null character) in the string pointed to
by s2.
- Returns
+<b> Returns</b>
3 The strstr function returns a pointer to the located string, or a null pointer if the string
is not found. If s2 points to a string with zero length, the function returns s1.
<a name="7.23.5.8" href="#7.23.5.8"><b> 7.23.5.8 The strtok function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strtok(char * restrict s1,
const char * restrict s2);
- Description
+<b> Description</b>
2 A sequence of calls to the strtok function breaks the string pointed to by s1 into a
sequence of tokens, each of which is delimited by a character from the string pointed to
by s2. The first call in the sequence has a non-null first argument; subsequent calls in the
searching from the saved pointer and behaves as described above.
6 The strtok function is not required to avoid data races. The implementation shall
behave as if no library function calls the strtok function.
- Returns
+<b> Returns</b>
7 The strtok function returns a pointer to the first character of a token, or a null pointer
if there is no token.
8 EXAMPLE
<a name="7.23.6" href="#7.23.6"><b> 7.23.6 Miscellaneous functions</b></a>
<a name="7.23.6.1" href="#7.23.6.1"><b> 7.23.6.1 The memset function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
void *memset(void *s, int c, size_t n);
- Description
+<b> Description</b>
2 The memset function copies the value of c (converted to an unsigned char) into
each of the first n characters of the object pointed to by s.
- Returns
+<b> Returns</b>
3 The memset function returns the value of s.
[<a name="p368" href="#p368">page 368</a>] (<a href="#Contents">Contents</a>)
<a name="7.23.6.2" href="#7.23.6.2"><b> 7.23.6.2 The strerror function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
char *strerror(int errnum);
- Description
+<b> Description</b>
2 The strerror function maps the number in errnum to a message string. Typically,
the values for errnum come from errno, but strerror shall map any value of type
int to a message.
3 The strerror function is not required to avoid data races. The implementation shall
behave as if no library function calls the strerror function.
- Returns
+<b> Returns</b>
4 The strerror function returns a pointer to the string, the contents of which are locale-
specific. The array pointed to shall not be modified by the program, but may be
overwritten by a subsequent call to the strerror function.
<a name="7.23.6.3" href="#7.23.6.3"><b> 7.23.6.3 The strlen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.23"><string.h></a>
size_t strlen(const char *s);
- Description
+<b> Description</b>
2 The strlen function computes the length of the string pointed to by s.
- Returns
+<b> Returns</b>
3 The strlen function returns the number of characters that precede the terminating null
character.
<a name="7.25.2" href="#7.25.2"><b> 7.25.2 Initialization functions</b></a>
<a name="7.25.2.1" href="#7.25.2.1"><b> 7.25.2.1 The call_once function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void call_once(once_flag *flag, void (*func)(void));
- Description
+<b> Description</b>
2 The call_once function uses the once_flag pointed to by flag to ensure that
func is called exactly once, the first time the call_once function is called with that
value of flag. Completion of an effective call to the call_once function synchronizes
with all subsequent calls to the call_once function with the same value of flag.
- Returns
+<b> Returns</b>
3 The call_once function returns no value.
<a name="7.25.3" href="#7.25.3"><b> 7.25.3 Condition variable functions</b></a>
<a name="7.25.3.1" href="#7.25.3.1"><b> 7.25.3.1 The cnd_broadcast function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int cnd_broadcast(cnd_t *cond);
- Description
+<b> Description</b>
2 The cnd_broadcast function unblocks all of the threads that are blocked on the
condition variable pointed to by cond at the time of the call. If no threads are blocked
on the condition variable pointed to by cond at the time of the call, the function does
nothing.
- Returns
+<b> Returns</b>
3 The cnd_broadcast function returns thrd_success on success, or thrd_error
if the request could not be honored.
<a name="7.25.3.2" href="#7.25.3.2"><b> 7.25.3.2 The cnd_destroy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void cnd_destroy(cnd_t *cond);
- Description
+<b> Description</b>
2 The cnd_destroy function releases all resources used by the condition variable
pointed to by cond. The cnd_destroy function requires that no threads be blocked
waiting for the condition variable pointed to by cond.
[<a name="p375" href="#p375">page 375</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The cnd_destroy function returns no value.
<a name="7.25.3.3" href="#7.25.3.3"><b> 7.25.3.3 The cnd_init function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int cnd_init(cnd_t *cond);
- Description
+<b> Description</b>
2 The cnd_init function creates a condition variable. If it succeeds it sets the variable
pointed to by cond to a value that uniquely identifies the newly created condition
variable. A thread that calls cnd_wait on a newly created condition variable will
block.
- Returns
+<b> Returns</b>
3 The cnd_init function returns thrd_success on success, or thrd_nomem if no
memory could be allocated for the newly created condition, or thrd_error if the
request could not be honored.
<a name="7.25.3.4" href="#7.25.3.4"><b> 7.25.3.4 The cnd_signal function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int cnd_signal(cnd_t *cond);
- Description
+<b> Description</b>
2 The cnd_signal function unblocks one of the threads that are blocked on the
condition variable pointed to by cond at the time of the call. If no threads are blocked
on the condition variable at the time of the call, the function does nothing and return
success.
- Returns
+<b> Returns</b>
3 The cnd_signal function returns thrd_success on success or thrd_error if
the request could not be honored.
<a name="7.25.3.5" href="#7.25.3.5"><b> 7.25.3.5 The cnd_timedwait function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int cnd_timedwait(cnd_t *cond, mtx_t *mtx,
const xtime *xt);
[<a name="p376" href="#p376">page 376</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The cnd_timedwait function atomically unlocks the mutex pointed to by mtx and
endeavors to block until the condition variable pointed to by cond is signaled by a call to
cnd_signal or to cnd_broadcast, or until after the time specified by the xtime
object pointed to by xt. When the calling thread becomes unblocked it locks the variable
pointed to by mtx before it returns. The cnd_timedwait function requires that the
mutex pointed to by mtx be locked by the calling thread.
- Returns
+<b> Returns</b>
3 The cnd_timedwait function returns thrd_success upon success, or
thrd_timeout if the time specified in the call was reached without acquiring the
requested resource, or thrd_error if the request could not be honored.
<a name="7.25.3.6" href="#7.25.3.6"><b> 7.25.3.6 The cnd_wait function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int cnd_wait(cnd_t *cond, mtx_t *mtx);
- Description
+<b> Description</b>
2 The cnd_wait function atomically unlocks the mutex pointed to by mtx and endeavors
to block until the condition variable pointed to by cond is signaled by a call to
cnd_signal or to cnd_broadcast. When the calling thread becomes unblocked it
locks the mutex pointed to by mtx before it returns. If the mutex pointed to by mtx is
not locked by the calling thread, the cnd_wait function will act as if the abort
function is called.
- Returns
+<b> Returns</b>
3 The cnd_wait function returns thrd_success on success or thrd_error if the
request could not be honored.
<a name="7.25.4" href="#7.25.4"><b> 7.25.4 Mutex functions</b></a>
<a name="7.25.4.1" href="#7.25.4.1"><b> 7.25.4.1 The mtx_destroy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void mtx_destroy(mtx_t *mtx);
- Description
+<b> Description</b>
2 The mtx_destroy function releases any resources used by the mutex pointed to by
mtx. No threads can be blocked waiting for the mutex pointed to by mtx.
[<a name="p377" href="#p377">page 377</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The mtx_destroy function returns no value.
<a name="7.25.4.2" href="#7.25.4.2"><b> 7.25.4.2 The mtx_init function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int mtx_init(mtx_t *mtx, int type);
- Description
+<b> Description</b>
2 The mtx_init function creates a mutex object with properties indicated by type,
which must have one of the six values:
mtx_plain for a simple non-recursive mutex,
mtx_try | mtx_recursive for a recursive mutex that supports test and return.
3 If the mtx_init function succeeds, it sets the mutex pointed to by mtx to a value that
uniquely identifies the newly created mutex.
- Returns
+<b> Returns</b>
4 The mtx_init function returns thrd_success on success, or thrd_error if the
request could not be honored.
<a name="7.25.4.3" href="#7.25.4.3"><b> 7.25.4.3 The mtx_lock function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int mtx_lock(mtx_t *mtx);
- Description
+<b> Description</b>
2 The mtx_lock function blocks until it locks the mutex pointed to by mtx. If the mutex
is non-recursive, it shall not be locked by the calling thread. Prior calls to mtx_unlock
on the same mutex shall synchronize with this operation.
- Returns
+<b> Returns</b>
3 The mtx_lock function returns thrd_success on success, or thrd_busy if the
resource requested is already in use, or thrd_error if the request could not be
honored.
[<a name="p378" href="#p378">page 378</a>] (<a href="#Contents">Contents</a>)
<a name="7.25.4.4" href="#7.25.4.4"><b> 7.25.4.4 The mtx_timedlock function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int mtx_timedlock(mtx_t *mtx, const xtime *xt);
- Description
+<b> Description</b>
2 The mtx_timedlock function endeavors to block until it locks the mutex pointed to by
mtx or until the time specified by the xtime object xt has passed. The specified mutex
shall support timeout. If the operation succeeds, prior calls to mtx_unlock on the same
mutex shall synchronize with this operation.
- Returns
+<b> Returns</b>
3 The mtx_timedlock function returns thrd_success on success, or thrd_busy
if the resource requested is already in use, or thrd_timeout if the time specified was
reached without acquiring the requested resource, or thrd_error if the request could
not be honored.
<a name="7.25.4.5" href="#7.25.4.5"><b> 7.25.4.5 The mtx_trylock function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int mtx_trylock(mtx_t *mtx);
- Description
+<b> Description</b>
2 The mtx_trylock function endeavors to lock the mutex pointed to by mtx. The
specified mutex shall support either test and return or timeout. If the mutex is already
locked, the function returns without blocking. If the operation succeeds, prior calls to
mtx_unlock on the same mutex shall synchronize with this operation.
- Returns
+<b> Returns</b>
3 The mtx_trylock function returns thrd_success on success, or thrd_busy if
the resource requested is already in use, or thrd_error if the request could not be
honored.
<a name="7.25.4.6" href="#7.25.4.6"><b> 7.25.4.6 The mtx_unlock function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int mtx_unlock(mtx_t *mtx);
- Description
+<b> Description</b>
2 The mtx_unlock function unlocks the mutex pointed to by mtx. The mutex pointed to
by mtx shall be locked by the calling thread.
[<a name="p379" href="#p379">page 379</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The mtx_unlock function returns thrd_success on success or thrd_error if
the request could not be honored.
<a name="7.25.5" href="#7.25.5"><b> 7.25.5 Thread functions</b></a>
<a name="7.25.5.1" href="#7.25.5.1"><b> 7.25.5.1 The thrd_create function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int thrd_create(thrd_t *thr, thrd_start_t func,
void *arg);
- Description
+<b> Description</b>
2 The thrd_create function creates a new thread executing func(arg). If the
thrd_create function succeeds, it sets the object pointed to by thr to the identifier of
the newly created thread. (A thread's identifier may be reused for a different thread once
the original thread has exited and either been detached or joined to another thread.) The
completion of the thrd_create function synchronizes with the beginning of the
execution of the new thread.
- Returns
+<b> Returns</b>
3 The thrd_create function returns thrd_success on success, or thrd_nomem if
no memory could be allocated for the thread requested, or thrd_error if the request
could not be honored.
<a name="7.25.5.2" href="#7.25.5.2"><b> 7.25.5.2 The thrd_current function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
thrd_t thrd_current(void);
- Description
+<b> Description</b>
2 The thrd_current function identifies the thread that called it.
- Returns
+<b> Returns</b>
3 The thrd_current function returns the identifier of the thread that called it.
<a name="7.25.5.3" href="#7.25.5.3"><b> 7.25.5.3 The thrd_detach function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int thrd_detach(thrd_t thr);
[<a name="p380" href="#p380">page 380</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The thrd_detach function tells the operating system to dispose of any resources
allocated to the thread identified by thr when that thread terminates. The thread
identified by thr shall not have been previously detached or joined with another thread.
- Returns
+<b> Returns</b>
3 The thrd_detach function returns thrd_success on success or thrd_error if
the request could not be honored.
<a name="7.25.5.4" href="#7.25.5.4"><b> 7.25.5.4 The thrd_equal function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int thrd_equal(thrd_t thr0, thrd_t thr1);
- Description
+<b> Description</b>
2 The thrd_equal function will determine whether the thread identified by thr0 refers
to the thread identified by thr1.
- Returns
+<b> Returns</b>
3 The thrd_equal function returns zero if the thread thr0 and the thread thr1 refer to
different threads. Otherwise the thrd_equal function returns a nonzero value.
<a name="7.25.5.5" href="#7.25.5.5"><b> 7.25.5.5 The thrd_exit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void thrd_exit(int res);
- Description
+<b> Description</b>
2 The thrd_exit function terminates execution of the calling thread and sets its result
code to res.
- Returns
+<b> Returns</b>
3 The thrd_exit function returns no value.
<a name="7.25.5.6" href="#7.25.5.6"><b> 7.25.5.6 The thrd_join function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int thrd_join(thrd_t thr, int *res);
- Description
+<b> Description</b>
2 The thrd_join function joins the thread identified by thr with the current thread by
blocking until the other thread has terminated. If the parameter res is not a null pointer,
it stores the thread's result code in the integer pointed to by res. The termination of the
other thread synchronizes with the completion of the thrd_join function. The thread
identified by thr shall not have been previously detached or joined with another thread.
- Returns
+<b> Returns</b>
3 The thrd_join function returns thrd_success on success or thrd_error if the
request could not be honored.
<a name="7.25.5.7" href="#7.25.5.7"><b> 7.25.5.7 The thrd_sleep function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void thrd_sleep(const xtime *xt);
- Description
+<b> Description</b>
2 The thrd_sleep function suspends execution of the calling thread until after the time
specified by the xtime object pointed to by xt.
- Returns
+<b> Returns</b>
3 The thrd_sleep function returns no value.
<a name="7.25.5.8" href="#7.25.5.8"><b> 7.25.5.8 The thrd_yield function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void thrd_yield(void);
- Description
+<b> Description</b>
2 The thrd_yield function endeavors to permit other threads to run, even if the current
thread would ordinarily continue to run.
- Returns
+<b> Returns</b>
3 The thrd_yield function returns no value.
<a name="7.25.6" href="#7.25.6"><b> 7.25.6 Thread-specific storage functions</b></a>
<a name="7.25.6.1" href="#7.25.6.1"><b> 7.25.6.1 The tss_create function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int tss_create(tss_t *key, tss_dtor_t dtor);
- Description
+<b> Description</b>
2 The tss_create function creates a thread-specific storage pointer with destructor
dtor, which may be null.
[<a name="p382" href="#p382">page 382</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 If the tss_create function is successful, it sets the thread-specific storage pointed to
by key to a value that uniquely identifies the newly created pointer and returns
thrd_success; otherwise, thrd_error is returned and the thread-specific storage
pointed to by key is set to an undefined value.
<a name="7.25.6.2" href="#7.25.6.2"><b> 7.25.6.2 The tss_delete function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void tss_delete(tss_t key);
- Description
+<b> Description</b>
2 The tss_delete function releases any resources used by the thread-specific storage
identified by key.
- Returns
+<b> Returns</b>
3 The tss_delete function returns no value.
<a name="7.25.6.3" href="#7.25.6.3"><b> 7.25.6.3 The tss_get function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
void *tss_get(tss_t key);
- Description
+<b> Description</b>
2 The tss_get function returns the value for the current thread held in the thread-specific
storage identified by key.
- Returns
+<b> Returns</b>
3 The tss_get function returns the value for the current thread if successful, or zero if
unsuccessful.
<a name="7.25.6.4" href="#7.25.6.4"><b> 7.25.6.4 The tss_set function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int tss_set(tss_t key, void *val);
- Description
+<b> Description</b>
2 The tss_set function sets the value for the current thread held in the thread-specific
storage identified by key to val.
[<a name="p383" href="#p383">page 383</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The tss_set function returns thrd_success on success or thrd_error if the
request could not be honored.
<a name="7.25.7" href="#7.25.7"><b> 7.25.7 Time functions</b></a>
<a name="7.25.7.1" href="#7.25.7.1"><b> 7.25.7.1 The xtime_get function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.25"><threads.h></a>
int xtime_get(xtime *xt, int base);
- Description
+<b> Description</b>
2 The xtime_get function sets the xtime object pointed to by xt to hold the current
time based on the time base base.
- Returns
+<b> Returns</b>
3 If the xtime_get function is successful it returns the nonzero value base, which must
be TIME_UTC; otherwise, it returns zero.306)
Saving Time is not in effect, and negative if the information is not available.
<a name="7.26.2" href="#7.26.2"><b> 7.26.2 Time manipulation functions</b></a>
<a name="7.26.2.1" href="#7.26.2.1"><b> 7.26.2.1 The clock function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
clock_t clock(void);
- Description
+<b> Description</b>
2 The clock function determines the processor time used.
- Returns
+<b> Returns</b>
3 The clock function returns the implementation's best approximation to the processor
time used by the program since the beginning of an implementation-defined era related
only to the program invocation. To determine the time in seconds, the value returned by
the processor time used is not available or its value cannot be represented, the function
returns the value (clock_t)(-1).308)
<a name="7.26.2.2" href="#7.26.2.2"><b> 7.26.2.2 The difftime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
double difftime(time_t time1, time_t time0);
- Description
+<b> Description</b>
2 The difftime function computes the difference between two calendar times: time1 -
time0.
- Returns
+<b> Returns</b>
3 The difftime function returns the difference expressed in seconds as a double.
[<a name="p386" href="#p386">page 386</a>] (<a href="#Contents">Contents</a>)
<a name="7.26.2.3" href="#7.26.2.3"><b> 7.26.2.3 The mktime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
time_t mktime(struct tm *timeptr);
- Description
+<b> Description</b>
2 The mktime function converts the broken-down time, expressed as local time, in the
structure pointed to by timeptr into a calendar time value with the same encoding as
that of the values returned by the time function. The original values of the tm_wday
set appropriately, and the other components are set to represent the specified calendar
time, but with their values forced to the ranges indicated above; the final value of
tm_mday is not set until tm_mon and tm_year are determined.
- Returns
+<b> Returns</b>
3 The mktime function returns the specified calendar time encoded as a value of type
time_t. If the calendar time cannot be represented, the function returns the value
(time_t)(-1).
printf("%s\n", wday[time_str.tm_wday]);
<a name="7.26.2.4" href="#7.26.2.4"><b> 7.26.2.4 The time function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
time_t time(time_t *timer);
- Description
+<b> Description</b>
2 The time function determines the current calendar time. The encoding of the value is
unspecified.
- Returns
+<b> Returns</b>
3 The time function returns the implementation's best approximation to the current
calendar time. The value (time_t)(-1) is returned if the calendar time is not
available. If timer is not a null pointer, the return value is also assigned to the object it
previous call to any of them and the functions are not required to avoid data races. The
implementation shall behave as if no other library functions call these functions.
<a name="7.26.3.1" href="#7.26.3.1"><b> 7.26.3.1 The asctime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
char *asctime(const struct tm *timeptr);
- Description
+<b> Description</b>
2 The asctime function converts the broken-down time in the structure pointed to by
timeptr into a string in the form
Sun Sep 16 01:03:52 1973\n\0
ranges,310) the behavior of the asctime function is undefined. Likewise, if the
calculated year exceeds four digits or is less than the year 1000, the behavior is
undefined.
- Returns
+<b> Returns</b>
4 The asctime function returns a pointer to the string.
<a name="7.26.3.2" href="#7.26.3.2"><b> 7.26.3.2 The ctime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
char *ctime(const time_t *timer);
- Description
+<b> Description</b>
2 The ctime function converts the calendar time pointed to by timer to local time in the
form of a string. It is equivalent to
asctime(localtime(timer))
[<a name="p389" href="#p389">page 389</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The ctime function returns the pointer returned by the asctime function with that
broken-down time as argument.
Forward references: the localtime function (<a href="#7.26.3.4">7.26.3.4</a>).
<a name="7.26.3.3" href="#7.26.3.3"><b> 7.26.3.3 The gmtime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
struct tm *gmtime(const time_t *timer);
- Description
+<b> Description</b>
2 The gmtime function converts the calendar time pointed to by timer into a broken-
down time, expressed as UTC.
- Returns
+<b> Returns</b>
3 The gmtime function returns a pointer to the broken-down time, or a null pointer if the
specified time cannot be converted to UTC.
<a name="7.26.3.4" href="#7.26.3.4"><b> 7.26.3.4 The localtime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
struct tm *localtime(const time_t *timer);
- Description
+<b> Description</b>
2 The localtime function converts the calendar time pointed to by timer into a
broken-down time, expressed as local time.
- Returns
+<b> Returns</b>
3 The localtime function returns a pointer to the broken-down time, or a null pointer if
the specified time cannot be converted to local time.
<a name="7.26.3.5" href="#7.26.3.5"><b> 7.26.3.5 The strftime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
size_t strftime(char * restrict s,
size_t maxsize,
[<a name="p390" href="#p390">page 390</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The strftime function places characters into the array pointed to by s as controlled by
the string pointed to by format. The format shall be a multibyte character sequence,
beginning and ending in its initial shift state. The format string consists of zero or
%x equivalent to ''%m/%d/%y''.
%X equivalent to %T.
%Z implementation-defined.
- Returns
+<b> Returns</b>
8 If the total number of resulting characters including the terminating null character is not
more than maxsize, the strftime function returns the number of characters placed
into the array pointed to by s not including the terminating null character. Otherwise,
to avoid data races in this case. The implementation behaves as if no library function
calls these functions with a null pointer for ps.
<a name="7.27.1.1" href="#7.27.1.1"><b> 7.27.1.1 The mbrtoc16 function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.27"><uchar.h></a>
size_t mbrtoc16(char16_t * restrict pc16,
const char * restrict s, size_t n,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the mbrtoc16 function is equivalent to the call:
mbrtoc16(NULL, "", 1, ps)
In this case, the values of the parameters pc16 and n are ignored.
store successive wide characters without consuming any additional input until all the
characters have been stored. If the corresponding wide character is the null wide
character, the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The mbrtoc16 function returns the first of the following that applies (given the current
conversion state):
0 if the next n or fewer bytes complete the multibyte character that
value is stored); the value of the macro EILSEQ is stored in errno,
and the conversion state is unspecified.
<a name="7.27.1.2" href="#7.27.1.2"><b> 7.27.1.2 The c16rtomb function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.27"><uchar.h></a>
size_t c16rtomb(char * restrict s, char16_t c16,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the c16rtomb function is equivalent to the call
c16rtomb(buf, L'\0', ps)
where buf is an internal buffer.
array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
c16 is a null wide character, a null byte is stored, preceded by any shift sequence needed
to restore the initial shift state; the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The c16rtomb function returns the number of bytes stored in the array object (including
any shift sequences). When c16 is not a valid wide character, an encoding error occurs:
the function stores the value of the macro EILSEQ in errno and returns
(size_t)(-1); the conversion state is unspecified.
<a name="7.27.1.3" href="#7.27.1.3"><b> 7.27.1.3 The mbrtoc32 function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.27"><uchar.h></a>
size_t mbrtoc32(char32_t * restrict pc32,
const char * restrict s, size_t n,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the mbrtoc32 function is equivalent to the call:
mbrtoc32(NULL, "", 1, ps)
In this case, the values of the parameters pc32 and n are ignored.
store successive wide characters without consuming any additional input until all the
characters have been stored. If the corresponding wide character is the null wide
character, the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The mbrtoc32 function returns the first of the following that applies (given the current
conversion state):
0 if the next n or fewer bytes complete the multibyte character that
value is stored); the value of the macro EILSEQ is stored in errno,
and the conversion state is unspecified.
<a name="7.27.1.4" href="#7.27.1.4"><b> 7.27.1.4 The c32rtomb function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.27"><uchar.h></a>
size_t c32rtomb(char * restrict s, char32_t c32,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the c32rtomb function is equivalent to the call
c32rtomb(buf, L'\0', ps)
where buf is an internal buffer.
array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
c32 is a null wide character, a null byte is stored, preceded by any shift sequence needed
to restore the initial shift state; the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The c32rtomb function returns the number of bytes stored in the array object (including
any shift sequences). When c32 is not a valid wide character, an encoding error occurs:
the function stores the value of the macro EILSEQ in errno and returns
1 The formatted wide character input/output functions shall behave as if there is a sequence
point after the actions associated with each specifier.316)
<a name="7.28.2.1" href="#7.28.2.1"><b> 7.28.2.1 The fwprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
int fwprintf(FILE * restrict stream,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The fwprintf function writes output to the stream pointed to by stream, under
control of the wide string pointed to by format that specifies how subsequent arguments
are converted for output. If there are insufficient arguments for the format, the behavior
adjacent decimal strings L < U, both having DECIMAL_DIG significant digits; the value
of the resultant decimal string D should satisfy L <= D <= U, with the extra stipulation that
the error should have a correct sign for the current rounding direction.
- Returns
+<b> Returns</b>
14 The fwprintf function returns the number of wide characters transmitted, or a negative
value if an output or encoding error occurred.
Forward references: the btowc function (<a href="#7.28.6.1.1">7.28.6.1.1</a>), the mbrtowc function
(<a href="#7.28.6.3.2">7.28.6.3.2</a>).
<a name="7.28.2.2" href="#7.28.2.2"><b> 7.28.2.2 The fwscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
int fwscanf(FILE * restrict stream,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The fwscanf function reads input from the stream pointed to by stream, under
control of the wide string pointed to by format that specifies the admissible input
sequences and how they are to be converted for assignment, using subsequent arguments
15 Trailing white space (including new-line wide characters) is left unread unless matched
by a directive. The success of literal matches and suppressed assignments is not directly
determinable other than via the %n directive.
- Returns
+<b> Returns</b>
16 The fwscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the function returns the
number of input items assigned, which can be fewer than provided for, or even zero, in
wcstol, wcstoll, wcstoul, and wcstoull functions (<a href="#7.28.4.1.2">7.28.4.1.2</a>), the wcrtomb
function (<a href="#7.28.6.3.3">7.28.6.3.3</a>).
<a name="7.28.2.3" href="#7.28.2.3"><b> 7.28.2.3 The swprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int swprintf(wchar_t * restrict s,
size_t n,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The swprintf function is equivalent to fwprintf, except that the argument s
specifies an array of wide characters into which the generated output is to be written,
rather than written to a stream. No more than n wide characters are written, including a
terminating null wide character, which is always added (unless n is zero).
- Returns
+<b> Returns</b>
3 The swprintf function returns the number of wide characters written in the array, not
counting the terminating null wide character, or a negative value if an encoding error
occurred or if n or more wide characters were requested to be written.
<a name="7.28.2.4" href="#7.28.2.4"><b> 7.28.2.4 The swscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int swscanf(const wchar_t * restrict s,
const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The swscanf function is equivalent to fwscanf, except that the argument s specifies a
wide string from which the input is to be obtained, rather than from a stream. Reaching
the end of the wide string is equivalent to encountering end-of-file for the fwscanf
function.
- Returns
+<b> Returns</b>
3 The swscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the swscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
[<a name="p413" href="#p413">page 413</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.2.5" href="#7.28.2.5"><b> 7.28.2.5 The vfwprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
int vfwprintf(FILE * restrict stream,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfwprintf function is equivalent to fwprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfwprintf function does not invoke the
va_end macro.327)
- Returns
+<b> Returns</b>
3 The vfwprintf function returns the number of wide characters transmitted, or a
negative value if an output or encoding error occurred.
4 EXAMPLE The following shows the use of the vfwprintf function in a general error-reporting
[<a name="p414" href="#p414">page 414</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.2.6" href="#7.28.2.6"><b> 7.28.2.6 The vfwscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
int vfwscanf(FILE * restrict stream,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vfwscanf function is equivalent to fwscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfwscanf function does not invoke the
va_end macro.327)
- Returns
+<b> Returns</b>
3 The vfwscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the vfwscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.28.2.7" href="#7.28.2.7"><b> 7.28.2.7 The vswprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
int vswprintf(wchar_t * restrict s,
size_t n,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vswprintf function is equivalent to swprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vswprintf function does not invoke the
va_end macro.327)
- Returns
+<b> Returns</b>
3 The vswprintf function returns the number of wide characters written in the array, not
counting the terminating null wide character, or a negative value if an encoding error
occurred or if n or more wide characters were requested to be generated.
[<a name="p415" href="#p415">page 415</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.2.8" href="#7.28.2.8"><b> 7.28.2.8 The vswscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
int vswscanf(const wchar_t * restrict s,
const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vswscanf function is equivalent to swscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vswscanf function does not invoke the
va_end macro.327)
- Returns
+<b> Returns</b>
3 The vswscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the vswscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.28.2.9" href="#7.28.2.9"><b> 7.28.2.9 The vwprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
int vwprintf(const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vwprintf function is equivalent to wprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vwprintf function does not invoke the
va_end macro.327)
- Returns
+<b> Returns</b>
3 The vwprintf function returns the number of wide characters transmitted, or a negative
value if an output or encoding error occurred.
[<a name="p416" href="#p416">page 416</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.2.10" href="#7.28.2.10"><b> 7.28.2.10 The vwscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
int vwscanf(const wchar_t * restrict format,
va_list arg);
- Description
+<b> Description</b>
2 The vwscanf function is equivalent to wscanf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vwscanf function does not invoke the
va_end macro.327)
- Returns
+<b> Returns</b>
3 The vwscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the vwscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.28.2.11" href="#7.28.2.11"><b> 7.28.2.11 The wprintf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int wprintf(const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The wprintf function is equivalent to fwprintf with the argument stdout
interposed before the arguments to wprintf.
- Returns
+<b> Returns</b>
3 The wprintf function returns the number of wide characters transmitted, or a negative
value if an output or encoding error occurred.
<a name="7.28.2.12" href="#7.28.2.12"><b> 7.28.2.12 The wscanf function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int wscanf(const wchar_t * restrict format, ...);
- Description
+<b> Description</b>
2 The wscanf function is equivalent to fwscanf with the argument stdin interposed
before the arguments to wscanf.
[<a name="p417" href="#p417">page 417</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The wscanf function returns the value of the macro EOF if an input failure occurs
before the first conversion (if any) has completed. Otherwise, the wscanf function
returns the number of input items assigned, which can be fewer than provided for, or even
zero, in the event of an early matching failure.
<a name="7.28.3" href="#7.28.3"><b> 7.28.3 Wide character input/output functions</b></a>
<a name="7.28.3.1" href="#7.28.3.1"><b> 7.28.3.1 The fgetwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
wint_t fgetwc(FILE *stream);
- Description
+<b> Description</b>
2 If the end-of-file indicator for the input stream pointed to by stream is not set and a
next wide character is present, the fgetwc function obtains that wide character as a
wchar_t converted to a wint_t and advances the associated file position indicator for
the stream (if defined).
- Returns
+<b> Returns</b>
3 If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the end-
of-file indicator for the stream is set and the fgetwc function returns WEOF. Otherwise,
the fgetwc function returns the next wide character from the input stream pointed to by
function returns WEOF. If an encoding error occurs (including too few bytes), the value of
the macro EILSEQ is stored in errno and the fgetwc function returns WEOF.328)
<a name="7.28.3.2" href="#7.28.3.2"><b> 7.28.3.2 The fgetws function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
wchar_t *fgetws(wchar_t * restrict s,
int n, FILE * restrict stream);
- Description
+<b> Description</b>
2 The fgetws function reads at most one less than the number of wide characters
specified by n from the stream pointed to by stream into the array pointed to by s. No
additional wide characters are read after a new-line wide character (which is retained) or
after end-of-file. A null wide character is written immediately after the last wide
character read into the array.
- Returns
+<b> Returns</b>
3 The fgetws function returns s if successful. If end-of-file is encountered and no
characters have been read into the array, the contents of the array remain unchanged and a
null pointer is returned. If a read or encoding error occurs during the operation, the array
contents are indeterminate and a null pointer is returned.
<a name="7.28.3.3" href="#7.28.3.3"><b> 7.28.3.3 The fputwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
wint_t fputwc(wchar_t c, FILE *stream);
- Description
+<b> Description</b>
2 The fputwc function writes the wide character specified by c to the output stream
pointed to by stream, at the position indicated by the associated file position indicator
for the stream (if defined), and advances the indicator appropriately. If the file cannot
support positioning requests, or if the stream was opened with append mode, the
character is appended to the output stream.
- Returns
+<b> Returns</b>
3 The fputwc function returns the wide character written. If a write error occurs, the
error indicator for the stream is set and fputwc returns WEOF. If an encoding error
occurs, the value of the macro EILSEQ is stored in errno and fputwc returns WEOF.
<a name="7.28.3.4" href="#7.28.3.4"><b> 7.28.3.4 The fputws function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
int fputws(const wchar_t * restrict s,
FILE * restrict stream);
- Description
+<b> Description</b>
2 The fputws function writes the wide string pointed to by s to the stream pointed to by
stream. The terminating null wide character is not written.
- Returns
+<b> Returns</b>
3 The fputws function returns EOF if a write or encoding error occurs; otherwise, it
returns a nonnegative value.
[<a name="p419" href="#p419">page 419</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.3.5" href="#7.28.3.5"><b> 7.28.3.5 The fwide function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
int fwide(FILE *stream, int mode);
- Description
+<b> Description</b>
2 The fwide function determines the orientation of the stream pointed to by stream. If
mode is greater than zero, the function first attempts to make the stream wide oriented. If
mode is less than zero, the function first attempts to make the stream byte oriented.329)
Otherwise, mode is zero and the function does not alter the orientation of the stream.
- Returns
+<b> Returns</b>
3 The fwide function returns a value greater than zero if, after the call, the stream has
wide orientation, a value less than zero if the stream has byte orientation, or zero if the
stream has no orientation.
<a name="7.28.3.6" href="#7.28.3.6"><b> 7.28.3.6 The getwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
wint_t getwc(FILE *stream);
- Description
+<b> Description</b>
2 The getwc function is equivalent to fgetwc, except that if it is implemented as a
macro, it may evaluate stream more than once, so the argument should never be an
expression with side effects.
- Returns
+<b> Returns</b>
3 The getwc function returns the next wide character from the input stream pointed to by
stream, or WEOF.
<a name="7.28.3.7" href="#7.28.3.7"><b> 7.28.3.7 The getwchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wint_t getwchar(void);
[<a name="p420" href="#p420">page 420</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The getwchar function is equivalent to getwc with the argument stdin.
- Returns
+<b> Returns</b>
3 The getwchar function returns the next wide character from the input stream pointed to
by stdin, or WEOF.
<a name="7.28.3.8" href="#7.28.3.8"><b> 7.28.3.8 The putwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
wint_t putwc(wchar_t c, FILE *stream);
- Description
+<b> Description</b>
2 The putwc function is equivalent to fputwc, except that if it is implemented as a
macro, it may evaluate stream more than once, so that argument should never be an
expression with side effects.
- Returns
+<b> Returns</b>
3 The putwc function returns the wide character written, or WEOF.
<a name="7.28.3.9" href="#7.28.3.9"><b> 7.28.3.9 The putwchar function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wint_t putwchar(wchar_t c);
- Description
+<b> Description</b>
2 The putwchar function is equivalent to putwc with the second argument stdout.
- Returns
+<b> Returns</b>
3 The putwchar function returns the character written, or WEOF.
<a name="7.28.3.10" href="#7.28.3.10"><b> 7.28.3.10 The ungetwc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
wint_t ungetwc(wint_t c, FILE *stream);
- Description
+<b> Description</b>
2 The ungetwc function pushes the wide character specified by c back onto the input
stream pointed to by stream. Pushed-back wide characters will be returned by
subsequent reads on that stream in the reverse order of their pushing. A successful
back. For a text or binary stream, the value of its file position indicator after a successful
call to the ungetwc function is unspecified until all pushed-back wide characters are
read or discarded.
- Returns
+<b> Returns</b>
6 The ungetwc function returns the wide character pushed back, or WEOF if the operation
fails.
<a name="7.28.4" href="#7.28.4"><b> 7.28.4 General wide string utilities</b></a>
<a name="7.28.4.1" href="#7.28.4.1"><b> 7.28.4.1 Wide string numeric conversion functions</b></a>
<a name="7.28.4.1.1" href="#7.28.4.1.1"><b> 7.28.4.1.1 The wcstod, wcstof, and wcstold functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
double wcstod(const wchar_t * restrict nptr,
wchar_t ** restrict endptr);
wchar_t ** restrict endptr);
long double wcstold(const wchar_t * restrict nptr,
wchar_t ** restrict endptr);
- Description
+<b> Description</b>
2 The wcstod, wcstof, and wcstold functions convert the initial portion of the wide
string pointed to by nptr to double, float, and long double representation,
respectively. First, they decompose the input string into three parts: an initial, possibly
correctly rounding L and U according to the current rounding direction, with the extra
stipulation that the error with respect to D should have a correct sign for the current
rounding direction.332)
- Returns
+<b> Returns</b>
10 The functions return the converted value, if any. If no conversion could be performed,
zero is returned. If the correct value overflows and default rounding is in effect (<a href="#7.12.1">7.12.1</a>),
plus or minus HUGE_VAL, HUGE_VALF, or HUGE_VALL is returned (according to the
[<a name="p425" href="#p425">page 425</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.4.1.2" href="#7.28.4.1.2"><b> 7.28.4.1.2 The wcstol, wcstoll, wcstoul, and wcstoull functions</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
long int wcstol(
const wchar_t * restrict nptr,
const wchar_t * restrict nptr,
wchar_t ** restrict endptr,
int base);
- Description
+<b> Description</b>
2 The wcstol, wcstoll, wcstoul, and wcstoull functions convert the initial
portion of the wide string pointed to by nptr to long int, long long int,
unsigned long int, and unsigned long long int representation,
7 If the subject sequence is empty or does not have the expected form, no conversion is
performed; the value of nptr is stored in the object pointed to by endptr, provided
that endptr is not a null pointer.
- Returns
+<b> Returns</b>
8 The wcstol, wcstoll, wcstoul, and wcstoull functions return the converted
value, if any. If no conversion could be performed, zero is returned. If the correct value
is outside the range of representable values, LONG_MIN, LONG_MAX, LLONG_MIN,
sign of the value, if any), and the value of the macro ERANGE is stored in errno.
<a name="7.28.4.2" href="#7.28.4.2"><b> 7.28.4.2 Wide string copying functions</b></a>
<a name="7.28.4.2.1" href="#7.28.4.2.1"><b> 7.28.4.2.1 The wcscpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcscpy(wchar_t * restrict s1,
const wchar_t * restrict s2);
- Description
+<b> Description</b>
2 The wcscpy function copies the wide string pointed to by s2 (including the terminating
null wide character) into the array pointed to by s1.
- Returns
+<b> Returns</b>
3 The wcscpy function returns the value of s1.
[<a name="p427" href="#p427">page 427</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.4.2.2" href="#7.28.4.2.2"><b> 7.28.4.2.2 The wcsncpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcsncpy(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsncpy function copies not more than n wide characters (those that follow a null
wide character are not copied) from the array pointed to by s2 to the array pointed to by
s1.333)
3 If the array pointed to by s2 is a wide string that is shorter than n wide characters, null
wide characters are appended to the copy in the array pointed to by s1, until n wide
characters in all have been written.
- Returns
+<b> Returns</b>
4 The wcsncpy function returns the value of s1.
<a name="7.28.4.2.3" href="#7.28.4.2.3"><b> 7.28.4.2.3 The wmemcpy function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wmemcpy(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wmemcpy function copies n wide characters from the object pointed to by s2 to the
object pointed to by s1.
- Returns
+<b> Returns</b>
3 The wmemcpy function returns the value of s1.
[<a name="p428" href="#p428">page 428</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.4.2.4" href="#7.28.4.2.4"><b> 7.28.4.2.4 The wmemmove function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wmemmove(wchar_t *s1, const wchar_t *s2,
size_t n);
- Description
+<b> Description</b>
2 The wmemmove function copies n wide characters from the object pointed to by s2 to
the object pointed to by s1. Copying takes place as if the n wide characters from the
object pointed to by s2 are first copied into a temporary array of n wide characters that
does not overlap the objects pointed to by s1 or s2, and then the n wide characters from
the temporary array are copied into the object pointed to by s1.
- Returns
+<b> Returns</b>
3 The wmemmove function returns the value of s1.
<a name="7.28.4.3" href="#7.28.4.3"><b> 7.28.4.3 Wide string concatenation functions</b></a>
<a name="7.28.4.3.1" href="#7.28.4.3.1"><b> 7.28.4.3.1 The wcscat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcscat(wchar_t * restrict s1,
const wchar_t * restrict s2);
- Description
+<b> Description</b>
2 The wcscat function appends a copy of the wide string pointed to by s2 (including the
terminating null wide character) to the end of the wide string pointed to by s1. The initial
wide character of s2 overwrites the null wide character at the end of s1.
- Returns
+<b> Returns</b>
3 The wcscat function returns the value of s1.
<a name="7.28.4.3.2" href="#7.28.4.3.2"><b> 7.28.4.3.2 The wcsncat function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcsncat(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsncat function appends not more than n wide characters (a null wide character
and those that follow it are not appended) from the array pointed to by s2 to the end of
the wide string pointed to by s1. The initial wide character of s2 overwrites the null
wide character at the end of s1. A terminating null wide character is always appended to
the result.334)
- Returns
+<b> Returns</b>
3 The wcsncat function returns the value of s1.
<a name="7.28.4.4" href="#7.28.4.4"><b> 7.28.4.4 Wide string comparison functions</b></a>
1 Unless explicitly stated otherwise, the functions described in this subclause order two
wide characters the same way as two integers of the underlying integer type designated
by wchar_t.
<a name="7.28.4.4.1" href="#7.28.4.4.1"><b> 7.28.4.4.1 The wcscmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int wcscmp(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcscmp function compares the wide string pointed to by s1 to the wide string
pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcscmp function returns an integer greater than, equal to, or less than zero,
accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the
wide string pointed to by s2.
<a name="7.28.4.4.2" href="#7.28.4.4.2"><b> 7.28.4.4.2 The wcscoll function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int wcscoll(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcscoll function compares the wide string pointed to by s1 to the wide string
pointed to by s2, both interpreted as appropriate to the LC_COLLATE category of the
current locale.
- Returns
+<b> Returns</b>
3 The wcscoll function returns an integer greater than, equal to, or less than zero,
accordingly as the wide string pointed to by s1 is greater than, equal to, or less than the
wide string pointed to by s2 when both are interpreted as appropriate to the current
locale.
<a name="7.28.4.4.3" href="#7.28.4.4.3"><b> 7.28.4.4.3 The wcsncmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int wcsncmp(const wchar_t *s1, const wchar_t *s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsncmp function compares not more than n wide characters (those that follow a
null wide character are not compared) from the array pointed to by s1 to the array
pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcsncmp function returns an integer greater than, equal to, or less than zero,
accordingly as the possibly null-terminated array pointed to by s1 is greater than, equal
to, or less than the possibly null-terminated array pointed to by s2.
<a name="7.28.4.4.4" href="#7.28.4.4.4"><b> 7.28.4.4.4 The wcsxfrm function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t wcsxfrm(wchar_t * restrict s1,
const wchar_t * restrict s2,
size_t n);
- Description
+<b> Description</b>
2 The wcsxfrm function transforms the wide string pointed to by s2 and places the
resulting wide string into the array pointed to by s1. The transformation is such that if
the wcscmp function is applied to two transformed wide strings, it returns a value greater
applied to the same two original wide strings. No more than n wide characters are placed
into the resulting array pointed to by s1, including the terminating null wide character. If
n is zero, s1 is permitted to be a null pointer.
- Returns
+<b> Returns</b>
3 The wcsxfrm function returns the length of the transformed wide string (not including
the terminating null wide character). If the value returned is n or greater, the contents of
the array pointed to by s1 are indeterminate.
1 + wcsxfrm(NULL, s, 0)
<a name="7.28.4.4.5" href="#7.28.4.4.5"><b> 7.28.4.4.5 The wmemcmp function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int wmemcmp(const wchar_t *s1, const wchar_t *s2,
size_t n);
- Description
+<b> Description</b>
2 The wmemcmp function compares the first n wide characters of the object pointed to by
s1 to the first n wide characters of the object pointed to by s2.
- Returns
+<b> Returns</b>
3 The wmemcmp function returns an integer greater than, equal to, or less than zero,
accordingly as the object pointed to by s1 is greater than, equal to, or less than the object
pointed to by s2.
<a name="7.28.4.5" href="#7.28.4.5"><b> 7.28.4.5 Wide string search functions</b></a>
<a name="7.28.4.5.1" href="#7.28.4.5.1"><b> 7.28.4.5.1 The wcschr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcschr(const wchar_t *s, wchar_t c);
- Description
+<b> Description</b>
2 The wcschr function locates the first occurrence of c in the wide string pointed to by s.
The terminating null wide character is considered to be part of the wide string.
- Returns
+<b> Returns</b>
3 The wcschr function returns a pointer to the located wide character, or a null pointer if
the wide character does not occur in the wide string.
<a name="7.28.4.5.2" href="#7.28.4.5.2"><b> 7.28.4.5.2 The wcscspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t wcscspn(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcscspn function computes the length of the maximum initial segment of the wide
string pointed to by s1 which consists entirely of wide characters not from the wide
string pointed to by s2.
[<a name="p432" href="#p432">page 432</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The wcscspn function returns the length of the segment.
<a name="7.28.4.5.3" href="#7.28.4.5.3"><b> 7.28.4.5.3 The wcspbrk function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcspbrk(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcspbrk function locates the first occurrence in the wide string pointed to by s1 of
any wide character from the wide string pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcspbrk function returns a pointer to the wide character in s1, or a null pointer if
no wide character from s2 occurs in s1.
<a name="7.28.4.5.4" href="#7.28.4.5.4"><b> 7.28.4.5.4 The wcsrchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
- Description
+<b> Description</b>
2 The wcsrchr function locates the last occurrence of c in the wide string pointed to by
s. The terminating null wide character is considered to be part of the wide string.
- Returns
+<b> Returns</b>
3 The wcsrchr function returns a pointer to the wide character, or a null pointer if c does
not occur in the wide string.
<a name="7.28.4.5.5" href="#7.28.4.5.5"><b> 7.28.4.5.5 The wcsspn function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t wcsspn(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcsspn function computes the length of the maximum initial segment of the wide
string pointed to by s1 which consists entirely of wide characters from the wide string
pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcsspn function returns the length of the segment.
[<a name="p433" href="#p433">page 433</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.4.5.6" href="#7.28.4.5.6"><b> 7.28.4.5.6 The wcsstr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcsstr(const wchar_t *s1, const wchar_t *s2);
- Description
+<b> Description</b>
2 The wcsstr function locates the first occurrence in the wide string pointed to by s1 of
the sequence of wide characters (excluding the terminating null wide character) in the
wide string pointed to by s2.
- Returns
+<b> Returns</b>
3 The wcsstr function returns a pointer to the located wide string, or a null pointer if the
wide string is not found. If s2 points to a wide string with zero length, the function
returns s1.
<a name="7.28.4.5.7" href="#7.28.4.5.7"><b> 7.28.4.5.7 The wcstok function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wcstok(wchar_t * restrict s1,
const wchar_t * restrict s2,
wchar_t ** restrict ptr);
- Description
+<b> Description</b>
2 A sequence of calls to the wcstok function breaks the wide string pointed to by s1 into
a sequence of tokens, each of which is delimited by a wide character from the wide string
pointed to by s2. The third argument points to a caller-provided wchar_t pointer into
by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
value for ptr, shall start searching just past the element overwritten by a null wide
character (if any).
- Returns
+<b> Returns</b>
7 The wcstok function returns a pointer to the first wide character of a token, or a null
pointer if there is no token.
8 EXAMPLE
t = wcstok(NULL, L"?", &ptr1); // t is a null pointer
<a name="7.28.4.5.8" href="#7.28.4.5.8"><b> 7.28.4.5.8 The wmemchr function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wmemchr(const wchar_t *s, wchar_t c,
size_t n);
- Description
+<b> Description</b>
2 The wmemchr function locates the first occurrence of c in the initial n wide characters of
the object pointed to by s.
- Returns
+<b> Returns</b>
3 The wmemchr function returns a pointer to the located wide character, or a null pointer if
the wide character does not occur in the object.
<a name="7.28.4.6" href="#7.28.4.6"><b> 7.28.4.6 Miscellaneous functions</b></a>
<a name="7.28.4.6.1" href="#7.28.4.6.1"><b> 7.28.4.6.1 The wcslen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t wcslen(const wchar_t *s);
- Description
+<b> Description</b>
2 The wcslen function computes the length of the wide string pointed to by s.
- Returns
+<b> Returns</b>
3 The wcslen function returns the number of wide characters that precede the terminating
null wide character.
<a name="7.28.4.6.2" href="#7.28.4.6.2"><b> 7.28.4.6.2 The wmemset function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
wchar_t *wmemset(wchar_t *s, wchar_t c, size_t n);
- Description
+<b> Description</b>
2 The wmemset function copies the value of c into each of the first n wide characters of
the object pointed to by s.
- Returns
+<b> Returns</b>
3 The wmemset function returns the value of s.
<a name="7.28.5" href="#7.28.5"><b> 7.28.5 Wide character time conversion functions</b></a>
<a name="7.28.5.1" href="#7.28.5.1"><b> 7.28.5.1 The wcsftime function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.26"><time.h></a>
#include <a href="#7.28"><wchar.h></a>
size_t wcsftime(wchar_t * restrict s,
size_t maxsize,
const wchar_t * restrict format,
const struct tm * restrict timeptr);
- Description
+<b> Description</b>
2 The wcsftime function is equivalent to the strftime function, except that:
-- The argument s points to the initial element of an array of wide characters into which
the generated output is to be placed.
-- The argument format is a wide string and the conversion specifiers are replaced by
corresponding sequences of wide characters.
-- The return value indicates the number of wide characters.
- Returns
+<b> Returns</b>
3 If the total number of resulting wide characters including the terminating null wide
character is not more than maxsize, the wcsftime function returns the number of
wide characters placed into the array pointed to by s not including the terminating null
<a name="7.28.6.1" href="#7.28.6.1"><b> 7.28.6.1 Single-byte/wide character conversion functions</b></a>
<a name="7.28.6.1.1" href="#7.28.6.1.1"><b> 7.28.6.1.1 The btowc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a> *
wint_t btowc(int c);
- Description
+<b> Description</b>
2 The btowc function determines whether c constitutes a valid single-byte character in the
initial shift state.
- Returns
+<b> Returns</b>
3 The btowc function returns WEOF if c has the value EOF or if (unsigned char)c
does not constitute a valid single-byte character in the initial shift state. Otherwise, it
returns the wide character representation of that character.
<a name="7.28.6.1.2" href="#7.28.6.1.2"><b> 7.28.6.1.2 The wctob function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a> *
int wctob(wint_t c);
- Description
+<b> Description</b>
2 The wctob function determines whether c corresponds to a member of the extended
character set whose multibyte character representation is a single byte when in the initial
shift state.
- Returns
+<b> Returns</b>
3 The wctob function returns EOF if c does not correspond to a multibyte character with
length one in the initial shift state. Otherwise, it returns the single-byte representation of
that character as an unsigned char converted to an int.
<a name="7.28.6.2" href="#7.28.6.2"><b> 7.28.6.2 Conversion state functions</b></a>
<a name="7.28.6.2.1" href="#7.28.6.2.1"><b> 7.28.6.2.1 The mbsinit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
int mbsinit(const mbstate_t *ps);
- Description
+<b> Description</b>
2 If ps is not a null pointer, the mbsinit function determines whether the referenced
mbstate_t object describes an initial conversion state.
[<a name="p438" href="#p438">page 438</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
3 The mbsinit function returns nonzero if ps is a null pointer or if the referenced object
describes an initial conversion state; otherwise, it returns zero.
<a name="7.28.6.3" href="#7.28.6.3"><b> 7.28.6.3 Restartable multibyte/wide character conversion functions</b></a>
2 Also unlike their corresponding functions, the return value does not represent whether the
encoding is state-dependent.
<a name="7.28.6.3.1" href="#7.28.6.3.1"><b> 7.28.6.3.1 The mbrlen function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t mbrlen(const char * restrict s,
size_t n,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 The mbrlen function is equivalent to the call:
mbrtowc(NULL, s, n, ps != NULL ? ps : &internal)
where internal is the mbstate_t object for the mbrlen function, except that the
expression designated by ps is evaluated only once.
- Returns
+<b> Returns</b>
3 The mbrlen function returns a value between zero and n, inclusive, (size_t)(-2),
or (size_t)(-1).
Forward references: the mbrtowc function (<a href="#7.28.6.3.2">7.28.6.3.2</a>).
[<a name="p439" href="#p439">page 439</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.6.3.2" href="#7.28.6.3.2"><b> 7.28.6.3.2 The mbrtowc function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t mbrtowc(wchar_t * restrict pwc,
const char * restrict s,
size_t n,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the mbrtowc function is equivalent to the call:
mbrtowc(NULL, "", 1, ps)
In this case, the values of the parameters pwc and n are ignored.
corresponding wide character and then, if pwc is not a null pointer, stores that value in
the object pointed to by pwc. If the corresponding wide character is the null wide
character, the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The mbrtowc function returns the first of the following that applies (given the current
conversion state):
0 if the next n or fewer bytes complete the multibyte character that
[<a name="p440" href="#p440">page 440</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.6.3.3" href="#7.28.6.3.3"><b> 7.28.6.3.3 The wcrtomb function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t wcrtomb(char * restrict s,
wchar_t wc,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 If s is a null pointer, the wcrtomb function is equivalent to the call
wcrtomb(buf, L'\0', ps)
where buf is an internal buffer.
array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If
wc is a null wide character, a null byte is stored, preceded by any shift sequence needed
to restore the initial shift state; the resulting state described is the initial conversion state.
- Returns
+<b> Returns</b>
4 The wcrtomb function returns the number of bytes stored in the array object (including
any shift sequences). When wc is not a valid wide character, an encoding error occurs:
the function stores the value of the macro EILSEQ in errno and returns
[<a name="p441" href="#p441">page 441</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.6.4.1" href="#7.28.6.4.1"><b> 7.28.6.4.1 The mbsrtowcs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t mbsrtowcs(wchar_t * restrict dst,
const char ** restrict src,
size_t len,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 The mbsrtowcs function converts a sequence of multibyte characters that begins in the
conversion state described by the object pointed to by ps, from the array indirectly
pointed to by src into a sequence of corresponding wide characters. If dst is not a null
just past the last multibyte character converted (if any). If conversion stopped due to
reaching a terminating null character and if dst is not a null pointer, the resulting state
described is the initial conversion state.
- Returns
+<b> Returns</b>
4 If the input conversion encounters a sequence of bytes that do not form a valid multibyte
character, an encoding error occurs: the mbsrtowcs function stores the value of the
macro EILSEQ in errno and returns (size_t)(-1); the conversion state is
[<a name="p442" href="#p442">page 442</a>] (<a href="#Contents">Contents</a>)
<a name="7.28.6.4.2" href="#7.28.6.4.2"><b> 7.28.6.4.2 The wcsrtombs function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.28"><wchar.h></a>
size_t wcsrtombs(char * restrict dst,
const wchar_t ** restrict src,
size_t len,
mbstate_t * restrict ps);
- Description
+<b> Description</b>
2 The wcsrtombs function converts a sequence of wide characters from the array
indirectly pointed to by src into a sequence of corresponding multibyte characters that
begins in the conversion state described by the object pointed to by ps. If dst is not a
address just past the last wide character converted (if any). If conversion stopped due to
reaching a terminating null wide character, the resulting state described is the initial
conversion state.
- Returns
+<b> Returns</b>
4 If conversion stops because a wide character is reached that does not correspond to a
valid multibyte character, an encoding error occurs: the wcsrtombs function stores the
value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion
both printing and white-space wide characters.340)
Forward references: the wctob function (<a href="#7.28.6.1.2">7.28.6.1.2</a>).
<a name="7.29.2.1.1" href="#7.29.2.1.1"><b> 7.29.2.1.1 The iswalnum function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswalnum(wint_t wc);
- Description
+<b> Description</b>
2 The iswalnum function tests for any wide character for which iswalpha or
iswdigit is true.
<a name="7.29.2.1.2" href="#7.29.2.1.2"><b> 7.29.2.1.2 The iswalpha function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswalpha(wint_t wc);
- Description
+<b> Description</b>
2 The iswalpha function tests for any wide character for which iswupper or
iswlower is true, or any wide character that is one of a locale-specific set of alphabetic
wide characters for which none of iswcntrl, iswdigit, iswpunct, or iswspace
is true.341)
<a name="7.29.2.1.3" href="#7.29.2.1.3"><b> 7.29.2.1.3 The iswblank function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswblank(wint_t wc);
- Description
+<b> Description</b>
2 The iswblank function tests for any wide character that is a standard blank wide
character or is one of a locale-specific set of wide characters for which iswspace is true
and that is used to separate words within a line of text. The standard blank wide
characters are the following: space (L' '), and horizontal tab (L'\t'). In the "C"
locale, iswblank returns true only for the standard blank characters.
<a name="7.29.2.1.4" href="#7.29.2.1.4"><b> 7.29.2.1.4 The iswcntrl function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswcntrl(wint_t wc);
- Description
+<b> Description</b>
2 The iswcntrl function tests for any control wide character.
<a name="7.29.2.1.5" href="#7.29.2.1.5"><b> 7.29.2.1.5 The iswdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswdigit(wint_t wc);
- Description
+<b> Description</b>
2 The iswdigit function tests for any wide character that corresponds to a decimal-digit
character (as defined in <a href="#5.2.1">5.2.1</a>).
<a name="7.29.2.1.6" href="#7.29.2.1.6"><b> 7.29.2.1.6 The iswgraph function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswgraph(wint_t wc);
[<a name="p446" href="#p446">page 446</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The iswgraph function tests for any wide character for which iswprint is true and
iswspace is false.342)
<a name="7.29.2.1.7" href="#7.29.2.1.7"><b> 7.29.2.1.7 The iswlower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswlower(wint_t wc);
- Description
+<b> Description</b>
2 The iswlower function tests for any wide character that corresponds to a lowercase
letter or is one of a locale-specific set of wide characters for which none of iswcntrl,
iswdigit, iswpunct, or iswspace is true.
<a name="7.29.2.1.8" href="#7.29.2.1.8"><b> 7.29.2.1.8 The iswprint function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswprint(wint_t wc);
- Description
+<b> Description</b>
2 The iswprint function tests for any printing wide character.
<a name="7.29.2.1.9" href="#7.29.2.1.9"><b> 7.29.2.1.9 The iswpunct function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswpunct(wint_t wc);
- Description
+<b> Description</b>
2 The iswpunct function tests for any printing wide character that is one of a locale-
specific set of punctuation wide characters for which neither iswspace nor iswalnum
is true.342)
<a name="7.29.2.1.10" href="#7.29.2.1.10"><b> 7.29.2.1.10 The iswspace function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswspace(wint_t wc);
[<a name="p447" href="#p447">page 447</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
2 The iswspace function tests for any wide character that corresponds to a locale-specific
set of white-space wide characters for which none of iswalnum, iswgraph, or
iswpunct is true.
<a name="7.29.2.1.11" href="#7.29.2.1.11"><b> 7.29.2.1.11 The iswupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswupper(wint_t wc);
- Description
+<b> Description</b>
2 The iswupper function tests for any wide character that corresponds to an uppercase
letter or is one of a locale-specific set of wide characters for which none of iswcntrl,
iswdigit, iswpunct, or iswspace is true.
<a name="7.29.2.1.12" href="#7.29.2.1.12"><b> 7.29.2.1.12 The iswxdigit function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswxdigit(wint_t wc);
- Description
+<b> Description</b>
2 The iswxdigit function tests for any wide character that corresponds to a
hexadecimal-digit character (as defined in <a href="#6.4.4.1">6.4.4.1</a>).
<a name="7.29.2.2" href="#7.29.2.2"><b> 7.29.2.2 Extensible wide character classification functions</b></a>
as well as testing equivalent to that performed by the functions described in the previous
subclause (<a href="#7.29.2.1">7.29.2.1</a>).
<a name="7.29.2.2.1" href="#7.29.2.2.1"><b> 7.29.2.2.1 The iswctype function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
int iswctype(wint_t wc, wctype_t desc);
- Description
+<b> Description</b>
2 The iswctype function determines whether the wide character wc has the property
described by desc. The current setting of the LC_CTYPE category shall be the same as
during the call to wctype that returned the value desc.
iswctype(wc, wctype("space")) // iswspace(wc)
iswctype(wc, wctype("upper")) // iswupper(wc)
iswctype(wc, wctype("xdigit")) // iswxdigit(wc)
- Returns
+<b> Returns</b>
4 The iswctype function returns nonzero (true) if and only if the value of the wide
character wc has the property described by desc. If desc is zero, the iswctype
function returns zero (false).
Forward references: the wctype function (<a href="#7.29.2.2.2">7.29.2.2.2</a>).
<a name="7.29.2.2.2" href="#7.29.2.2.2"><b> 7.29.2.2.2 The wctype function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
wctype_t wctype(const char *property);
- Description
+<b> Description</b>
2 The wctype function constructs a value with type wctype_t that describes a class of
wide characters identified by the string argument property.
3 The strings listed in the description of the iswctype function shall be valid in all
locales as property arguments to the wctype function.
- Returns
+<b> Returns</b>
4 If property identifies a valid class of wide characters according to the LC_CTYPE
category of the current locale, the wctype function returns a nonzero value that is valid
as the second argument to the iswctype function; otherwise, it returns zero.
1 The header <a href="#7.29"><wctype.h></a> declares several functions useful for mapping wide characters.
<a name="7.29.3.1" href="#7.29.3.1"><b> 7.29.3.1 Wide character case mapping functions</b></a>
<a name="7.29.3.1.1" href="#7.29.3.1.1"><b> 7.29.3.1.1 The towlower function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
wint_t towlower(wint_t wc);
- Description
+<b> Description</b>
2 The towlower function converts an uppercase letter to a corresponding lowercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a wide character for which iswupper is true and there are one or
more corresponding wide characters, as specified by the current locale, for which
iswlower is true, the towlower function returns one of the corresponding wide
characters (always the same one for any given locale); otherwise, the argument is
returned unchanged.
<a name="7.29.3.1.2" href="#7.29.3.1.2"><b> 7.29.3.1.2 The towupper function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
wint_t towupper(wint_t wc);
- Description
+<b> Description</b>
2 The towupper function converts a lowercase letter to a corresponding uppercase letter.
- Returns
+<b> Returns</b>
3 If the argument is a wide character for which iswlower is true and there are one or
more corresponding wide characters, as specified by the current locale, for which
iswupper is true, the towupper function returns one of the corresponding wide
[<a name="p450" href="#p450">page 450</a>] (<a href="#Contents">Contents</a>)
<a name="7.29.3.2.1" href="#7.29.3.2.1"><b> 7.29.3.2.1 The towctrans function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
wint_t towctrans(wint_t wc, wctrans_t desc);
- Description
+<b> Description</b>
2 The towctrans function maps the wide character wc using the mapping described by
desc. The current setting of the LC_CTYPE category shall be the same as during the call
to wctrans that returned the value desc.
mapping function (<a href="#7.29.3.1">7.29.3.1</a>) in the comment that follows the expression:
towctrans(wc, wctrans("tolower")) // towlower(wc)
towctrans(wc, wctrans("toupper")) // towupper(wc)
- Returns
+<b> Returns</b>
4 The towctrans function returns the mapped value of wc using the mapping described
by desc. If desc is zero, the towctrans function returns the value of wc.
<a name="7.29.3.2.2" href="#7.29.3.2.2"><b> 7.29.3.2.2 The wctrans function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.29"><wctype.h></a>
wctrans_t wctrans(const char *property);
- Description
+<b> Description</b>
2 The wctrans function constructs a value with type wctrans_t that describes a
mapping between wide characters identified by the string argument property.
3 The strings listed in the description of the towctrans function shall be valid in all
locales as property arguments to the wctrans function.
- Returns
+<b> Returns</b>
4 If property identifies a valid mapping of wide characters according to the LC_CTYPE
category of the current locale, the wctrans function returns a nonzero value that is valid
as the second argument to the towctrans function; otherwise, it returns zero.
[<a name="p529" href="#p529">page 529</a>] (<a href="#Contents">Contents</a>)
<a name="G.5.1" href="#G.5.1"><b> G.5.1 Multiplicative operators</b></a>
- Semantics
+<b> Semantics</b>
1 If one operand has real type and the other operand has imaginary type, then the result has
imaginary type. If both operands have imaginary type, then the result has real type. (If
either operand has complex type, then the result has complex type.)
with division, provides better roundoff characteristics.
<a name="G.5.2" href="#G.5.2"><b> G.5.2 Additive operators</b></a>
- Semantics
+<b> Semantics</b>
1 If both operands have imaginary type, then the result has imaginary type. (If one operand
has real type and the other operand has imaginary type, or if either operand has complex
type, then the result has complex type.)
which is the type size_t.
<a name="K.3.5.1" href="#K.3.5.1"><b> K.3.5.1 Operations on files</b></a>
<a name="K.3.5.1.1" href="#K.3.5.1.1"><b> K.3.5.1.1 The tmpfile_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
errno_t tmpfile_s(FILE * restrict * restrict streamptr);
Runtime-constraints
2 streamptr shall not be a null pointer.
3 If there is a runtime-constraint violation, tmpfile_s does not attempt to create a file.
- Description
+<b> Description</b>
4 The tmpfile_s function creates a temporary binary file that is different from any other
existing file and that will automatically be removed when it is closed or at program
termination. If the program terminates abnormally, whether an open temporary file is
the program (this limit may be shared with tmpnam_s) and there should be no limit on
the number simultaneously open other than this limit and any limit on the number of open
files (FOPEN_MAX).
- Returns
+<b> Returns</b>
6 The tmpfile_s function returns zero if it created the file. If it did not create the file or
there was a runtime-constraint violation, tmpfile_s returns a nonzero value.
<a name="K.3.5.1.2" href="#K.3.5.1.2"><b> K.3.5.1.2 The tmpnam_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
errno_t tmpnam_s(char *s, rsize_t maxsize);
Runtime-constraints
2 s shall not be a null pointer. maxsize shall be less than or equal to RSIZE_MAX.
maxsize shall be greater than the length of the generated file name string.
- Description
+<b> Description</b>
3 The tmpnam_s function generates a string that is a valid file name and that is not the
same as the name of an existing file.374) The function is potentially capable of generating
TMP_MAX_S different strings, but any or all of them may already be in use by existing
should be used instead of tmpnam_s when possible. One situation that requires the use
of the tmpnam_s function is when the program needs to create a temporary directory
rather than a temporary file.
- Returns
+<b> Returns</b>
8 If no suitable string can be generated, or if there is a runtime-constraint violation, the
tmpnam_s function writes a null character to s[0] (only if s is not null and maxsize
is greater than zero) and returns a nonzero value.
10 The value of the macro TMP_MAX_S shall be at least 25.
<a name="K.3.5.2" href="#K.3.5.2"><b> K.3.5.2 File access functions</b></a>
<a name="K.3.5.2.1" href="#K.3.5.2.1"><b> K.3.5.2.1 The fopen_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
errno_t fopen_s(FILE * restrict * restrict streamptr,
[<a name="p584" href="#p584">page 584</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
4 The fopen_s function opens the file whose name is the string pointed to by
filename, and associates a stream with it.
5 The mode string shall be as described for fopen, with the addition that modes starting
[<a name="p585" href="#p585">page 585</a>] (<a href="#Contents">Contents</a>)
to FILE pointed to by streamptr will be set to a null pointer.
- Returns
+<b> Returns</b>
9 The fopen_s function returns zero if it opened the file. If it did not open the file or if
there was a runtime-constraint violation, fopen_s returns a nonzero value.
<a name="K.3.5.2.2" href="#K.3.5.2.2"><b> K.3.5.2.2 The freopen_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
errno_t freopen_s(FILE * restrict * restrict newstreamptr,
3 If there is a runtime-constraint violation, freopen_s neither attempts to close any file
associated with stream nor attempts to open a file. Furthermore, if newstreamptr is
not a null pointer, fopen_s sets *newstreamptr to the null pointer.
- Description
+<b> Description</b>
4 The freopen_s function opens the file whose name is the string pointed to by
filename and associates the stream pointed to by stream with it. The mode
argument has the same meaning as in the fopen_s function (including the mode's effect
7 If the file was opened successfully, then the pointer to FILE pointed to by
newstreamptr will be set to the value of stream. Otherwise, the pointer to FILE
pointed to by newstreamptr will be set to a null pointer.
- Returns
+<b> Returns</b>
8 The freopen_s function returns zero if it opened the file. If it did not open the file or
there was a runtime-constraint violation, freopen_s returns a nonzero value.
subclause causes copying to take place between objects that overlap, the objects take on
unspecified values.
<a name="K.3.5.3.1" href="#K.3.5.3.1"><b> K.3.5.3.1 The fprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int fprintf_s(FILE * restrict stream,
3 If there is a runtime-constraint violation,378) the fprintf_s function does not attempt
to produce further output, and it is unspecified to what extent fprintf_s produced
output before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The fprintf_s function is equivalent to the fprintf function except for the explicit
runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The fprintf_s function returns the number of characters transmitted, or a negative
value if an output error, encoding error, or runtime-constraint violation occurred.
[<a name="p587" href="#p587">page 587</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.5.3.2" href="#K.3.5.3.2"><b> K.3.5.3.2 The fscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int fscanf_s(FILE * restrict stream,
3 If there is a runtime-constraint violation,379) the fscanf_s function does not attempt to
perform further input, and it is unspecified to what extent fscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The fscanf_s function is equivalent to fscanf except that the c, s, and [ conversion
specifiers apply to a pair of arguments (unless assignment suppression is indicated by a
*). The first of these arguments is the same as for fscanf. That argument is
one element.380)
5 A matching failure occurs if the number of elements in a receiving object is insufficient to
hold the converted input (including any trailing null character).
- Returns
+<b> Returns</b>
6 The fscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
array of six characters to store it.
<a name="K.3.5.3.3" href="#K.3.5.3.3"><b> K.3.5.3.3 The printf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int printf_s(const char * restrict format, ...);
[<a name="p589" href="#p589">page 589</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
4 The printf_s function is equivalent to the printf function except for the explicit
runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The printf_s function returns the number of characters transmitted, or a negative
value if an output error, encoding error, or runtime-constraint violation occurred.
<a name="K.3.5.3.4" href="#K.3.5.3.4"><b> K.3.5.3.4 The scanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int scanf_s(const char * restrict format, ...);
3 If there is a runtime-constraint violation, the scanf_s function does not attempt to
perform further input, and it is unspecified to what extent scanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The scanf_s function is equivalent to fscanf_s with the argument stdin
interposed before the arguments to scanf_s.
- Returns
+<b> Returns</b>
5 The scanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
scanf_s function returns the number of input items assigned, which can be fewer than
provided for, or even zero, in the event of an early matching failure.
<a name="K.3.5.3.5" href="#K.3.5.3.5"><b> K.3.5.3.5 The snprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int snprintf_s(char * restrict s, rsize_t n,
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the snprintf_s function sets s[0] to the
null character.
- Description
+<b> Description</b>
4 The snprintf_s function is equivalent to the snprintf function except for the
explicit runtime-constraints listed above.
5 The snprintf_s function, unlike sprintf_s, will truncate the result to fit within the
array pointed to by s.
- Returns
+<b> Returns</b>
6 The snprintf_s function returns the number of characters that would have been
written had n been sufficiently large, not counting the terminating null character, or a
negative value if a runtime-constraint violation occurred. Thus, the null-terminated
output has been completely written if and only if the returned value is nonnegative and
less than n.
<a name="K.3.5.3.6" href="#K.3.5.3.6"><b> K.3.5.3.6 The sprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int sprintf_s(char * restrict s, rsize_t n,
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the sprintf_s function sets s[0] to the
null character.
- Description
+<b> Description</b>
4 The sprintf_s function is equivalent to the sprintf function except for the
parameter n and the explicit runtime-constraints listed above.
5 The sprintf_s function, unlike snprintf_s, treats a result too big for the array
pointed to by s as a runtime-constraint violation.
- Returns
+<b> Returns</b>
6 If no runtime-constraint violation occurred, the sprintf_s function returns the number
of characters written in the array, not counting the terminating null character. If an
encoding error occurred, sprintf_s returns a negative value. If any other runtime-
constraint violation occurred, sprintf_s returns zero.
<a name="K.3.5.3.7" href="#K.3.5.3.7"><b> K.3.5.3.7 The sscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
int sscanf_s(const char * restrict s,
3 If there is a runtime-constraint violation, the sscanf_s function does not attempt to
perform further input, and it is unspecified to what extent sscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The sscanf_s function is equivalent to fscanf_s, except that input is obtained from
a string (specified by the argument s) rather than from a stream. Reaching the end of the
string is equivalent to encountering end-of-file for the fscanf_s function. If copying
takes place between objects that overlap, the objects take on unspecified values.
- Returns
+<b> Returns</b>
5 The sscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
sscanf_s function returns the number of input items assigned, which can be fewer than
[<a name="p592" href="#p592">page 592</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.5.3.8" href="#K.3.5.3.8"><b> K.3.5.3.8 The vfprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, the vfprintf_s function does not attempt to
produce further output, and it is unspecified to what extent vfprintf_s produced
output before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vfprintf_s function is equivalent to the vfprintf function except for the
explicit runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The vfprintf_s function returns the number of characters transmitted, or a negative
value if an output error, encoding error, or runtime-constraint violation occurred.
<a name="K.3.5.3.9" href="#K.3.5.3.9"><b> K.3.5.3.9 The vfscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, the vfscanf_s function does not attempt to
perform further input, and it is unspecified to what extent vfscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vfscanf_s function is equivalent to fscanf_s, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfscanf_s function does not invoke the
va_end macro.385)
- Returns
+<b> Returns</b>
5 The vfscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
vfscanf_s function returns the number of input items assigned, which can be fewer
than provided for, or even zero, in the event of an early matching failure.
<a name="K.3.5.3.10" href="#K.3.5.3.10"><b> K.3.5.3.10 The vprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
[<a name="p594" href="#p594">page 594</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
4 The vprintf_s function is equivalent to the vprintf function except for the explicit
runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The vprintf_s function returns the number of characters transmitted, or a negative
value if an output error, encoding error, or runtime-constraint violation occurred.
<a name="K.3.5.3.11" href="#K.3.5.3.11"><b> K.3.5.3.11 The vscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, the vscanf_s function does not attempt to
perform further input, and it is unspecified to what extent vscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vscanf_s function is equivalent to scanf_s, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vscanf_s function does not invoke the
va_end macro.387)
- Returns
+<b> Returns</b>
5 The vscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
vscanf_s function returns the number of input items assigned, which can be fewer than
[<a name="p595" href="#p595">page 595</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.5.3.12" href="#K.3.5.3.12"><b> K.3.5.3.12 The vsnprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the vsnprintf_s function sets s[0] to the
null character.
- Description
+<b> Description</b>
4 The vsnprintf_s function is equivalent to the vsnprintf function except for the
explicit runtime-constraints listed above.
5 The vsnprintf_s function, unlike vsprintf_s, will truncate the result to fit within
the array pointed to by s.
- Returns
+<b> Returns</b>
6 The vsnprintf_s function returns the number of characters that would have been
written had n been sufficiently large, not counting the terminating null character, or a
negative value if a runtime-constraint violation occurred. Thus, the null-terminated
[<a name="p596" href="#p596">page 596</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.5.3.13" href="#K.3.5.3.13"><b> K.3.5.3.13 The vsprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the vsprintf_s function sets s[0] to the
null character.
- Description
+<b> Description</b>
4 The vsprintf_s function is equivalent to the vsprintf function except for the
parameter n and the explicit runtime-constraints listed above.
5 The vsprintf_s function, unlike vsnprintf_s, treats a result too big for the array
pointed to by s as a runtime-constraint violation.
- Returns
+<b> Returns</b>
6 If no runtime-constraint violation occurred, the vsprintf_s function returns the
number of characters written in the array, not counting the terminating null character. If
an encoding error occurred, vsprintf_s returns a negative value. If any other
[<a name="p597" href="#p597">page 597</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.5.3.14" href="#K.3.5.3.14"><b> K.3.5.3.14 The vsscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, the vsscanf_s function does not attempt to
perform further input, and it is unspecified to what extent vsscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vsscanf_s function is equivalent to sscanf_s, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vsscanf_s function does not invoke the
va_end macro.390)
- Returns
+<b> Returns</b>
5 The vsscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
vscanf_s function returns the number of input items assigned, which can be fewer than
provided for, or even zero, in the event of an early matching failure.
<a name="K.3.5.4" href="#K.3.5.4"><b> K.3.5.4 Character input/output functions</b></a>
<a name="K.3.5.4.1" href="#K.3.5.4.1"><b> K.3.5.4.1 The gets_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
char *gets_s(char *s, rsize_t n);
3 If there is a runtime-constraint violation, s[0] is set to the null character, and characters
are read and discarded from stdin until a new-line character is read, or end-of-file or a
read error occurs.
- Description
+<b> Description</b>
4 The gets_s function reads at most one less than the number of characters specified by n
from the stream pointed to by stdin, into the array pointed to by s. No additional
characters are read after a new-line character (which is discarded) or after end-of-file.
attention to the presence or absence of a new-line character in the result array. Consider
using fgets (along with any needed processing based on new-line characters) instead of
gets_s.
- Returns
+<b> Returns</b>
7 The gets_s function returns s if successful. If there was a runtime-constraint violation,
or if end-of-file is encountered and no characters have been read into the array, or if a
read error occurs during the operation, then a null pointer is returned.
errno_t error);
<a name="K.3.6.1" href="#K.3.6.1"><b> K.3.6.1 Runtime-constraint handling</b></a>
<a name="K.3.6.1.1" href="#K.3.6.1.1"><b> K.3.6.1.1 The set_constraint_handler_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
constraint_handler_t set_constraint_handler_s(
constraint_handler_t handler);
- Description
+<b> Description</b>
2 The set_constraint_handler_s function sets the runtime-constraint handler to
be handler. The runtime-constraint handler is the function to be called when a library
function detects a runtime-constraint violation. Only the most recent handler registered
default handler is implementation-defined, and it may cause the program to exit or abort.
5 If the handler argument to set_constraint_handler_s is a null pointer, the
implementation default handler becomes the current constraint handler.
- Returns
+<b> Returns</b>
6 The set_constraint_handler_s function returns a pointer to the previously
registered handler.392)
<a name="K.3.6.1.2" href="#K.3.6.1.2"><b> K.3.6.1.2 The abort_handler_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
void abort_handler_s(
const char * restrict msg,
void * restrict ptr,
errno_t error);
- Description
+<b> Description</b>
2 A pointer to the abort_handler_s function shall be a suitable argument to the
set_constraint_handler_s function.
3 The abort_handler_s function writes a message on the standard error stream in an
implementation-defined format. The message shall include the string pointed to by msg.
The abort_handler_s function then calls the abort function.393)
- Returns
+<b> Returns</b>
4 The abort_handler_s function does not return to its caller.
[<a name="p601" href="#p601">page 601</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.6.1.3" href="#K.3.6.1.3"><b> K.3.6.1.3 The ignore_handler_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
void ignore_handler_s(
const char * restrict msg,
void * restrict ptr,
errno_t error);
- Description
+<b> Description</b>
2 A pointer to the ignore_handler_s function shall be a suitable argument to the
set_constraint_handler_s function.
3 The ignore_handler_s function simply returns to its caller.394)
- Returns
+<b> Returns</b>
4 The ignore_handler_s function returns no value.
<a name="K.3.6.2" href="#K.3.6.2"><b> K.3.6.2 Communication with the environment</b></a>
<a name="K.3.6.2.1" href="#K.3.6.2.1"><b> K.3.6.2.1 The getenv_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
errno_t getenv_s(size_t * restrict len,
RSIZE_MAX. If maxsize is not equal to zero, then value shall not be a null pointer.
3 If there is a runtime-constraint violation, the integer pointed to by len is set to 0 (if len
is not null), and the environment list is not searched.
- Description
+<b> Description</b>
4 The getenv_s function searches an environment list, provided by the host environment,
for a string that matches the string pointed to by name.
zero, then value[0] is set to the null character.
7 The set of environment names and the method for altering the environment list are
implementation-defined.
- Returns
+<b> Returns</b>
8 The getenv_s function returns zero if the specified name is found and the associated
string was successfully stored in value. Otherwise, a nonzero value is returned.
<a name="K.3.6.3" href="#K.3.6.3"><b> K.3.6.3 Searching and sorting utilities</b></a>
comparison function, and also between any call to the comparison function and any
movement of the objects passed as arguments to that call.
<a name="K.3.6.3.1" href="#K.3.6.3.1"><b> K.3.6.3.1 The bsearch_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
void *bsearch_s(const void *key, const void *base,
zero, then none of key, base, or compar shall be a null pointer.
3 If there is a runtime-constraint violation, the bsearch_s function does not search the
array.
- Description
+<b> Description</b>
4 The bsearch_s function searches an array of nmemb objects, the initial element of
which is pointed to by base, for an element that matches the object pointed to by key.
The size of each element of the array is specified by size.
[<a name="p604" href="#p604">page 604</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
6 The bsearch_s function returns a pointer to a matching element of the array, or a null
pointer if no match is found or there is a runtime-constraint violation. If two elements
compare as equal, which element is matched is unspecified.
<a name="K.3.6.3.2" href="#K.3.6.3.2"><b> K.3.6.3.2 The qsort_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
errno_t qsort_s(void *base, rsize_t nmemb, rsize_t size,
2 Neither nmemb nor size shall be greater than RSIZE_MAX. If nmemb is not equal to
zero, then neither base nor compar shall be a null pointer.
3 If there is a runtime-constraint violation, the qsort_s function does not sort the array.
- Description
+<b> Description</b>
4 The qsort_s function sorts an array of nmemb objects, the initial element of which is
pointed to by base. The size of each object is specified by size.
5 The contents of the array are sorted into ascending order according to a comparison
pass it to the comparison function.398)
6 If two elements compare as equal, their relative order in the resulting sorted array is
unspecified.
- Returns
+<b> Returns</b>
7 The qsort_s function returns zero if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
encodings have state dependency, and zero otherwise.399) Changing the LC_CTYPE
category causes the conversion state of these functions to be indeterminate.
<a name="K.3.6.4.1" href="#K.3.6.4.1"><b> K.3.6.4.1 The wctomb_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.22"><stdlib.h></a>
errno_t wctomb_s(int * restrict status,
4 If there is a runtime-constraint violation, wctomb_s does not modify the int pointed to
by status, and if s is not a null pointer, no more than smax elements in the array
pointed to by s will be accessed.
- Description
+<b> Description</b>
5 The wctomb_s function determines n and stores the multibyte character representation
of wc in the array whose first element is pointed to by s (if s is not a null pointer). The
number of characters stored never exceeds MB_CUR_MAX or smax. If wc is a null wide
multibyte character.
9 In no case will the int pointed to by status be set to a value greater than the
MB_CUR_MAX macro.
- Returns
+<b> Returns</b>
10 The wctomb_s function returns zero if successful, and a nonzero value if there was a
runtime-constraint violation or wc did not correspond to a valid multibyte character.
<a name="K.3.6.5" href="#K.3.6.5"><b> K.3.6.5 Multibyte/wide string conversion functions</b></a>
1 The behavior of the multibyte string functions is affected by the LC_CTYPE category of
the current locale.
<a name="K.3.6.5.1" href="#K.3.6.5.1"><b> K.3.6.5.1 The mbstowcs_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
errno_t mbstowcs_s(size_t * restrict retval,
wchar_t * restrict dst, rsize_t dstmax,
retval is not a null pointer, then mbstowcs_s sets *retval to (size_t)(-1). If
dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
then mbstowcs_s sets dst[0] to the null wide character.
- Description
+<b> Description</b>
4 The mbstowcs_s function converts a sequence of multibyte characters that begins in
the initial shift state from the array pointed to by src into a sequence of corresponding
wide characters. If dst is not a null pointer, the converted characters are stored into the
unspecified values when mbstowcs_s returns.401)
7 If copying takes place between objects that overlap, the objects take on unspecified
values.
- Returns
+<b> Returns</b>
8 The mbstowcs_s function returns zero if no runtime-constraint violation and no
encoding error occurred. Otherwise, a nonzero value is returned.
<a name="K.3.6.5.2" href="#K.3.6.5.2"><b> K.3.6.5.2 The wcstombs_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #include <a href="#7.22"><stdlib.h></a>
errno_t wcstombs_s(size_t * restrict retval,
char * restrict dst, rsize_t dstmax,
retval is not a null pointer, then wcstombs_s sets *retval to (size_t)(-1). If
dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
then wcstombs_s sets dst[0] to the null character.
- Description
+<b> Description</b>
4 The wcstombs_s function converts a sequence of wide characters from the array
pointed to by src into a sequence of corresponding multibyte characters that begins in
the initial shift state. If dst is not a null pointer, the converted characters are then stored
[<a name="p609" href="#p609">page 609</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
8 The wcstombs_s function returns zero if no runtime-constraint violation and no
encoding error occurred. Otherwise, a nonzero value is returned.
<a name="K.3.7" href="#K.3.7"><b> K.3.7 String handling <string.h></b></a>
which is the type size_t.
<a name="K.3.7.1" href="#K.3.7.1"><b> K.3.7.1 Copying functions</b></a>
<a name="K.3.7.1.1" href="#K.3.7.1.1"><b> K.3.7.1.1 The memcpy_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t memcpy_s(void * restrict s1, rsize_t s1max,
3 If there is a runtime-constraint violation, the memcpy_s function stores zeros in the first
s1max characters of the object pointed to by s1 if s1 is not a null pointer and s1max is
not greater than RSIZE_MAX.
- Description
+<b> Description</b>
4 The memcpy_s function copies n characters from the object pointed to by s2 into the
object pointed to by s1.
- Returns
+<b> Returns</b>
5 The memcpy_s function returns zero if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
[<a name="p610" href="#p610">page 610</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.7.1.2" href="#K.3.7.1.2"><b> K.3.7.1.2 The memmove_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t memmove_s(void *s1, rsize_t s1max,
3 If there is a runtime-constraint violation, the memmove_s function stores zeros in the
first s1max characters of the object pointed to by s1 if s1 is not a null pointer and
s1max is not greater than RSIZE_MAX.
- Description
+<b> Description</b>
4 The memmove_s function copies n characters from the object pointed to by s2 into the
object pointed to by s1. This copying takes place as if the n characters from the object
pointed to by s2 are first copied into a temporary array of n characters that does not
overlap the objects pointed to by s1 or s2, and then the n characters from the temporary
array are copied into the object pointed to by s1.
- Returns
+<b> Returns</b>
5 The memmove_s function returns zero if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
<a name="K.3.7.1.3" href="#K.3.7.1.3"><b> K.3.7.1.3 The strcpy_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t strcpy_s(char * restrict s1,
[<a name="p611" href="#p611">page 611</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
4 The strcpy_s function copies the string pointed to by s2 (including the terminating
null character) into the array pointed to by s1.
5 All elements following the terminating null character (if any) written by strcpy_s in
the array of s1max characters pointed to by s1 take unspecified values when
strcpy_s returns.404)
- Returns
+<b> Returns</b>
6 The strcpy_s function returns zero405) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
<a name="K.3.7.1.4" href="#K.3.7.1.4"><b> K.3.7.1.4 The strncpy_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t strncpy_s(char * restrict s1,
3 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then strncpy_s sets s1[0] to the
null character.
- Description
+<b> Description</b>
4 The strncpy_s function copies not more than n successive characters (characters that
follow a null character are not copied) from the array pointed to by s2 to the array
pointed to by s1. If no null character was copied from s2, then s1[n] is set to a null
5 All elements following the terminating null character (if any) written by strncpy_s in
the array of s1max characters pointed to by s1 take unspecified values when
strncpy_s returns.406)
- Returns
+<b> Returns</b>
6 The strncpy_s function returns zero407) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
7 EXAMPLE 1 The strncpy_s function can be used to copy a string without the danger that the result
<a name="K.3.7.2" href="#K.3.7.2"><b> K.3.7.2 Concatenation functions</b></a>
<a name="K.3.7.2.1" href="#K.3.7.2.1"><b> K.3.7.2.1 The strcat_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t strcat_s(char * restrict s1,
4 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then strcat_s sets s1[0] to the
null character.
- Description
+<b> Description</b>
5 The strcat_s function appends a copy of the string pointed to by s2 (including the
terminating null character) to the end of the string pointed to by s1. The initial character
from s2 overwrites the null character at the end of s1.
6 All elements following the terminating null character (if any) written by strcat_s in
the array of s1max characters pointed to by s1 take unspecified values when
strcat_s returns.409)
- Returns
+<b> Returns</b>
7 The strcat_s function returns zero410) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
<a name="K.3.7.2.2" href="#K.3.7.2.2"><b> K.3.7.2.2 The strncat_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t strncat_s(char * restrict s1,
4 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then strncat_s sets s1[0] to the
null character.
- Description
+<b> Description</b>
5 The strncat_s function appends not more than n successive characters (characters
that follow a null character are not copied) from the array pointed to by s2 to the end of
the string pointed to by s1. The initial character from s2 overwrites the null character at
6 All elements following the terminating null character (if any) written by strncat_s in
the array of s1max characters pointed to by s1 take unspecified values when
strncat_s returns.412)
- Returns
+<b> Returns</b>
7 The strncat_s function returns zero413) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
8 EXAMPLE 1 The strncat_s function can be used to copy a string without the danger that the result
<a name="K.3.7.3" href="#K.3.7.3"><b> K.3.7.3 Search functions</b></a>
<a name="K.3.7.3.1" href="#K.3.7.3.1"><b> K.3.7.3.1 The strtok_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
char *strtok_s(char * restrict s1,
on subsequent calls.
3 If there is a runtime-constraint violation, the strtok_s function does not indirect
through the s1 or s2 pointers, and does not store a value in the object pointed to by ptr.
- Description
+<b> Description</b>
4 A sequence of calls to the strtok_s function breaks the string pointed to by s1 into a
sequence of tokens, each of which is delimited by a character from the string pointed to
by s2. The fourth argument points to a caller-provided char pointer into which the
to by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
value for ptr, shall start searching just past the element overwritten by a null character
(if any).
- Returns
+<b> Returns</b>
9 The strtok_s function returns a pointer to the first character of a token, or a null
pointer if there is no token or there is a runtime-constraint violation.
10 EXAMPLE
<a name="K.3.7.4" href="#K.3.7.4"><b> K.3.7.4 Miscellaneous functions</b></a>
<a name="K.3.7.4.1" href="#K.3.7.4.1"><b> K.3.7.4.1 The memset_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t memset_s(void *s, rsize_t smax, int c, rsize_t n)
[<a name="p617" href="#p617">page 617</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
4 The memset_s function copies the value of c (converted to an unsigned char) into
each of the first n characters of the object pointed to by s. Unlike memset, any call to
the memset_s function shall be evaluated strictly according to the rules of the abstract
machine as described in (<a href="#5.1.2.3">5.1.2.3</a>). That is, any call to the memset_s function shall
assume that the memory indicated by s and n may be accessible in the future and thus
must contain the values indicated by c.
- Returns
+<b> Returns</b>
5 The memset_s function returns zero if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
<a name="K.3.7.4.2" href="#K.3.7.4.2"><b> K.3.7.4.2 The strerror_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
errno_t strerror_s(char *s, rsize_t maxsize,
maxsize shall not equal zero.
3 If there is a runtime-constraint violation, then the array (if any) pointed to by s is not
modified.
- Description
+<b> Description</b>
4 The strerror_s function maps the number in errnum to a locale-specific message
string. Typically, the values for errnum come from errno, but strerror_s shall
map any value of type int to a message.
from the string to the array pointed to by s and then s[maxsize-1] is set to the null
character. Then, if maxsize is greater than 3, then s[maxsize-2],
s[maxsize-3], and s[maxsize-4] are set to the character period (.).
- Returns
+<b> Returns</b>
7 The strerror_s function returns zero if the length of the desired string was less than
maxsize and there was no runtime-constraint violation. Otherwise, the strerror_s
function returns a nonzero value.
[<a name="p618" href="#p618">page 618</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.7.4.3" href="#K.3.7.4.3"><b> K.3.7.4.3 The strerrorlen_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
size_t strerrorlen_s(errno_t errnum);
- Description
+<b> Description</b>
2 The strerrorlen_s function calculates the length of the (untruncated) locale-specific
message string that the strerror_s function maps to errnum.
- Returns
+<b> Returns</b>
3 The strerrorlen_s function returns the number of characters (not including the null
character) in the full message string.
<a name="K.3.7.4.4" href="#K.3.7.4.4"><b> K.3.7.4.4 The strnlen_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.23"><string.h></a>
size_t strnlen_s(const char *s, size_t maxsize);
- Description
+<b> Description</b>
2 The strnlen_s function computes the length of the string pointed to by s.
- Returns
+<b> Returns</b>
3 If s is a null pointer,414) then the strnlen_s function returns zero.
4 Otherwise, the strnlen_s function returns the number of characters that precede the
terminating null character. If there is no null character in the first maxsize characters of
1 Like the strftime function, the asctime_s and ctime_s functions do not return a
pointer to a static object, and other library functions are permitted to call them.
<a name="K.3.8.2.1" href="#K.3.8.2.1"><b> K.3.8.2.1 The asctime_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.26"><time.h></a>
errno_t asctime_s(char *s, rsize_t maxsize,
3 If there is a runtime-constraint violation, there is no attempt to convert the time, and
s[0] is set to a null character if s is not a null pointer and maxsize is not zero and is
not greater than RSIZE_MAX.
- Description
+<b> Description</b>
4 The asctime_s function converts the normalized broken-down time in the structure
pointed to by timeptr into a 26 character (including the null character) string in the
The strftime function allows more flexible formatting and supports locale-specific
behavior. If you do not require the exact form of the result string produced by the
asctime_s function, consider using the strftime function instead.
- Returns
+<b> Returns</b>
5 The asctime_s function returns zero if the time was successfully converted and stored
into the array pointed to by s. Otherwise, it returns a nonzero value.
[<a name="p621" href="#p621">page 621</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.8.2.2" href="#K.3.8.2.2"><b> K.3.8.2.2 The ctime_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.26"><time.h></a>
errno_t ctime_s(char *s, rsize_t maxsize,
shall not be greater than RSIZE_MAX.
3 If there is a runtime-constraint violation, s[0] is set to a null character if s is not a null
pointer and maxsize is not equal zero and is not greater than RSIZE_MAX.
- Description
+<b> Description</b>
4 The ctime_s function converts the calendar time pointed to by timer to local time in
the form of a string. It is equivalent to
asctime_s(s, maxsize, localtime_s(timer))
The strftime function allows more flexible formatting and supports locale-specific
behavior. If you do not require the exact form of the result string produced by the
ctime_s function, consider using the strftime function instead.
- Returns
+<b> Returns</b>
5 The ctime_s function returns zero if the time was successfully converted and stored
into the array pointed to by s. Otherwise, it returns a nonzero value.
<a name="K.3.8.2.3" href="#K.3.8.2.3"><b> K.3.8.2.3 The gmtime_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.26"><time.h></a>
struct tm *gmtime_s(const time_t * restrict timer,
Runtime-constraints
2 Neither timer nor result shall be a null pointer.
3 If there is a runtime-constraint violation, there is no attempt to convert the time.
- Description
+<b> Description</b>
4 The gmtime_s function converts the calendar time pointed to by timer into a broken-
down time, expressed as UTC. The broken-down time is stored in the structure pointed
[<a name="p622" href="#p622">page 622</a>] (<a href="#Contents">Contents</a>)
to by result.
- Returns
+<b> Returns</b>
5 The gmtime_s function returns result, or a null pointer if the specified time cannot
be converted to UTC or there is a runtime-constraint violation.
<a name="K.3.8.2.4" href="#K.3.8.2.4"><b> K.3.8.2.4 The localtime_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.26"><time.h></a>
struct tm *localtime_s(const time_t * restrict timer,
Runtime-constraints
2 Neither timer nor result shall be a null pointer.
3 If there is a runtime-constraint violation, there is no attempt to convert the time.
- Description
+<b> Description</b>
4 The localtime_s function converts the calendar time pointed to by timer into a
broken-down time, expressed as local time. The broken-down time is stored in the
structure pointed to by result.
- Returns
+<b> Returns</b>
5 The localtime_s function returns result, or a null pointer if the specified time
cannot be converted to local time or there is a runtime-constraint violation.
<a name="K.3.9" href="#K.3.9"><b> K.3.9 Extended multibyte and wide character utilities <wchar.h></b></a>
<a name="K.3.9.1" href="#K.3.9.1"><b> K.3.9.1 Formatted wide character input/output functions</b></a>
<a name="K.3.9.1.1" href="#K.3.9.1.1"><b> K.3.9.1.1 The fwprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
int fwprintf_s(FILE * restrict stream,
3 If there is a runtime-constraint violation, the fwprintf_s function does not attempt to
produce further output, and it is unspecified to what extent fwprintf_s produced
output before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The fwprintf_s function is equivalent to the fwprintf function except for the
explicit runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The fwprintf_s function returns the number of wide characters transmitted, or a
negative value if an output error, encoding error, or runtime-constraint violation occurred.
<a name="K.3.9.1.2" href="#K.3.9.1.2"><b> K.3.9.1.2 The fwscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.21"><stdio.h></a>
#include <a href="#7.28"><wchar.h></a>
3 If there is a runtime-constraint violation, the fwscanf_s function does not attempt to
perform further input, and it is unspecified to what extent fwscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The fwscanf_s function is equivalent to fwscanf except that the c, s, and [
conversion specifiers apply to a pair of arguments (unless assignment suppression is
indicated by a *). The first of these arguments is the same as for fwscanf. That
an array of one element.417)
5 A matching failure occurs if the number of elements in a receiving object is insufficient to
hold the converted input (including any trailing null character).
- Returns
+<b> Returns</b>
6 The fwscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
fwscanf_s function returns the number of input items assigned, which can be fewer
than provided for, or even zero, in the event of an early matching failure.
<a name="K.3.9.1.3" href="#K.3.9.1.3"><b> K.3.9.1.3 The snwprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
int snwprintf_s(wchar_t * restrict s,
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the snwprintf_s function sets s[0] to the
null wide character.
- Description
+<b> Description</b>
4 The snwprintf_s function is equivalent to the swprintf function except for the
explicit runtime-constraints listed above.
5 The snwprintf_s function, unlike swprintf_s, will truncate the result to fit within
the array pointed to by s.
- Returns
+<b> Returns</b>
6 The snwprintf_s function returns the number of wide characters that would have
been written had n been sufficiently large, not counting the terminating wide null
character, or a negative value if a runtime-constraint violation occurred. Thus, the null-
terminated output has been completely written if and only if the returned value is
nonnegative and less than n.
<a name="K.3.9.1.4" href="#K.3.9.1.4"><b> K.3.9.1.4 The swprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
int swprintf_s(wchar_t * restrict s, rsize_t n,
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the swprintf_s function sets s[0] to the
null wide character.
- Description
+<b> Description</b>
4 The swprintf_s function is equivalent to the swprintf function except for the
explicit runtime-constraints listed above.
5 The swprintf_s function, unlike snwprintf_s, treats a result too big for the array
pointed to by s as a runtime-constraint violation.
- Returns
+<b> Returns</b>
6 If no runtime-constraint violation occurred, the swprintf_s function returns the
number of wide characters written in the array, not counting the terminating null wide
character. If an encoding error occurred or if n or more wide characters are requested to
be written, swprintf_s returns a negative value. If any other runtime-constraint
violation occurred, swprintf_s returns zero.
<a name="K.3.9.1.5" href="#K.3.9.1.5"><b> K.3.9.1.5 The swscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
int swscanf_s(const wchar_t * restrict s,
3 If there is a runtime-constraint violation, the swscanf_s function does not attempt to
perform further input, and it is unspecified to what extent swscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The swscanf_s function is equivalent to fwscanf_s, except that the argument s
specifies a wide string from which the input is to be obtained, rather than from a stream.
Reaching the end of the wide string is equivalent to encountering end-of-file for the
fwscanf_s function.
- Returns
+<b> Returns</b>
5 The swscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
swscanf_s function returns the number of input items assigned, which can be fewer
[<a name="p627" href="#p627">page 627</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.9.1.6" href="#K.3.9.1.6"><b> K.3.9.1.6 The vfwprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, the vfwprintf_s function does not attempt
to produce further output, and it is unspecified to what extent vfwprintf_s produced
output before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vfwprintf_s function is equivalent to the vfwprintf function except for the
explicit runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The vfwprintf_s function returns the number of wide characters transmitted, or a
negative value if an output error, encoding error, or runtime-constraint violation occurred.
<a name="K.3.9.1.7" href="#K.3.9.1.7"><b> K.3.9.1.7 The vfwscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.21"><stdio.h></a>
3 If there is a runtime-constraint violation, the vfwscanf_s function does not attempt to
perform further input, and it is unspecified to what extent vfwscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vfwscanf_s function is equivalent to fwscanf_s, with the variable argument
list replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfwscanf_s function does not invoke the
va_end macro.421)
- Returns
+<b> Returns</b>
5 The vfwscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
vfwscanf_s function returns the number of input items assigned, which can be fewer
than provided for, or even zero, in the event of an early matching failure.
<a name="K.3.9.1.8" href="#K.3.9.1.8"><b> K.3.9.1.8 The vsnwprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
3 If there is a runtime-constraint violation, then if s is not a null pointer and n is greater
than zero and less than RSIZE_MAX, then the vsnwprintf_s function sets s[0] to
the null wide character.
- Description
+<b> Description</b>
4 The vsnwprintf_s function is equivalent to the vswprintf function except for the
explicit runtime-constraints listed above.
5 The vsnwprintf_s function, unlike vswprintf_s, will truncate the result to fit
within the array pointed to by s.
- Returns
+<b> Returns</b>
6 The vsnwprintf_s function returns the number of wide characters that would have
been written had n been sufficiently large, not counting the terminating null character, or
a negative value if a runtime-constraint violation occurred. Thus, the null-terminated
output has been completely written if and only if the returned value is nonnegative and
less than n.
<a name="K.3.9.1.9" href="#K.3.9.1.9"><b> K.3.9.1.9 The vswprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
[<a name="p630" href="#p630">page 630</a>] (<a href="#Contents">Contents</a>)
- Description
+<b> Description</b>
4 The vswprintf_s function is equivalent to the vswprintf function except for the
explicit runtime-constraints listed above.
5 The vswprintf_s function, unlike vsnwprintf_s, treats a result too big for the
array pointed to by s as a runtime-constraint violation.
- Returns
+<b> Returns</b>
6 If no runtime-constraint violation occurred, the vswprintf_s function returns the
number of wide characters written in the array, not counting the terminating null wide
character. If an encoding error occurred or if n or more wide characters are requested to
be written, vswprintf_s returns a negative value. If any other runtime-constraint
violation occurred, vswprintf_s returns zero.
<a name="K.3.9.1.10" href="#K.3.9.1.10"><b> K.3.9.1.10 The vswscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
3 If there is a runtime-constraint violation, the vswscanf_s function does not attempt to
perform further input, and it is unspecified to what extent vswscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vswscanf_s function is equivalent to swscanf_s, with the variable argument
list replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vswscanf_s function does not invoke the
[<a name="p631" href="#p631">page 631</a>] (<a href="#Contents">Contents</a>)
- Returns
+<b> Returns</b>
5 The vswscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
vswscanf_s function returns the number of input items assigned, which can be fewer
than provided for, or even zero, in the event of an early matching failure.
<a name="K.3.9.1.11" href="#K.3.9.1.11"><b> K.3.9.1.11 The vwprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
3 If there is a runtime-constraint violation, the vwprintf_s function does not attempt to
produce further output, and it is unspecified to what extent vwprintf_s produced
output before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vwprintf_s function is equivalent to the vwprintf function except for the
explicit runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The vwprintf_s function returns the number of wide characters transmitted, or a
negative value if an output error, encoding error, or runtime-constraint violation occurred.
[<a name="p632" href="#p632">page 632</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.9.1.12" href="#K.3.9.1.12"><b> K.3.9.1.12 The vwscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.16"><stdarg.h></a>
#include <a href="#7.28"><wchar.h></a>
3 If there is a runtime-constraint violation, the vwscanf_s function does not attempt to
perform further input, and it is unspecified to what extent vwscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The vwscanf_s function is equivalent to wscanf_s, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vwscanf_s function does not invoke the
va_end macro.426)
- Returns
+<b> Returns</b>
5 The vwscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
vwscanf_s function returns the number of input items assigned, which can be fewer
than provided for, or even zero, in the event of an early matching failure.
<a name="K.3.9.1.13" href="#K.3.9.1.13"><b> K.3.9.1.13 The wprintf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
int wprintf_s(const wchar_t * restrict format, ...);
3 If there is a runtime-constraint violation, the wprintf_s function does not attempt to
produce further output, and it is unspecified to what extent wprintf_s produced output
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The wprintf_s function is equivalent to the wprintf function except for the explicit
runtime-constraints listed above.
- Returns
+<b> Returns</b>
5 The wprintf_s function returns the number of wide characters transmitted, or a
negative value if an output error, encoding error, or runtime-constraint violation occurred.
<a name="K.3.9.1.14" href="#K.3.9.1.14"><b> K.3.9.1.14 The wscanf_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
int wscanf_s(const wchar_t * restrict format, ...);
3 If there is a runtime-constraint violation, the wscanf_s function does not attempt to
perform further input, and it is unspecified to what extent wscanf_s performed input
before discovering the runtime-constraint violation.
- Description
+<b> Description</b>
4 The wscanf_s function is equivalent to fwscanf_s with the argument stdin
interposed before the arguments to wscanf_s.
- Returns
+<b> Returns</b>
5 The wscanf_s function returns the value of the macro EOF if an input failure occurs
before any conversion or if there is a runtime-constraint violation. Otherwise, the
wscanf_s function returns the number of input items assigned, which can be fewer than
<a name="K.3.9.2" href="#K.3.9.2"><b> K.3.9.2 General wide string utilities</b></a>
<a name="K.3.9.2.1" href="#K.3.9.2.1"><b> K.3.9.2.1 Wide string copying functions</b></a>
<a name="K.3.9.2.1.1" href="#K.3.9.2.1.1"><b> K.3.9.2.1.1 The wcscpy_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
errno_t wcscpy_s(wchar_t * restrict s1,
3 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then wcscpy_s sets s1[0] to the
null wide character.
- Description
+<b> Description</b>
4 The wcscpy_s function copies the wide string pointed to by s2 (including the
terminating null wide character) into the array pointed to by s1.
5 All elements following the terminating null wide character (if any) written by
wcscpy_s in the array of s1max wide characters pointed to by s1 take unspecified
values when wcscpy_s returns.428)
- Returns
+<b> Returns</b>
6 The wcscpy_s function returns zero429) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
[<a name="p635" href="#p635">page 635</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.9.2.1.2" href="#K.3.9.2.1.2"><b> K.3.9.2.1.2 The wcsncpy_s function</b></a>
- Synopsis
+<b> Synopsis</b>
7 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
errno_t wcsncpy_s(wchar_t * restrict s1,
9 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then wcsncpy_s sets s1[0] to the
null wide character.
- Description
+<b> Description</b>
10 The wcsncpy_s function copies not more than n successive wide characters (wide
characters that follow a null wide character are not copied) from the array pointed to by
s2 to the array pointed to by s1. If no null wide character was copied from s2, then
11 All elements following the terminating null wide character (if any) written by
wcsncpy_s in the array of s1max wide characters pointed to by s1 take unspecified
values when wcsncpy_s returns.430)
- Returns
+<b> Returns</b>
12 The wcsncpy_s function returns zero431) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
13 EXAMPLE 1 The wcsncpy_s function can be used to copy a wide string without the danger that the
The third call will assign to r3 the value zero and to dst3 the sequence of wide characters good\0.
<a name="K.3.9.2.1.3" href="#K.3.9.2.1.3"><b> K.3.9.2.1.3 The wmemcpy_s function</b></a>
- Synopsis
+<b> Synopsis</b>
14 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
errno_t wmemcpy_s(wchar_t * restrict s1,
16 If there is a runtime-constraint violation, the wmemcpy_s function stores zeros in the
first s1max wide characters of the object pointed to by s1 if s1 is not a null pointer and
s1max is not greater than RSIZE_MAX.
- Description
+<b> Description</b>
17 The wmemcpy_s function copies n successive wide characters from the object pointed
to by s2 into the object pointed to by s1.
- Returns
+<b> Returns</b>
18 The wmemcpy_s function returns zero if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
[<a name="p637" href="#p637">page 637</a>] (<a href="#Contents">Contents</a>)
<a name="K.3.9.2.1.4" href="#K.3.9.2.1.4"><b> K.3.9.2.1.4 The wmemmove_s function</b></a>
- Synopsis
+<b> Synopsis</b>
19 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
errno_t wmemmove_s(wchar_t *s1, rsize_t s1max,
21 If there is a runtime-constraint violation, the wmemmove_s function stores zeros in the
first s1max wide characters of the object pointed to by s1 if s1 is not a null pointer and
s1max is not greater than RSIZE_MAX.
- Description
+<b> Description</b>
22 The wmemmove_s function copies n successive wide characters from the object pointed
to by s2 into the object pointed to by s1. This copying takes place as if the n wide
characters from the object pointed to by s2 are first copied into a temporary array of n
wide characters that does not overlap the objects pointed to by s1 or s2, and then the n
wide characters from the temporary array are copied into the object pointed to by s1.
- Returns
+<b> Returns</b>
23 The wmemmove_s function returns zero if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
<a name="K.3.9.2.2" href="#K.3.9.2.2"><b> K.3.9.2.2 Wide string concatenation functions</b></a>
<a name="K.3.9.2.2.1" href="#K.3.9.2.2.1"><b> K.3.9.2.2.1 The wcscat_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
errno_t wcscat_s(wchar_t * restrict s1,
4 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then wcscat_s sets s1[0] to the
null wide character.
- Description
+<b> Description</b>
5 The wcscat_s function appends a copy of the wide string pointed to by s2 (including
the terminating null wide character) to the end of the wide string pointed to by s1. The
initial wide character from s2 overwrites the null wide character at the end of s1.
6 All elements following the terminating null wide character (if any) written by
wcscat_s in the array of s1max wide characters pointed to by s1 take unspecified
values when wcscat_s returns.433)
- Returns
+<b> Returns</b>
7 The wcscat_s function returns zero434) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
<a name="K.3.9.2.2.2" href="#K.3.9.2.2.2"><b> K.3.9.2.2.2 The wcsncat_s function</b></a>
- Synopsis
+<b> Synopsis</b>
8 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
errno_t wcsncat_s(wchar_t * restrict s1,
11 If there is a runtime-constraint violation, then if s1 is not a null pointer and s1max is
greater than zero and not greater than RSIZE_MAX, then wcsncat_s sets s1[0] to the
null wide character.
- Description
+<b> Description</b>
12 The wcsncat_s function appends not more than n successive wide characters (wide
characters that follow a null wide character are not copied) from the array pointed to by
s2 to the end of the wide string pointed to by s1. The initial wide character from s2
13 All elements following the terminating null wide character (if any) written by
wcsncat_s in the array of s1max wide characters pointed to by s1 take unspecified
values when wcsncat_s returns.436)
- Returns
+<b> Returns</b>
14 The wcsncat_s function returns zero437) if there was no runtime-constraint violation.
Otherwise, a nonzero value is returned.
15 EXAMPLE 1 The wcsncat_s function can be used to copy a wide string without the danger that the
<a name="K.3.9.2.3" href="#K.3.9.2.3"><b> K.3.9.2.3 Wide string search functions</b></a>
<a name="K.3.9.2.3.1" href="#K.3.9.2.3.1"><b> K.3.9.2.3.1 The wcstok_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
wchar_t *wcstok_s(wchar_t * restrict s1,
resumes on subsequent calls.
3 If there is a runtime-constraint violation, the wcstok_s function does not indirect
through the s1 or s2 pointers, and does not store a value in the object pointed to by ptr.
- Description
+<b> Description</b>
4 A sequence of calls to the wcstok_s function breaks the wide string pointed to by s1
into a sequence of tokens, each of which is delimited by a wide character from the wide
string pointed to by s2. The fourth argument points to a caller-provided wchar_t
to by ptr so that subsequent calls, with a null pointer for s1 and the unmodified pointer
value for ptr, shall start searching just past the element overwritten by a null wide
character (if any).
- Returns
+<b> Returns</b>
9 The wcstok_s function returns a pointer to the first wide character of a token, or a null
pointer if there is no token or there is a runtime-constraint violation.
10 EXAMPLE
<a name="K.3.9.2.4" href="#K.3.9.2.4"><b> K.3.9.2.4 Miscellaneous functions</b></a>
<a name="K.3.9.2.4.1" href="#K.3.9.2.4.1"><b> K.3.9.2.4.1 The wcsnlen_s function</b></a>
- Synopsis
+<b> Synopsis</b>
1 #define __STDC_WANT_LIB_EXT1__ 1
#include <a href="#7.28"><wchar.h></a>
size_t wcsnlen_s(const wchar_t *s, size_t maxsize);
- Description
+<b> Description</b>
2 The wcsnlen_s function computes the length of the wide string pointed to by s.
- Returns
+<b> Returns</b>
3 If s is a null pointer,438) then the wcsnlen_s function returns zero.
4 Otherwise, the wcsnlen_s function returns the number of wide characters that precede
the terminating null wide character. If there is no null wide character in the first
1 Unlike wcrtomb, wcrtomb_s does not permit the ps parameter (the pointer to the
conversion state) to be a null pointer.
<a name="K.3.9.3.1.1" href="#K.3.9.3.1.1"><b> K.3.9.3.1.1 The wcrtomb_s function</b></a>
- Synopsis
+<b> Synopsis</b>
2 #include <a href="#7.28"><wchar.h></a>
errno_t wcrtomb_s(size_t * restrict retval,
char * restrict s, rsize_t smax,
not a null pointer and smax is greater than zero and not greater than RSIZE_MAX, then
wcrtomb_s sets s[0] to the null character. If retval is not a null pointer, then
wcrtomb_s sets *retval to (size_t)(-1).
- Description
+<b> Description</b>
5 If s is a null pointer, the wcrtomb_s function is equivalent to the call
wcrtomb_s(&retval, buf, sizeof buf, L'\0', ps)
where retval and buf are internal variables of the appropriate types, and the size of
conversion state is unspecified. Otherwise, the wcrtomb_s function stores into
*retval the number of bytes (including any shift sequences) stored in the array pointed
to by s.
- Returns
+<b> Returns</b>
8 The wcrtomb_s function returns zero if no runtime-constraint violation and no
encoding error occurred. Otherwise, a nonzero value is returned.
<a name="K.3.9.3.2" href="#K.3.9.3.2"><b> K.3.9.3.2 Restartable multibyte/wide string conversion functions</b></a>
1 Unlike mbsrtowcs and wcsrtombs, mbsrtowcs_s and wcsrtombs_s do not
permit the ps parameter (the pointer to the conversion state) to be a null pointer.
<a name="K.3.9.3.2.1" href="#K.3.9.3.2.1"><b> K.3.9.3.2.1 The mbsrtowcs_s function</b></a>
- Synopsis
+<b> Synopsis</b>
2 #include <a href="#7.28"><wchar.h></a>
errno_t mbsrtowcs_s(size_t * restrict retval,
wchar_t * restrict dst, rsize_t dstmax,
retval is not a null pointer, then mbsrtowcs_s sets *retval to (size_t)(-1).
If dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
then mbsrtowcs_s sets dst[0] to the null wide character.
- Description
+<b> Description</b>
5 The mbsrtowcs_s function converts a sequence of multibyte characters that begins in
the conversion state described by the object pointed to by ps, from the array indirectly
pointed to by src into a sequence of corresponding wide characters. If dst is not a null
unspecified values when mbsrtowcs_s returns.440)
9 If copying takes place between objects that overlap, the objects take on unspecified
values.
- Returns
+<b> Returns</b>
10 The mbsrtowcs_s function returns zero if no runtime-constraint violation and no
encoding error occurred. Otherwise, a nonzero value is returned.
<a name="K.3.9.3.2.2" href="#K.3.9.3.2.2"><b> K.3.9.3.2.2 The wcsrtombs_s function</b></a>
- Synopsis
+<b> Synopsis</b>
11 #include <a href="#7.28"><wchar.h></a>
errno_t wcsrtombs_s(size_t * restrict retval,
char * restrict dst, rsize_t dstmax,
retval is not a null pointer, then wcsrtombs_s sets *retval to (size_t)(-1).
If dst is not a null pointer and dstmax is greater than zero and less than RSIZE_MAX,
then wcsrtombs_s sets dst[0] to the null character.
- Description
+<b> Description</b>
14 The wcsrtombs_s function converts a sequence of wide characters from the array
indirectly pointed to by src into a sequence of corresponding multibyte characters that
begins in the conversion state described by the object pointed to by ps. If dst is not a
wcsrtombs_s returns.442)
18 If copying takes place between objects that overlap, the objects take on unspecified
values.
- Returns
+<b> Returns</b>
19 The wcsrtombs_s function returns zero if no runtime-constraint violation and no
encoding error occurred. Otherwise, a nonzero value is returned.