C Standard Library (一)
精选
转载
[Last modified : 2006-11-30]
void assert(int expression);
- Macro used for internal error detection. (Ignored if
NDEBUG is defined where <assert.h> is included.) If expression equals zero, message printed on stderr and abort called to terminate execution. Source filename and line number in message are from preprocessor macros __FILE__ and __LINE__.
int isalnum(int c);
isalpha(c) or isdigit(c)
int isalpha(int c);
isupper(c) or islower(c)
int iscntrl(int c);
- is control character. In ASCII, control characters are
0x00 (NUL) to 0x1F (US), and 0x7F (DEL)
int isdigit(int c);
- is decimal digit
int isgraph(int c);
- is printing character other than space
int islower(int c);
- is lower-case letter
int isprint(int c);
- is printing character (including space). In ASCII, printing characters are
0x20 (' ') to 0x7E ('~')
int ispunct(int c);
- is printing character other than space, letter, digit
int isspace(int c);
- is space, formfeed, newline, carriage return, tab, vertical tab
int isupper(int c);
- is upper-case letter
int isxdigit(int c);
- is hexadecimal digit
int tolower(int c);
- return lower-case equivalent
int toupper(int c);
- return upper-case equivalent
errno
- object to which certain library functions assign specific positive values on error
EDOM
- code used for domain errors
ERANGE
- code used for range errors
Notes:
- other implementation-defined error values are permitted
- to determine the value (if any) assigned to errno by a library function, a program should assign zero to errno immediately prior to the function call
FLT_RADIX
- radix of floating-point representations
FLT_ROUNDS
- floating-point rounding mode
Where the prefix "FLT" pertains to type float, "DBL" to type double, and "LDBL" to type long double:
FLT_DIG
DBL_DIG
LDBL_DIG
- precision (in decimal digits)
FLT_EPSILON
DBL_EPSILON
LDBL_EPSILON
- smallest number x such that
1.0 + x != 1.0
FLT_MANT_DIG
DBL_MANT_DIG
LDBL_MANT_DIG
- number of digits, base
FLT_RADIX, in mantissa
FLT_MAX
DBL_MAX
LDBL_MAX
- maximum number
FLT_MAX_EXP
DBL_MAX_EXP
LDBL_MAX_EXP
- largest positive integer exponent to which
FLT_RADIX can be raised and remain representable
FLT_MIN
DBL_MIN
LDBL_MIN
- minimum normalised number
FLT_MIN_EXP
DBL_MIN_EXP
LDBL_MIN_EXP
- smallest negative integer exponent to which
FLT_RADIX can be raised and remain representable
CHAR_BIT
- number of bits in a
char
CHAR_MAX
- maximum value of type
char
CHAR_MIN
- minimum value of type
char
SCHAR_MAX
- maximum value of type
signed char
SCHAR_MIN
- minimum value of type
signed char
UCHAR_MAX
- maximum value of type
unsigned char
SHRT_MAX
- maximum value of type
short
SHRT_MIN
- minimum value of type
short
USHRT_MAX
- maximum value of type
unsigned short
INT_MAX
- maximum value of type
int
INT_MIN
- minimum value of type
int
UINT_MAX
- maximum value of type
unsigned int
LONG_MAX
- maximum value of type
long
LONG_MIN
- minimum value of type
long
ULONG_MAX
- maximum value of type
unsigned long
struct lconv
- Describes formatting of monetary and other numeric values:
char* decimal_point;
- decimal point for non-monetary values
char* grouping;
- sizes of digit groups for non-monetary values
char* thousands_sep;
- separator for digit groups for non-monetary values (left of "decimal point")
char* currency_symbol;
- currency symbol
char* int_curr_symbol;
- international currency symbol
char* mon_decimal_point;
- decimal point for monetary values
char* mon_grouping;
- sizes of digit groups for monetary values
char* mon_thousands_sep;
- separator for digit groups for monetary values (left of "decimal point")
char* negative_sign;
- negative sign for monetary values
char* positive_sign;
- positive sign for monetary values
char frac_digits;
- number of digits to be displayed to right of "decimal point" for monetary values
char int_frac_digits;
- number of digits to be displayed to right of "decimal point" for international monetary values
char n_cs_precedes;
- whether currency symbol precedes (
1) or follows (0) negative monetary values
char n_sep_by_space;
- whether currency symbol is (
1) or is not (0) separated by space from negative monetary values
char n_sign_posn;
- format for negative monetary values:
0
- parentheses surround quantity and currency symbol
1
- sign precedes quantity and currency symbol
2
- sign follows quantity and currency symbol
3
- sign immediately precedes currency symbol
4
- sign immediately follows currency symbol
char p_cs_precedes;
- whether currency symbol precedes (
1) or follows (0) positive monetary values
char p_sep_by_space;
- whether currency symbol is (
1) or is not (0) separated by space from non-negative monetary values
char p_sign_posn;
- format for non-negative monetary values, with values as for
n_sign_posn
Implementations may change field order and include additional fields. Standard C Library functions use only decimal_point.
struct lconv* localeconv(void);
- returns pointer to formatting information for current locale
char* setlocale(int category, const char* locale);
- Sets components of locale according to specified
category and locale. Returns string describing new locale or null on error. (Implementations are permitted to define values of category additional to those describe here.)
LC_ALL
category argument for all categories
LC_NUMERIC
category for numeric formatting information
LC_MONETARY
category for monetary formatting information
LC_COLLATE
category for information affecting collating functions
LC_CTYPE
category for information affecting character class tests functions
LC_TIME
category for information affecting time conversions functions
NULL
- null pointer constant
On domain error, implementation-defined value returned and
errno set to
EDOM. On range error,
errno set to
ERANGE and return value is
HUGE_VAL with correct sign for overflow, or zero for underflow. Angles are in radians.
HUGE_VAL
- magnitude returned (with correct sign) on overflow error
double exp(double x);
- exponential of
x
double log(double x);
- natural logarithm of
x
double log10(double x);
- base-10 logarithm of
x
double pow(double x, double y);
x raised to power y
double sqrt(double x);
- square root of
x
double ceil(double x);
- smallest integer not less than
x
double floor(double x);
- largest integer not greater than
x
double fabs(double x);
- absolute value of
x
double ldexp(double x, int n);
x times 2 to the power n
double frexp(double x, int* exp);
- if
x non-zero, returns value, with absolute value in interval [1/2, 1), and assigns to *exp integer such that product of return value and 2 raised to the power *exp equals x; if x zero, both return value and *exp are zero
double modf(double x, double* ip);
- returns fractional part and assigns to
*ip integral part of x, both with same sign as x
double fmod(double x, double y);
- if
y non-zero, floating-point remainder of x/y, with same sign as x; if y zero, result is implementation-defined
double sin(double x);
- sine of
x
double cos(double x);
- cosine of
x
double tan(double x);
- tangent of
x
double asin(double x);
- arc-sine of
x
double acos(double x);
- arc-cosine of
x
double atan(double x);
- arc-tangent of
x
double atan2(double y, double x);
- arc-tangent of
y/x
double sinh(double x);
- hyperbolic sine of
x
double cosh(double x);
- hyperbolic cosine of
x
double tanh(double x);
- hyperbolic tangent of
x
jmp_buf
- type of object holding context information
int setjmp(jmp_buf env);
- Saves context information in
env and returns zero. Subsequent call to longjmp with same env returns non-zero.
void longjmp(jmp_buf env, int val);
- Restores context saved by most recent call to
setjmp with specified env. Execution resumes as a second return from setjmp, with returned value val if specified value non-zero, or 1 otherwise.
SIGABRT
- abnormal termination
SIGFPE
- arithmetic error
SIGILL
- invalid execution
SIGINT
- (asynchronous) interactive attention
SIGSEGV
- illegal storage access
SIGTERM
- (asynchronous) termination request
SIG_DFL
- specifies default signal handling
SIG_ERR
signal return value indicating error
SIG_IGN
- specifies that signal should be ignored
void (*signal(int sig, void (*handler)(int)))(int);
- Install handler for subsequent signal sig. If
handler is SIG_DFL, implementation-defined default behaviour will be used; if SIG_IGN, signal will be ignored; otherwise function pointed to by handler will be invoked with argument sig. In the last case, handling is restored to default behaviour before handler is called. If handler returns, execution resumes where signal occurred. signal returns the previous handler or SIG_ERR on error. Initial state is implementation-defined. Implementations may may define signals additional to those listed here.
int raise(int sig);
- Sends signal
sig. Returns zero on success.
va_list
- type of object holding context information
void va_start(va_list ap, lastarg);
- Initialisation macro which must be called once before any unnamed argument is accessed. Stores context information in
ap. lastarg is the last named parameter of the function.
type va_arg(va_list ap, type);
- Yields value of the type (
type) and value of the next unnamed argument.
void va_end(va_list ap);
- Termination macro which must be called once after argument processing and before exit from function.
NULL
- Null pointer constant.
offsetof(stype, m)
- Offset (in bytes) of member
m from start of structure type stype.
ptrdiff_t
- Type for objects declared to store result of subtracting pointers.
size_t
- Type for objects declared to store result of
sizeof operator.