分类: C/C++
2009-12-30 16:54:58
void assert(int expression);
NDEBUG
is defined where
is included.) If expression equals zero, message printed on
and called to terminate execution. Source filename and line number in message arefrom 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);
0x00
(NUL
) to 0x1F
(US
), and 0x7F
(DEL
)int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
0x20
(' '
) to 0x7E
('~'
)int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);
[]
Notes:
[]
FLT_ROUNDS
Where the prefix "FLT
" pertains to type float
, "DBL
" to type double
, and "LDBL
" to type long double
:
FLT_DIG
DBL_DIG
LDBL_DIG
FLT_EPSILON
DBL_EPSILON
LDBL_EPSILON
1.0 + x != 1.0
FLT_MANT_DIG
DBL_MANT_DIG
LDBL_MANT_DIG
, in mantissaFLT_MAX
DBL_MAX
LDBL_MAX
FLT_MAX_EXP
DBL_MAX_EXP
LDBL_MAX_EXP
can be raised and remain representableFLT_MIN
DBL_MIN
LDBL_MIN
FLT_MIN_EXP
DBL_MIN_EXP
LDBL_MIN_EXP
can be raised and remain representable[]
CHAR_BIT
char
CHAR_MAX
char
CHAR_MIN
char
SCHAR_MAX
signed char
SCHAR_MIN
signed char
UCHAR_MAX
unsigned char
SHRT_MAX
short
SHRT_MIN
short
USHRT_MAX
unsigned short
INT_MAX
int
INT_MIN
int
UINT_MAX
unsigned int
long
long
unsigned long
[]
char* ;
char* grouping;
char* thousands_sep;
char* currency_symbol;
char* int_curr_symbol;
char* mon_decimal_point;
char* mon_grouping;
char* mon_thousands_sep;
char* negative_sign;
char* positive_sign;
char frac_digits;
char int_frac_digits;
char n_cs_precedes;
1
) or follows (0
) negative monetary valueschar n_sep_by_space;
1
) or is not (0
) separated by space from negative monetary values;
0
1
2
3
4
char p_cs_precedes;
1
) or follows (0
) positive monetary valueschar p_sep_by_space;
1
) or is not (0
) separated by space from non-negative monetary valueschar p_sign_posn;
.* localeconv(void);
char* setlocale(int , const char* locale);
and locale
. Returns string describing new locale or null on error. (Implementations are permitted to define values of
additional to those describe here.)LC_ALL
argument for all categoriesLC_NUMERIC
for numeric formatting informationLC_MONETARY
for monetary formatting informationLC_COLLATE
for information affecting collating functionsLC_CTYPE
for information affecting functionsLC_TIME
for information affecting time conversions functionsNULL
[]
On domain error, implementation-defined value returned and set to
. On range error,
set to
and return value is
with correct sign for overflow, or zero for underflow. Angles are in radians.
double exp(double x);
x
double log(double x);
x
double log10(double x);
x
double pow(double x, double y);
x
raised to power y
double sqrt(double x);
x
double ceil(double x);
x
double floor(double x);
x
double fabs(double x);
x
double ldexp(double x, int n);
x
times 2 to the power n
double frexp(double x, int* exp);
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 zerodouble modf(double x, double* ip);
*ip
integral part of x
, both with same sign as x
double fmod(double x, double y);
y
non-zero, floating-point remainder of x/y
, with same sign as x
; if y
zero, result is implementation-defineddouble sin(double x);
x
double cos(double x);
x
double tan(double x);
x
double asin(double x);
x
double acos(double x);
x
double atan(double x);
x
double atan2(double y, double x);
y/x
double sinh(double x);
x
double cosh(double x);
x
double tanh(double x);
x
[]
int setjmp( env);
env
and returns zero. Subsequent call to
with same env returns non-zero.void longjmp( env, int val);
with specified env
. Execution resumes as a second return from
, with returned value val
if specified value non-zero, or 1 otherwise.[]
SIGFPE
SIGILL
SIGINT
SIGSEGV
SIGTERM
return value indicating error
void (*(int sig, void (*handler)(int)))(int);
handler
is
, implementation-defined default behaviour will be used; if
, 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.
returns the previous handler or SIG_ERR
on error. Initial state is implementation-defined. Implementations may may define signals additional to those listed here.
sig
. Returns zero on success.[]
void ( ap, lastarg);
ap
. lastarg
is the last named parameter of the function.type ( ap, type);
type
) and value of the next unnamed argument.void ( ap);
[]
NULL
offsetof(stype, m)
m
from start of structure type stype
.ptrdiff_t
size_t
sizeof
operator.[]
.
FILENAME_MAX
FOPEN_MAX
.
origin
argument to
specifying current file position.
origin
argument to
specifying end of file.
origin
argument to
specifying beginning of file.
.
mode
argument to
specifying full buffering.
mode
argument to
specifying line buffering.
mode
argument to
specifying no buffering.
sizeof
operator.* (const char* filename, const char* mode);
filename
and returns a stream, or
on failure. mode
may be one of the following for text files:"r"
"w"
"a"
"r+"
"w+"
"a+"
b
included (after the first character), for binary files.* freopen(const char* filename, const char* mode, * stream);
stream
, then opens file filename
with specified mode and associates it with stream
. Returns stream
or
on error.int (* stream);
stream
and returns zero on success or on error. Effect undefined for input stream. ()
flushes all output streams.int (* stream);
on error, zero otherwise.int (const char* filename);
int (const char* oldname, const char* newname);
oldname
to newname
. Returns non-zero on failure.* ();
"wb+"
) which will be removed when closed or on normal program termination. Returns stream or
on failure.char* (char s[]);
s
(if s
non-null) and returns unique name for a temporary file. Unique name is returned for each of the first
invocations.int (* stream, char* buf, int mode, size);
stream
. mode
is
for full buffering,
for line buffering,
for no buffering. Non-null buf
specifies buffer of size size
to be used; otherwise, a buffer is allocated. Returns non-zero on error. Call must be before any other operation on stream.void (* stream, char* buf);
buf
, turns off buffering, otherwise equivalent to (void)(stream, buf, , )
.int (* stream, const char* format, ...);
format
) and writes output to stream stream
. Number of characters written, or negative value on error, is returned. Conversion specifications consist of:%
-
+
0
#
o
, first digit will be zero, for [xX
], prefix 0x
or 0X
to non-zero value, for [eEfgG
], always decimal point, for [gG
]trailing zeros not removed.*
, value taken from next argument (which must be int
)..
(separating width from precision):s
, maximum characters to be printed from the string, for [eEf
], digits after decimal point, for [gG
], significant digits, for an integer, minimum number of digits to be printed. If specified as *
, value taken from next argument (which must be int
).h
short
or unsigned short
l
long
or unsigned long
L
long double
d,i
int
argument, printed in signed decimal notationo
int
argument, printed in unsigned octal notationx,X
int
argument, printed in unsigned hexadecimal notationu
int
argument, printed in unsigned decimal notationc
int
argument, printed as single characters
char*
argumentf
double
argument, printed with format [-
]mmm.
ddde,E
double
argument, printed with format [-
]m.
dddddd(e
|E
)(+
|-
)xxg,G
double
argumentp
void*
argument, printed as pointern
int*
argument : the number of characters written to this point is written into argument%
int (const char* format, ...);
(f, ...)
is equivalent to(, f, ...)
int (char* s, const char* format, ...);
s
, which must be large enough to hold the output, rather than to a stream. Output is NUL
-terminated. Returns length (excluding the terminating NUL
).int (* stream, const char* format, arg);
with variable argument list replaced by arg
, which must have been initialised by the
macro (and may have been used in calls to
).int (const char* format, arg);
with variable argument list replaced by arg
, which must have been initialised by the
macro (and may have been used in calls to
).int vsprintf(char* s, const char* format, arg);
with variable argument list replaced by arg
, which must have been initialised by the
macro (and may have been used in calls to
).int (* stream, const char* format, ...);
stream
according to format format
. The function returns when format
is fully processed. Returns number of items converted and assigned, or
if end-of-file or error occurs before any conversion. Each of the arguments following format
must be a pointer. Format string may contain:%
*
"h
short
rather than int
l
long
rather than int
, or double
rather than float
L
long double
rather than float
d
int*
parameter requiredi
int*
parameter required; decimal, octal or hexo
int*
parameter requiredu
unsigned int*
parameter requiredx
int*
parameter requiredc
char*
parameter required; white-space is not skipped, and NUL
-termination is not performeds
char*
parameter required; string is NUL
-terminatede,f,g
float*
parameter requiredp
void*
parameter requiredn
int*
parameter required[...]
char*
parameter required; string is NUL
-terminated[^...]
char*
parameter required; string is NUL
-terminated%
%
; no assignmentint (const char* format, ...);
(f, ...)
is equivalent to (, f, ...)
int sscanf(char* s, const char* format, ...);
, but input read from string s
.int (* stream);
stream
, or
on end-of-file or error.char* (char* s, int n, * stream);
stream
to s
, stopping when n
-1 characters copied, newline copied, end-of-file reached or error occurs. If no error, s
is NUL
-terminated. Returns
on end-of-file or error, s
otherwise.(int c, * stream);
c
, to stream stream
. Returns c
, or
on error.char* (const char* s, * stream);
s
, to (output) stream stream. Returns non-negative on success or
on error.int (* stream);
except that it may be a macro.int (void);
()
.char* (char* s);
into s
until newline encountered, end-of-file reached, or error occurs. Does not copy newline. NUL
-terminates s
. Returns s
, or
on end-of-file or error. Should not be used because of the potential for buffer overflow.int (int c, * stream);
except that it may be a macro.int (int c);
putchar(c)
is equivalent to (c, )
.int (const char* s);
s
(excluding terminating NUL
) and a newline to
. Returns non-negative on success,
on error.int (int c, * stream);
c
(which must not be
), onto (input) stream stream
such that it will be returned by the next read. Only one character of pushback is guaranteed (for each stream). Returns c
, or
on error. (void* ptr, size, nobj, * stream);
nobj
objects of size size
from stream stream
into ptr
and returns number of objects read. (
and
can be used to check status.)size_t (const void* ptr, size, nobj, * stream);
stream
, nobj
objects of size size
from array ptr
. Returns number of objects written.int (* stream, long offset, int origin);
stream
and clears end-of-file indicator. For a binary stream, file position is set to offset
bytes from the position indicated by origin
: beginning of file for
, current position for
, or end of file for
. Behaviour is similar for a text stream, but offset
must be zero or, for
only, a value returned by
. Returns non-zero on error.long (* stream);
stream
, or -1
on error.void (* stream);
(stream, 0L, SEEK_SET); (stream)
.int (* stream, * ptr);
stream
in *ptr
. Returns non-zero on error.int (* stream, const * ptr);
*ptr
. Returns non-zero on error.void (* stream);
stream
.int (* stream);
stream
.int (* stream);
stream
.void (const char* s);
s
(if non-null) and ()
to standard error as would:(, "%s: %s\n", (s != ? s : ""), ())
[]
status
argument to
indicating failure.
status
argument to
indicating success.
()
.
()
. Structure having members:int quot;
int rem;
()
. Structure having members:long quot;
long rem;
sizeof
operator.int abs(int n);
long labs(long n);
n
. (int num, int denom);
(long num, long denom);
num/denom
.double atof(const char* s);
(s, (char**))
except that
is not necessarily set on conversion error.int atoi(const char* s);
(int)(s, (char**), 10)
except that
is not necessarily set on conversion error.long atol(const char* s);
(s, (char**), 10)
except that
is not necessarily set on conversion error.double (const char* s, char** endp);
s
to type double
. If endp
non-null, stores pointer to unconverted suffix in *endp
. On overflow, sets
to
and returns
with the appropriate sign; on underflow, sets
to
and returns zero; otherwise returns converted value.long (const char* s, char** endp, int base);
s
to type long
. If endp
non-null, stores pointer to unconverted suffix in *endp
. If base
between 2 and 36, that base used for conversion; if zero, leading (after any sign) 0X
or 0x
implies hexadecimal, leading 0
(after any sign) implies octal, otherwise decimal assumed. Leading 0X
or 0x
permitted for base hexadecimal. On overflow, sets
to
and returns
or
(as appropriate for sign); otherwise returns converted value.unsigned long (const char* s, char** endp, int base);
except result is unsigned long
and value on overflow is
.void* calloc( nobj, size);
nobj
objects each of size size
, or
on error.void* malloc( size);
on error.void* realloc(void* p, size_t size);
size
, initialised, to minimum of old and new sizes, to existing contents of p
(if non-null), or
on error. On success, old object deallocated, otherwise unchanged.void free(void* p);
p
non-null, deallocates space to which it points.void ();
()
.void (int status);
are called (in reverse order to that in which installed), open files are flushed, open streams are closed and control is returned to environment. status
is returned to environment in implementation-dependent manner. Zero or
indicates successful termination and
indicates unsuccessful termination. Implementations may define other values.int (void (*fcm)(void));
fcn
to be called when program terminates normally (or when main
returns). Returns non-zero on failure.int system(const char* s);
s
is not
, passes s
to environment for execution, and returns status reported by command processor; if s
is
, non-zero returned if environment has a command processor.char* getenv(const char* name);
name
from implementation's environment, or
if no such string exists.void* bsearch(const void* key, const void* base, n, size, int (*cmp)(const void* keyval, const void* datum));
base
(of n
objects each of size size
) for item matching key
according to comparison function cmp
. cmp
must return negative value if first argument is less than second, zero if equal and positive if greater. Items of base
are assumed to be in ascending order (according to cmp
). Returns a pointer to an item matching key
, or
if none found.void qsort(void* base, n, size, int (*cmp)(const void*, const void*));
base
(of n
objects each of size size
) according to comparison function cmp
. cmp
must return negative value if first argument is less than second, zero if equal and positive if greater.int (void);
0
to
.void srand(unsigned int seed);
seed
as seed for new sequence of pseudo-random numbers. Initial seed is 1
.[]
sizeof
operator.char* strcpy(char* s, const char* ct);
ct
to s
including terminating NUL
and returns s
.char* strncpy(char* s, const char* ct, n);
n
characters of ct
to s
. Pads with NUL
characters if ct
is of length less than n
. Note that this may leave s
without NUL
-termination. Return s
.char* strcat(char* s, const char* ct);
ct
to s
and return s
.char* strncat(char* s, const char* ct, n);
n
characters of ct
to s
. NUL
-terminates s
and return it.int strcmp(const char* cs, const char* ct);
cs
with ct
, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.int strncmp(const char* cs, const char* ct, n);
n
characters of cs
and ct
, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.int strcoll(const char* cs, const char* ct);
cs
with ct
according to locale, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.char* strchr(const char* cs, int c);
c
in cs
, or
if not found.char* strrchr(const char* cs, int c);
c
in cs
, or
if not found. strspn(const char* cs, const char* ct);
cs
which consists of characters which are in ct
. strcspn(const char* cs, const char* ct);
cs
which consists of characters which are not in ct
.char* strpbrk(const char* cs, const char* ct);
cs
of any character of ct
, or
if none is found.char* strstr(const char* cs, const char* ct);
ct
within cs
, or
if none is found. strlen(const char* cs);
cs
.
n
.char* strtok(char* s, const char* t);
s
for next token delimited by any character from ct
. Non-
s
indicates the first call of a sequence. If a token is found, it is NUL
-terminated and returned, otherwise
is returned. ct
need not be identical for each call in a sequence. strxfrm(char* s, const char* ct, n);
s
no more than n
characters (including terminating NUL
) of a string produced from ct
according to a locale-specific transformation. Returns length of entire transformed string.void* (void* s, const void* ct, n);
n
characters from ct
to s
and returns s
. s
may be corrupted if objects overlap.void* memmove(void* s, const void* ct, n);
n
characters from ct
to s
and returns s
. s
will not be corrupted if objects overlap.int memcmp(const void* cs, const void* ct, n);
n
characters of cs
and ct
, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.void* memchr(const void* cs, int c, n);
c
in first n
characters of cs
, or
if not found.void* memset(void* s, int c, n);
n
characters of s
by c
and returns s
.[]
CLOCKS_PER_SEC
units per second.
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
clock(void);
-1
if not available. time(* tp);
-1
if not available. If tp
is non-
, return value is also assigned to *tp
.double difftime( time2, time1);
time2
and time1
. mktime(* tp);
*tp
to fall withing normal ranges. Returns the corresponding calendar time, or -1
if it cannot be represented.char* (const * tp);
Sun Jan 3 13:08:42 1988\n\0
char* ctime(const * tp);
tp
converted to local time. Equivalent to:((tp))
* gmtime(const * tp);
*tp
converted to Coordinated Universal Time, or
if not available.* (const * tp);
*tp
converted into localtime.size_t strftime(char* s, size_t smax, const char* fmt, const * tp);
*tp
into s
according to fmt
. Places no more than smax
characters into s
, and returns number of characters produced (excluding terminating NUL
), or 0
if greater than smax
. Formatting conversions (%c
) are:A
a
B
b
c
d
01
-31
]H
00
-23
]I
01
-12
]j
001
-366
]M
00
-59
]m
01
-12
]p
AM
" or "PM
"S
00
-61
]U
00
-53
]W
00
-53
]w
0
) [0
-6
]X
x
Y
y
00
-99
]Z
%
%
[]
void assert(int expression);
NDEBUG
is defined where
is included.) If expression equals zero, message printed on
and called to terminate execution. Source filename and line number in message arefrom 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);
0x00
(NUL
) to 0x1F
(US
), and 0x7F
(DEL
)int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
0x20
(' '
) to 0x7E
('~'
)int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);
[]
Notes:
[]
FLT_ROUNDS
Where the prefix "FLT
" pertains to type float
, "DBL
" to type double
, and "LDBL
" to type long double
:
FLT_DIG
DBL_DIG
LDBL_DIG
FLT_EPSILON
DBL_EPSILON
LDBL_EPSILON
1.0 + x != 1.0
FLT_MANT_DIG
DBL_MANT_DIG
LDBL_MANT_DIG
, in mantissaFLT_MAX
DBL_MAX
LDBL_MAX
FLT_MAX_EXP
DBL_MAX_EXP
LDBL_MAX_EXP
can be raised and remain representableFLT_MIN
DBL_MIN
LDBL_MIN
FLT_MIN_EXP
DBL_MIN_EXP
LDBL_MIN_EXP
can be raised and remain representable[]
CHAR_BIT
char
CHAR_MAX
char
CHAR_MIN
char
SCHAR_MAX
signed char
SCHAR_MIN
signed char
UCHAR_MAX
unsigned char
SHRT_MAX
short
SHRT_MIN
short
USHRT_MAX
unsigned short
INT_MAX
int
INT_MIN
int
UINT_MAX
unsigned int
long
long
unsigned long
[]
char* ;
char* grouping;
char* thousands_sep;
char* currency_symbol;
char* int_curr_symbol;
char* mon_decimal_point;
char* mon_grouping;
char* mon_thousands_sep;
char* negative_sign;
char* positive_sign;
char frac_digits;
char int_frac_digits;
char n_cs_precedes;
1
) or follows (0
) negative monetary valueschar n_sep_by_space;
1
) or is not (0
) separated by space from negative monetary values;
0
1
2
3
4
char p_cs_precedes;
1
) or follows (0
) positive monetary valueschar p_sep_by_space;
1
) or is not (0
) separated by space from non-negative monetary valueschar p_sign_posn;
.* localeconv(void);
char* setlocale(int , const char* locale);
and locale
. Returns string describing new locale or null on error. (Implementations are permitted to define values of
additional to those describe here.)LC_ALL
argument for all categoriesLC_NUMERIC
for numeric formatting informationLC_MONETARY
for monetary formatting informationLC_COLLATE
for information affecting collating functionsLC_CTYPE
for information affecting functionsLC_TIME
for information affecting time conversions functionsNULL
[]
On domain error, implementation-defined value returned and set to
. On range error,
set to
and return value is
with correct sign for overflow, or zero for underflow. Angles are in radians.
double exp(double x);
x
double log(double x);
x
double log10(double x);
x
double pow(double x, double y);
x
raised to power y
double sqrt(double x);
x
double ceil(double x);
x
double floor(double x);
x
double fabs(double x);
x
double ldexp(double x, int n);
x
times 2 to the power n
double frexp(double x, int* exp);
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 zerodouble modf(double x, double* ip);
*ip
integral part of x
, both with same sign as x
double fmod(double x, double y);
y
non-zero, floating-point remainder of x/y
, with same sign as x
; if y
zero, result is implementation-defineddouble sin(double x);
x
double cos(double x);
x
double tan(double x);
x
double asin(double x);
x
double acos(double x);
x
double atan(double x);
x
double atan2(double y, double x);
y/x
double sinh(double x);
x
double cosh(double x);
x
double tanh(double x);
x
[]
int setjmp( env);
env
and returns zero. Subsequent call to
with same env returns non-zero.void longjmp( env, int val);
with specified env
. Execution resumes as a second return from
, with returned value val
if specified value non-zero, or 1 otherwise.[]
SIGFPE
SIGILL
SIGINT
SIGSEGV
SIGTERM
return value indicating error
void (*(int sig, void (*handler)(int)))(int);
handler
is
, implementation-defined default behaviour will be used; if
, 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.
returns the previous handler or SIG_ERR
on error. Initial state is implementation-defined. Implementations may may define signals additional to those listed here.
sig
. Returns zero on success.[]
void ( ap, lastarg);
ap
. lastarg
is the last named parameter of the function.type ( ap, type);
type
) and value of the next unnamed argument.void ( ap);
[]
NULL
offsetof(stype, m)
m
from start of structure type stype
.ptrdiff_t
size_t
sizeof
operator.[]
.
FILENAME_MAX
FOPEN_MAX
.
origin
argument to
specifying current file position.
origin
argument to
specifying end of file.
origin
argument to
specifying beginning of file.
.
mode
argument to
specifying full buffering.
mode
argument to
specifying line buffering.
mode
argument to
specifying no buffering.
sizeof
operator.* (const char* filename, const char* mode);
filename
and returns a stream, or
on failure. mode
may be one of the following for text files:"r"
"w"
"a"
"r+"
"w+"
"a+"
b
included (after the first character), for binary files.* freopen(const char* filename, const char* mode, * stream);
stream
, then opens file filename
with specified mode and associates it with stream
. Returns stream
or
on error.int (* stream);
stream
and returns zero on success or on error. Effect undefined for input stream. ()
flushes all output streams.int (* stream);
on error, zero otherwise.int (const char* filename);
int (const char* oldname, const char* newname);
oldname
to newname
. Returns non-zero on failure.* ();
"wb+"
) which will be removed when closed or on normal program termination. Returns stream or
on failure.char* (char s[]);
s
(if s
non-null) and returns unique name for a temporary file. Unique name is returned for each of the first
invocations.int (* stream, char* buf, int mode, size);
stream
. mode
is
for full buffering,
for line buffering,
for no buffering. Non-null buf
specifies buffer of size size
to be used; otherwise, a buffer is allocated. Returns non-zero on error. Call must be before any other operation on stream.void (* stream, char* buf);
buf
, turns off buffering, otherwise equivalent to (void)(stream, buf, , )
.int (* stream, const char* format, ...);
format
) and writes output to stream stream
. Number of characters written, or negative value on error, is returned. Conversion specifications consist of:%
-
+
0
#
o
, first digit will be zero, for [xX
], prefix 0x
or 0X
to non-zero value, for [eEfgG
], always decimal point, for [gG
]trailing zeros not removed.*
, value taken from next argument (which must be int
)..
(separating width from precision):s
, maximum characters to be printed from the string, for [eEf
], digits after decimal point, for [gG
], significant digits, for an integer, minimum number of digits to be printed. If specified as *
, value taken from next argument (which must be int
).h
short
or unsigned short
l
long
or unsigned long
L
long double
d,i
int
argument, printed in signed decimal notationo
int
argument, printed in unsigned octal notationx,X
int
argument, printed in unsigned hexadecimal notationu
int
argument, printed in unsigned decimal notationc
int
argument, printed as single characters
char*
argumentf
double
argument, printed with format [-
]mmm.
ddde,E
double
argument, printed with format [-
]m.
dddddd(e
|E
)(+
|-
)xxg,G
double
argumentp
void*
argument, printed as pointern
int*
argument : the number of characters written to this point is written into argument%
int (const char* format, ...);
(f, ...)
is equivalent to(, f, ...)
int (char* s, const char* format, ...);
s
, which must be large enough to hold the output, rather than to a stream. Output is NUL
-terminated. Returns length (excluding the terminating NUL
).int (* stream, const char* format, arg);
with variable argument list replaced by arg
, which must have been initialised by the
macro (and may have been used in calls to
).int (const char* format, arg);
with variable argument list replaced by arg
, which must have been initialised by the
macro (and may have been used in calls to
).int vsprintf(char* s, const char* format, arg);
with variable argument list replaced by arg
, which must have been initialised by the
macro (and may have been used in calls to
).int (* stream, const char* format, ...);
stream
according to format format
. The function returns when format
is fully processed. Returns number of items converted and assigned, or
if end-of-file or error occurs before any conversion. Each of the arguments following format
must be a pointer. Format string may contain:%
*
"h
short
rather than int
l
long
rather than int
, or double
rather than float
L
long double
rather than float
d
int*
parameter requiredi
int*
parameter required; decimal, octal or hexo
int*
parameter requiredu
unsigned int*
parameter requiredx
int*
parameter requiredc
char*
parameter required; white-space is not skipped, and NUL
-termination is not performeds
char*
parameter required; string is NUL
-terminatede,f,g
float*
parameter requiredp
void*
parameter requiredn
int*
parameter required[...]
char*
parameter required; string is NUL
-terminated[^...]
char*
parameter required; string is NUL
-terminated%
%
; no assignmentint (const char* format, ...);
(f, ...)
is equivalent to (, f, ...)
int sscanf(char* s, const char* format, ...);
, but input read from string s
.int (* stream);
stream
, or
on end-of-file or error.char* (char* s, int n, * stream);
stream
to s
, stopping when n
-1 characters copied, newline copied, end-of-file reached or error occurs. If no error, s
is NUL
-terminated. Returns
on end-of-file or error, s
otherwise.(int c, * stream);
c
, to stream stream
. Returns c
, or
on error.char* (const char* s, * stream);
s
, to (output) stream stream. Returns non-negative on success or
on error.int (* stream);
except that it may be a macro.int (void);
()
.char* (char* s);
into s
until newline encountered, end-of-file reached, or error occurs. Does not copy newline. NUL
-terminates s
. Returns s
, or
on end-of-file or error. Should not be used because of the potential for buffer overflow.int (int c, * stream);
except that it may be a macro.int (int c);
putchar(c)
is equivalent to (c, )
.int (const char* s);
s
(excluding terminating NUL
) and a newline to
. Returns non-negative on success,
on error.int (int c, * stream);
c
(which must not be
), onto (input) stream stream
such that it will be returned by the next read. Only one character of pushback is guaranteed (for each stream). Returns c
, or
on error. (void* ptr, size, nobj, * stream);
nobj
objects of size size
from stream stream
into ptr
and returns number of objects read. (
and
can be used to check status.)size_t (const void* ptr, size, nobj, * stream);
stream
, nobj
objects of size size
from array ptr
. Returns number of objects written.int (* stream, long offset, int origin);
stream
and clears end-of-file indicator. For a binary stream, file position is set to offset
bytes from the position indicated by origin
: beginning of file for
, current position for
, or end of file for
. Behaviour is similar for a text stream, but offset
must be zero or, for
only, a value returned by
. Returns non-zero on error.long (* stream);
stream
, or -1
on error.void (* stream);
(stream, 0L, SEEK_SET); (stream)
.int (* stream, * ptr);
stream
in *ptr
. Returns non-zero on error.int (* stream, const * ptr);
*ptr
. Returns non-zero on error.void (* stream);
stream
.int (* stream);
stream
.int (* stream);
stream
.void (const char* s);
s
(if non-null) and ()
to standard error as would:(, "%s: %s\n", (s != ? s : ""), ())
[]
status
argument to
indicating failure.
status
argument to
indicating success.
()
.
()
. Structure having members:int quot;
int rem;
()
. Structure having members:long quot;
long rem;
sizeof
operator.int abs(int n);
long labs(long n);
n
. (int num, int denom);
(long num, long denom);
num/denom
.double atof(const char* s);
(s, (char**))
except that
is not necessarily set on conversion error.int atoi(const char* s);
(int)(s, (char**), 10)
except that
is not necessarily set on conversion error.long atol(const char* s);
(s, (char**), 10)
except that
is not necessarily set on conversion error.double (const char* s, char** endp);
s
to type double
. If endp
non-null, stores pointer to unconverted suffix in *endp
. On overflow, sets
to
and returns
with the appropriate sign; on underflow, sets
to
and returns zero; otherwise returns converted value.long (const char* s, char** endp, int base);
s
to type long
. If endp
non-null, stores pointer to unconverted suffix in *endp
. If base
between 2 and 36, that base used for conversion; if zero, leading (after any sign) 0X
or 0x
implies hexadecimal, leading 0
(after any sign) implies octal, otherwise decimal assumed. Leading 0X
or 0x
permitted for base hexadecimal. On overflow, sets
to
and returns
or
(as appropriate for sign); otherwise returns converted value.unsigned long (const char* s, char** endp, int base);
except result is unsigned long
and value on overflow is
.void* calloc( nobj, size);
nobj
objects each of size size
, or
on error.void* malloc( size);
on error.void* realloc(void* p, size_t size);
size
, initialised, to minimum of old and new sizes, to existing contents of p
(if non-null), or
on error. On success, old object deallocated, otherwise unchanged.void free(void* p);
p
non-null, deallocates space to which it points.void ();
()
.void (int status);
are called (in reverse order to that in which installed), open files are flushed, open streams are closed and control is returned to environment. status
is returned to environment in implementation-dependent manner. Zero or
indicates successful termination and
indicates unsuccessful termination. Implementations may define other values.int (void (*fcm)(void));
fcn
to be called when program terminates normally (or when main
returns). Returns non-zero on failure.int system(const char* s);
s
is not
, passes s
to environment for execution, and returns status reported by command processor; if s
is
, non-zero returned if environment has a command processor.char* getenv(const char* name);
name
from implementation's environment, or
if no such string exists.void* bsearch(const void* key, const void* base, n, size, int (*cmp)(const void* keyval, const void* datum));
base
(of n
objects each of size size
) for item matching key
according to comparison function cmp
. cmp
must return negative value if first argument is less than second, zero if equal and positive if greater. Items of base
are assumed to be in ascending order (according to cmp
). Returns a pointer to an item matching key
, or
if none found.void qsort(void* base, n, size, int (*cmp)(const void*, const void*));
base
(of n
objects each of size size
) according to comparison function cmp
. cmp
must return negative value if first argument is less than second, zero if equal and positive if greater.int (void);
0
to
.void srand(unsigned int seed);
seed
as seed for new sequence of pseudo-random numbers. Initial seed is 1
.[]
sizeof
operator.char* strcpy(char* s, const char* ct);
ct
to s
including terminating NUL
and returns s
.char* strncpy(char* s, const char* ct, n);
n
characters of ct
to s
. Pads with NUL
characters if ct
is of length less than n
. Note that this may leave s
without NUL
-termination. Return s
.char* strcat(char* s, const char* ct);
ct
to s
and return s
.char* strncat(char* s, const char* ct, n);
n
characters of ct
to s
. NUL
-terminates s
and return it.int strcmp(const char* cs, const char* ct);
cs
with ct
, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.int strncmp(const char* cs, const char* ct, n);
n
characters of cs
and ct
, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.int strcoll(const char* cs, const char* ct);
cs
with ct
according to locale, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.char* strchr(const char* cs, int c);
c
in cs
, or
if not found.char* strrchr(const char* cs, int c);
c
in cs
, or
if not found. strspn(const char* cs, const char* ct);
cs
which consists of characters which are in ct
. strcspn(const char* cs, const char* ct);
cs
which consists of characters which are not in ct
.char* strpbrk(const char* cs, const char* ct);
cs
of any character of ct
, or
if none is found.char* strstr(const char* cs, const char* ct);
ct
within cs
, or
if none is found. strlen(const char* cs);
cs
.
n
.char* strtok(char* s, const char* t);
s
for next token delimited by any character from ct
. Non-
s
indicates the first call of a sequence. If a token is found, it is NUL
-terminated and returned, otherwise
is returned. ct
need not be identical for each call in a sequence. strxfrm(char* s, const char* ct, n);
s
no more than n
characters (including terminating NUL
) of a string produced from ct
according to a locale-specific transformation. Returns length of entire transformed string.void* (void* s, const void* ct, n);
n
characters from ct
to s
and returns s
. s
may be corrupted if objects overlap.void* memmove(void* s, const void* ct, n);
n
characters from ct
to s
and returns s
. s
will not be corrupted if objects overlap.int memcmp(const void* cs, const void* ct, n);
n
characters of cs
and ct
, returning negative value if cs<ct
, zero if cs==ct
, positive value if cs>ct
.void* memchr(const void* cs, int c, n);
c
in first n
characters of cs
, or
if not found.void* memset(void* s, int c, n);
n
characters of s
by c
and returns s
.[]
CLOCKS_PER_SEC
units per second.
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
clock(void);
-1
if not available. time(* tp);
-1
if not available. If tp
is non-
, return value is also assigned to *tp
.double difftime( time2, time1);
time2
and time1
. mktime(* tp);
*tp
to fall withing normal ranges. Returns the corresponding calendar time, or -1
if it cannot be represented.char* (const * tp);
Sun Jan 3 13:08:42 1988\n\0
char* ctime(const * tp);
tp
converted to local time. Equivalent to:((tp))
* gmtime(const * tp);
*tp
converted to Coordinated Universal Time, or
if not available.* (const * tp);
*tp
converted into localtime.size_t strftime(char* s, size_t smax, const char* fmt, const * tp);
*tp
into s
according to fmt
. Places no more than smax
characters into s
, and returns number of characters produced (excluding terminating NUL
), or 0
if greater than smax
. Formatting conversions (%c
) are:A
a
B
b
c
d
01
-31
]H
00
-23
]I
01
-12
]j
001
-366
]M
00
-59
]m
01
-12
]p
AM
" or "PM
"S
00
-61
]U
00
-53
]W
00
-53
]w
0
) [0
-6
]X
x
Y
y
00
-99
]Z
%
%
[]