Topic : An introduction to C
Author : Tom Torfs
Page : << Previous 20  Next >>
Go to page :


can assume this function is there and that it takes these parameters". In fact, we could also have written:

extern void myfunction(int number);

Unlike for variables, for function prototypes the extern is optional.
Apart from variable and function declarations (externs and prototypes), a header file is also often used to define macros, typedefs, enums, structs and unions. However, it should not be used for variable or function definitions, because this way the variable resp. function would be defined in every module where the header is included, and this will cause linker errors (unless they are defined as static, but even then it's usually a bad idea).

16. Overview of the standard library
16.1. Introduction to the standard library
This chapter provides an overview of the C standard library, on an alphabetical header by header basis. The explanations are kept short to keep the size of this document within reasonable limits. If you need more help concerning certain functions, your compiler's manual or online help may be of assistance. You may also find what you're looking for in Dinkumware's C reference, see: 17.2. Other interesting C-related online material
This overview is sorted on a strictly alphabetical basis (case and underscores are ignored).
All the library functions may be implemented as macros. If you really need a function version (for example, if the argument has side effects), you should #undef the macro first (see 13. Preprocessor macros/conditionals).
All the identifiers (variable and function names etc.) that are defined in the standard library are reserved, which means that you shouldn't use them in your own programs. Identifiers that start with an underscore are reserved in most contexts as well. [*]
[*] An exhaustive discussion of which identifiers are reserved in which contexts falls outside the scope of an introductory document about C programming. More information can be found in: 17.2. Other interesting C-related online material
In addition, the following identifiers are reserved for possible extensions to the library:

Macros:
- Macros that start with E followed by a digit or uppercase letter
- Macros that start with LC_ followed by an uppercase letter
- Macros that start with SIG or SIG_ followed by an uppercase letter
Function names:
- Function names that start with is or to followed by a lowercase letter
- Function names that start with str, mem or wcs followed by a lowercase
  letter
- The function names declared in math.h with the suffix f or l

The following header files that have been added to the original ANSI/ISO standard by normative addenda etc. or the C9X draft standard are not included here: (your compiler may not support them yet, either)

complex.h  complex arithmetic
fenv.h     floating-point environment
inttypes.h integer types
iso646.h   alternative spellings for operators
stdbool.h  standard boolean type
tgmath.h   type-generic mathematics
wchar.h    wide-character utilities
wctype.h   wide-character classification

16.2. assert.h (diagnostics)
Macros

void assert(int expression);

If NDEBUG macro is defined when assert.h is included, does nothing. Otherwise, checks whether expression is true. If it isn't, an error message containing the failed condition, the filename and line number is printed and the abort() function is called (see also 13.2. Using the assert() macro).
assert() is always defined as a macro and may not be #undef'ed.16.3. ctype.h (character handling)
Be careful that the values you pass to the functions declared in ctype.h are inside the range of an unsigned char or EOF. This may bite you if you use an implementation where the type char defaults to signed.
Functions

int isalnum(int c);

Returns nonzero if c is an alphanumeric character (letter or digit).

int isalpha(int c);

Returns nonzero if c is a letter.

int iscntrl(int c);

Returns nonzero if c is a control character.

int isdigit(int c);

Returns nonzero if c is a decimal digit.

int isgraph(int c);

Returns nonzero if c is any printing character except space.

int islower(int c);

Returns nonzero if c is a lowercase letter.

int isprint(int c);

Returns nonzero if c is a printing character including space.

int ispunct(int c);

Returns nonzero if c is any printing character other than a letter, a digit or space.

int isspace(int c);

Returns nonzero if c is a whitespace character (space, formfeed, newline, carriage return, horizontal or vertical tab).

int isupper(int c);

Returns nonzero if c is an uppercase letter.

int isxdigit(int c);

Returns nonzero if c is a hexadecimal digit.

int tolower(int c);

If c is an uppercase letter, returns the corresponding lowercase letter. Otherwise, returns c unchanged.

int toupper(int c);

If c is a lowercase letter, returns the corresponding uppercase letter. Otherwise, returns c unchanged.16.4. errno.h (error handling)
Macros

EDOM                          /* domain error */
ERANGE                        /* range error */


Integer constants representing certain error conditions. Your implementation may define more error condition macros, starting with an uppercase E and followed by an uppercase letter or digit.

errno

Integer variable that contains an error number or 0 for no error. Several library functions may set this value to nonzero if an error occurs. It is never automatically reset to 0.16.5. float.h (floating-point limits)
Macros

DBL_DIG

Number of decimal digits of precision in a double. Minimum 10.

DBL_EPSILON

Minimum positive double x such that 1.0 + x != 1.0. Maximum 1E-9.

DBL_MANT_DIG

Number of base-FLT_RADIX digits in the double mantissa.

DBL_MAX

Maximum representable finite double. Minimum 1E+37.

DBL_MAX_EXP

Maximum positive integer for which FLT_RADIX**FLT_MIN_EXP-1 is a representable, finite double.

DBL_MAX_10_EXP

Maximum positive integer for which 10**FLT_MIN_EXP is a representable, finite double. Minimum +37.

DBL_MIN

Minimum normalized double. Maximum 1E-37.

DBL_MIN_EXP

Minimum negative integer for which FLT_RADIX**FLT_MIN_EXP-1 is a normalized double.

DBL_MIN_10_EXP

Minimum negative integer for which 10**FLT_MIN_EXP is a normalized double. Maximum -37.

FLT_DIG

Number of decimal digits of precision in a float. Minimum 6.

FLT_EPSILON

Minimum positive float x such that 1.0 + x != 1.0. Maximum 1E-5.

FLT_MANT_DIG

Number of base-FLT_RADIX digits in the float mantissa.

FLT_MAX

Maximum representable finite float. Minimum 1E+37.

FLT_MAX_EXP

Maximum positive integer for which FLT_RADIX**FLT_MIN_EXP-1 is a representable, finite float.

FLT_MAX_10_EXP

Maximum positive integer for which 10**FLT_MIN_EXP is a representable, finite float. Minimum +37.

FLT_MIN

Minimum normalized float. Maximum 1E-37.

FLT_MIN_EXP

Minimum negative integer for which FLT_RADIX**FLT_MIN_EXP-1 is a normalized float.

FLT_MIN_10_EXP

Minimum negative integer for which 10**FLT_MIN_EXP is a normalized float. Maximum -37.

FLT_RADIX

Radix of floating-point exponent representation.

LDBL_DIG

Number of decimal digits of precision in a long double. Minimum 10.

LDBL_EPSILON

Minimum positive long double x such that 1.0 + x != 1.0. Maximum 1E-9.

LDBL_MANT_DIG

Number of base-FLT_RADIX digits in the long double mantissa.

LDBL_MAX

Maximum representable finite long double. Minimum 1E+37.

LDBL_MAX_EXP

Maximum positive integer for which FLT_RADIX**FLT_MIN_EXP-1 is a representable, finite long double.

LDBL_MAX_10_EXP

Maximum positive integer for which 10**FLT_MIN_EXP is a representable, finite long double. Minimum +37.

LDBL_MIN

Minimum normalized long double. Maximum 1E-37.

LDBL_MIN_EXP

Minimum negative integer for which FLT_RADIX**FLT_MIN_EXP-1 is a normalized long double.

LDBL_MIN_10_EXP

Minimum negative integer for which 10**FLT_MIN_EXP is a normalized long double. Maximum -37.16.6. limits.h (implementation limits)

CHAR_BIT

Number of bits in a byte (smallest object that is not a bit-field). Minimum 8.

CHAR_MAX

Maximum value a char can represent. Same as SCHAR_MAX if char defaults to signed, same as UCHAR_MAX if char defaults to unsigned.

CHAR_MIN

Minimum value a char can represent. Same as SCHAR_MIN if char defaults to signed, same as UCHAR_MIN if char defaults to unsigned.

INT_MAX

Maximum value an int can represent. Minimum +32767.

INT_MIN

Minimum value an int can represent. Maximum -32767.

LONG_MAX

Maximum value a long int can represent. Minimum +2147483647.

LONG_MIN

Minimum value a long int can represent. Maximum -2147483647.

MB_LEN_MAX

Maximum number of bytes in a multibyte character.

SCHAR_MAX

Maximum value a signed char can represent. Minimum +127.

SCHAR_MIN

Minimum value a signed char can represent. Maximum -127.

SHRT_MAX

Maximum value a short int can represent. Minimum +32767.

SHRT_MIN

Minimum value a short int can represent. Maximum -32767.

UCHAR_MAX

Maximum value an unsigned char can represent. Minimum 255.

UINT_MAX

Maximum value an unsigned int can represent. Minimum 65535.

ULONG_MAX

Maximum value an unsigned long int can represent. Minimum 4294967295.

USHRT_MAX

Maximum value an unsigned short int can represent. Minimum 65535.16.7. locale.h (localization)
Types

struct lconv {
   char *decimal_point;       /* decimal point character ["."] */
   char *thousands_sep;       /* digit group separating character [""] */
   char *grouping;            /* size of digit groups [""] */
   char *int_curr_symbol;     /* international currency symbol [""] */
   char *currency_symbol;     /* local currency symbol [""] */
   char *mon_decimal_point;   /* monetary decimal point [""] */
   char *mon_thousands_sep;   /* monetary digit group separator [""] */
   char *mon_grouping;        /* monetary digit group size [""] */
   char *positive_sign;


Page : << Previous 20  Next >>