您的位置:首页 > 其它

C标准库学习之其他

2007-05-26 17:20 134 查看
C Standard Library

[Last modified : 2006-11-30]
Contents

* <assert.h> : 诊断
* <ctype.h> : 字符类测试
* <errno.h> : 其他库函数的错误代码报告
* <float.h> : Implementation-defined Floating-Point Limits
* <limits.h> : Implementation-defined Limits
* <locale.h> : Locale-specific Information
* <math.h> : 数学函数
* <setjmp.h> : Non-local Jumps
* <signal.h> : Signals
* <stdarg.h> : Variable Argument Lists
* <stddef.h> : 一般用途的定义
* <stdio.h> : I/O库
* <stdlib.h> :标准库
* <string.h> : 字符串函数
* <time.h> : 时间日期函数

<assert.h>

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__.
一个用于内部错误诊断的宏。

<ctype.h>
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.h>
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

<float.h>
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

<limits.h>
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

<locale.h>
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

<math.h>


<setjmp.h>
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.

<signal.h>

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.

<stdarg.h>

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.

<stddef.h>

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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: