Unformatted text preview:

21. THE STANDARD LIBRARYGeneral RulesC89 HeadersSlide 4Slide 5C99 HeadersSlide 7Slide 8Slide 9Slide 1021. THE STANDARD LIBRARYGeneral 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 shouldn’t use these names for any other purpose.• Identifiers with external linkage (for example, function names) are always reserved, even if the header isn’t included.C89 Headers• <assert.h> Diagnostics. Contains only the assert macro, which enables programs to perform self-checks. If any check fails, the program terminates.#include <assert.h>void assert(int expression);/* if expression is false, writes a diagnostic message andterminates execution */C89 Headers• <ctype.h> Character Handling. Provides functions for testing and converting characters.#include <ctype.h>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 */C89 Headers• <errno.h> 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 positivevalue when an error occurs.#include <errno.h>#define errno …• <float.h> Characteristics of Floating Types. Provides macros that define the range and accuracy of floating types.#include <float.h>#define FLT_DIG 6 /* digits of precision */#define FLT_MAX 3.402823466e+38 /* largest floating number */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 <math.h>.C99 Headers• New headers in C99:<complex.h> Complex Arithmetic. Provides support for doing arithmetic on complex and imaginary numbers.<fenv.h> 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.<inttypes.h> Format Conversion of Integer Types. Provides functions for manipulating greatest-width integers and converting numeric character strings to greatest-width integers.C99 Headers<iso646.h> Alternative Spellings. Provides macros that can be used in place of certain operators. For example, the and macro is equivalent to the && operator.<stdbool.h> Boolean Type and Values. Defines the bool, true, and false macros.<stdint.h> 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.C99 Headers<tgmath.h> Type-Generic Math. Provides parameterized macros that represent functions in <math.h> and <complex.h>. A call of one of these macros is expanded into a call of the corresponding function, based on thetypes of the argument(s).<wchar.h> 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 outputfunctions, wide string manipulation functions, and functions that convert between multibyte and wide character sequences.C99 Headers<wctype.h> Wide Character Classification and Mapping Utilities. Provides functions for classifying wide characters and converting their


View Full Document

UF CGS 3460 - THE STANDARD LIBRARY

Download THE STANDARD LIBRARY
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view THE STANDARD LIBRARY and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view THE STANDARD LIBRARY 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?