21. THE STANDARD LIBRARY - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

21. THE STANDARD LIBRARY

Description:

Provides macros that can be used in place of certain operators. For example, the and macro is equivalent to the && operator. Boolean Type and Values. – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 11
Provided by: Ritw4
Category:
Tags: library | standard | the | macros

less

Transcript and Presenter's Notes

Title: 21. THE STANDARD LIBRARY


1
21. THE STANDARD LIBRARY
2
General Rules
The C standard library is divided into 15 parts
(24 in C99), with each part described by a
header. The names of functions, types, and
macros defined in a header are reserved programs
that include the header shouldnt use these names
for any other purpose. Identifiers with
external linkage (for example, function names)
are always reserved, even if the header isnt
included.
3
C89 Headers
ltassert.hgt Diagnostics. Contains only the
assert macro, which enables programs to perform
self-checks. If any check fails, the program
terminates. include ltassert.hgt void assert(int
expression) / if expression is false, writes a
diagnostic message and terminates execution /
4
C89 Headers
ltctype.hgt Character Handling. Provides
functions for testing and converting
characters. include ltctype.hgt int islower(int
c) / is c a lower-case letter? / int
tolower(int c) / if c is an upper-case letter,
returns the lower-caseversion otherwise, returns
c unchanged /
5
C89 Headers
lterrno.hgt Errors. Provides macros that allow
the program to detect whether an error has
occurred during calls of certain library
functions. errno (which may be a macro or a
variable) is an lvalue of type int that is set to
a positive value when an error occurs. include
lterrno.hgt define errno ltfloat.hgt
Characteristics of Floating Types. Provides
macros that define the range and accuracy of
floating types. include ltfloat.hgt define
FLT_DIG 6 / digits of precision / define
FLT_MAX 3.402823466e38 / largest floating
number /
6
C99 Headers
  • C99 supports all the headers of C89 and adds
    nine more. Most of the new headers deal with
    specialized mathematical needs or provide support
    for internationalization.
  • C99 also adds functions to many of the C89
    headers. In particular, a number of mathematical
    functions have been added to ltmath.hgt.

7
C99 Headers
New headers in C99 ltcomplex.hgt Complex
Arithmetic. Provides support for doing arithmetic
on complex and imaginary numbers. ltfenv.hgt
Floating-Point Environment. Provides access to
floating-point status flags and control modes.
Testing status flags allows a program to
determine more information about floating-point
exceptions. Changing a control mode (how rounding
is done, for example) gives a program more
control over how floating-point arithmetic is
performed. ltinttypes.hgt Format Conversion of
Integer Types. Provides functions for
manipulating greatest-width integers and
converting numeric character strings to
greatest-width integers.
8
C99 Headers
ltiso646.hgt Alternative Spellings. Provides macros
that can be used in place of certain operators.
For example, the and macro is equivalent to the
operator. ltstdbool.hgt Boolean Type and
Values. Defines the bool, true, and false
macros. ltstdint.hgt Integer Types. Provides
integer types having specified widths. For
example, int8_t is a signed integer type with
exactly 8 bits, and uint8_t is an unsigned
integer type with 8 bits.
9
C99 Headers
lttgmath.hgt Type-Generic Math. Provides
parameterized macros that represent functions in
ltmath.hgt and ltcomplex.hgt. A call of one of these
macros is expanded into a call of the
corresponding function, based on the types of the
argument(s). ltwchar.hgt Extended Multibyte and
Wide Character Utilities. Defines the wchar_t
type (among others) and provides functions for
working with multibyte characters and wide
characters. These include input and
output functions, wide string manipulation
functions, and functions that convert between
multibyte and wide character sequences.
10
C99 Headers
ltwctype.hgt Wide Character Classification and
Mapping Utilities. Provides functions for
classifying wide characters and converting their
case.
Write a Comment
User Comments (0)
About PowerShow.com