<assert.h>
: Diagnostics<ctype.h>
: Character Class Tests<errno.h>
: Error Number<float.h>
: Implementation-defined Floating-Point Limits<limits.h>
: Implementation-defined Limits<locale.h>
<math.h>
: Mathematical Functions<setjmp.h>
: Non-local Jumps<signal.h>
: Signals<stdarg.h>
: Variable Argument Lists<stddef.h>
<stdio.h>
: Input and Output<stdlib.h>
: Utility functions<string.h>
: String functions<time.h>
: Time and Date functionsvoid assert(int expression);
stderr
and abort called to terminate execution.
Source file and line number in message come from preprocessor macros
__FILE__
and
__LINE__
.
If NDEBUG
is defined where <assert.h>
is included, assert
macro is ignored.int isalnum(int c);
isalpha(c)
or isdigit(c)
int isalpha(int c);
isupper(c)
or islower(c)
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
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:
0x20 (' ')
to
0x7E ('~')
;
control characters are
0x00 (NUL)
to
0x1F (US)
and
0x7F (DEL)
FLT_RADIX
FLT_ROUNDS
FLT_DIG
FLT_EPSILON
1.0 + x != 1.0
FLT_MANT_DIG
FLT_MAX
FLT_MAX_EXP
FLT_MIN
FLT_MIN_EXP
DBL_DIG
DBL_EPSILON
DBL_MANT_DIG
DBL_MAX
double
floating-point numberDBL_MAX_EXP
DBL_MIN
double
floating-point numberDBL_MIN_EXP
CHAR_BIT
char
CHAR_MAX
char
CHAR_MIN
char
INT_MAX
int
INT_MIN
int
LONG_MAX
long
LONG_MIN
long
SCHAR_MAX
signed char
SCHAR_MIN
signed char
SHRT_MAX
short
SHRT_MIN
short
UCHAR_MAX
unsigned char
UCHAR_MIN
unsigned char
UINT_MAX
unsigned int
ULONG_MAX
unsigned long
USHRT_MAX
unsigned short
double sin(double x);
double cos(double x);
double tan(double x);
double asin(double x);
double acos(double x);
double atan(double x);
double atan2(double y, double x);
double sinh(double x);
double cosh(double x);
double tanh(double x);
double exp(double x);
double log(double x);
double log10(double x);
double pow(double x, double y);
double sqrt(double x);
double ceil(double x);
double floor(double x);
double fabs(double x);
double ldexp(double x, int n);
double frexp(double x, int* exp);
double modf(double x, double* ip);
double fmod(double x, double y);
int setjmp(jmp_buf env);
longjmp
.void longjmp(jmp_buf env, int val);
setjmp
using information saved in env.
Execution resumes as if setjmp
just executed and returned non-zero value val.SIGABRT
SIGFPE
SIGILL
SIGINT
SIGSEGV
SIGTERM
void (*signal(int sig, void (*handler)(int)))(int);
SIG_DFL
, implementation-defined default
behaviour is used;
if handler is SIG_IGN
, signal is ignored;
otherwise function pointed to by handler is called
with argument sig.
signal
returns the previous handler or
SIG_ERR
on error.
When signal sig subsequently occurs, the signal is
restored to its default behaviour
and the handler is called.
If the handler returns, execution resumes where signal occurred.
Initial state of signals is implementation-defined.
int raise(int sig);
Facilities for stepping through a list of function arguments of unknown number and type.
void va_start(va_list ap, lastarg);
type va_arg(va_list ap, type);
void va_end(va_list ap);
FILE
stdin
stdout
stderr
FILENAME_MAX
FOPEN_MAX
TMP_MAX
FILE* fopen(const char* filename, const char* mode);
NULL
on failure.
mode may be (combinations of):
"r"
"w"
"a"
"r+"
"w+"
"a+"
FILE* freopen(const char* filename, const char* mode, FILE* stream);
NULL
on error.
Usually used to change files associated with
stdin
,
stdout
,
stderr
.int fflush(FILE* stream);
EOF
for write error, zero otherwise.
fflush(NULL)
flushes all output streams.int fclose(FILE* stream);
EOF
on error, zero otherwise.int remove(const char* filename);
int rename(const char* oldname, const char* newname);
FILE* tmpfile();
"wb+"
) which will be removed
when closed or on normal program termination.
Returns stream or NULL
on failure.char* tmpname(char s[L_tmpnam]);
int setvbuf(FILE* stream, char* buf, int mode, size_t size);
void setbuf(FILE* stream, char* buf);
int fprintf(FILE* stream, const char* format, ...);
-
+
0
#
o
, first digit will be zero,
for [xX
], prefix 0x
or 0X
to non-zero,
for [eEfgG
], always decimal point,
for [gG
] trailing zeros not removed.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.d, i
o
x,X
u
c
s
f
e,E
g,G
p
n
%
int printf(const char* format, ...);
printf(f, ...)
is equivalent to
fprintf(stdout, f, ...)
int sprintf(char* s, const char* format, ...);
NUL
-terminated.
Return length does not include the NUL
.int vfprintf(FILE* stream, const char* format, va_list arg);
va_start
macro
and may have been used in calls to va_arg
.
See <stdarg.h>int vprintf(const char* format, va_list arg);
va_start
macro
and may have been used in calls to va_arg
.
See <stdarg.h>int vsprintf(char* s, const char* format, va_list arg);
va_start
macro
and may have been used in calls to va_arg
.
See <stdarg.h>int fscanf(FILE* stream, const char* format, ...);
EOF
if end-of-file or error occurs before any conversion;
otherwise, the number of items converted and assigned.
Each of the arguments following format
must be a pointer.
Format string may contain:
%
: Conversion specification, consisting of %
,
optional assignment suppression character *
,
optional number indicating maximum field width,
optional [hlL
] indicating width of target,
conversion character.d
int*
parameter requiredi
int*
parameter required; decimal, octal or hexo
int*
parameter requiredu
unsigned int*
parameter requiredx
int*
parameter requiredc
char*
parameter required; up to width;
no '\0'
added; no skips
char*
parameter required;
'\0'
addede,f,g
float*
parameter requiredp
void*
parameter requiredn
int*
parameter requiredchar*
parameter required; '\0'^
...]char*
parameter required; '\0'%
%
; no assignmentint scanf(const char* format, ...);
scanf(f, ...)
is equivalent to
fscanf(stdin, f, ...)
int sscanf(char* s, const char* format, ...);
int fgetc(FILE* stream);
unsigned char
, or EOF
on end-of-file or error.char* fgets(char* s, int n, FILE* stream);
NUL
-terminated.
Returns s, or NULL
on end-of-file or error.int fputc(int c, FILE* stream);
unsigned char
,
to stream stream.
Returns the character written, or EOF
on error.char* fputs(const char* s, FILE* stream);
'\n'
on stream stream.
Returns non-negative on success, EOF
on error.int getc(FILE* stream);
fgetc
except that it may be a macro.int getchar();
getc(stdin)
.char* gets(char* s);
'\0'
.
Returns s, or NULL
on end-of-file or error.int putc(int c, FILE* stream);
fputc
except that it may be a macro.int putchar(int c);
putchar(c)
is equivalent to
putc(c, stdout)
.int puts(const char* s);
EOF
on error.int unget(int c, FILE* stream);
EOF
),
converted to unsigned char, onto stream stream
such that it will be returned by the next read.
Only one character of pushback is guaranteed for a stream.
Returns c, or EOF
on error.size_t fread(void* ptr, size_t size, size_t nobj, FILE* stream);
feof
and
ferror
must be used to determine status.size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream);
int fseek(FILE* stream, long offset, int origin);
SEEK_SET
(beginning),
SEEK_CUR
(current position) or SEEK_END
(end-of-file);
for a text stream, offset must be zero
or a value returned by ftell
(in which case origin must be SEEK_SET
).
Returns non-zero on error.long ftell(FILE* stream);
-1L
on error.void rewind(FILE* stream);
rewind(stream)
is equivalent to
fseek(stream, 0L, SEEK_SET);
clearerr(stream)
.int fgetpos(FILE* stream, fpos_t* ptr);
*ptr
.
Type fpos_t
is suitable for recording such values.
Returns non-zero on error.int fsetpos(FILE* stream, const fpos_t* ptr);
*ptr
.
Returns non-zero on error.void clearerr(FILE* stream);
int feof(FILE* stream);
int ferror(FILE* stream);
void perror(const char* s);
errno
:fprintf(stderr, "%s: %s\n", s, "error message")
double atof(const char* s);
strtod(s, (char**)NULL)
.int atoi(const char* s);
(int)strtol(s, (char**)NULL, 10)
.long atol(const char* s);
strtol(s, (char**)NULL, 10)
.double strtod(const char* s, char** endp);
double
,
ignoring leading quite space.
Stores a pointer to any unconverted suffix in *endp
if endp non-NULL
.
If answer would overflow, HUGE_VAL
is returned
with the appropriate sign; if underflow, zero returned.
In either case, errno
is set to ERANGE
.long strtol(const char* s, char** endp, int base);
long
,
ignoring leading quite space.
Stores a pointer to any unconverted suffix in *endp
if endp non-NULL
.
If base between 2 and 36, that base used;
if zero, leading 0X
or 0x
implies hexadecimal,
leading 0
implies octal, otherwise decimal.
Leading 0X
or 0x
permitted for base 16.
If answer would overflow, LONG_MAX
or LONG_MIN
returned and errno
is set to ERANGE
.unsigned long strtoul(const char* s, char** endp, int base);
strtol
except result is unsigned long
and error value is ULONG_MAX
.int rand();
0
to RAND_MAX
.void srand(unsigned int seed);
1
.void* calloc(size_t nobj, size_t size);
NULL
if request cannot be satisfied.void* malloc(size_t size);
NULL
if request cannot be satisfied.void* realloc(void* p, size_t size);
NULL
leaving p
unchanged.void free(void* p);
NULL
, in which case there is no effect,
or a pointer returned by calloc
, malloc
or
realloc
.void abort();
raise(SIGABRT)
.void exit(int status);
atexit
are called in reverse order of registration, open files are flushed,
open streams are closed and control is returned to environment.
status is returned to environment in implementation-dependent
manner.
Zero indicates successful termination and the values
EXIT_SUCCESS
and EXIT_FAILURE
may be used.int atexit(void (*fcm)(void));
int system(const char* s);
NULL
, non-zero returned
if command processor exists;
return value is implementation-dependent if
s is non-NULL
.char* getenv(const char* name);
NULL
if no such string exists.void* bsearch(const void* key, const void* base, size_t n, size_t size, int (*cmp)(const void* keyval, const void* datum));
base[0]...base[n-1]
for item matching *key
.
Comparison function cmp must return negative if
first argument is less than second, zero if equal and positive if greater.
The n items of base must be in ascending order.
Returns a pointer to the matching entry or NULL
if not found.void qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*));
base[0]...base[n-1]
of objects of size size.
Comparison function cmp must return negative if
first argument is less than second, zero if equal and positive if greater.int abs(int n);
long labs(long n);
div_t div(int num, int denom);
quot
and rem
of structure
of type div_t
the quotient and remainder of
num/denom
.ldiv_t ldiv(long num, long denom);
quot
and rem
of structure
of type ldiv_t
the quotient and remainder of
num/denom
.char* strcpy(char* s, const char* ct);
NUL
.
Return s.char* strncpy(char* s, const char* ct, int n);
NUL
s if ct is of length less than n.
Return s.char* strcat(char* s, const char* ct);
char* strncat(char* s, const char* ct, int n);
NUL
and return it.int strcmp(const char* cs, const char* ct);
cs < ct
,
zero if cs == ct
,
positive if cs > ct
.int strncmp(const char* cs, const char* ct, int n);
cs < ct
,
zero if cs == ct
,
positive if cs > ct
.char* strchr(const char* cs, int c);
NULL
if not found.char* strrchr(const char* cs, int c);
NULL
if not found.size_t strspn(const char* cs, const char* ct);
size_t strcspn(const char* cs, const char* ct);
char* strpbrk(const char* cs, const char* ct);
NULL
if not found.char* strstr(const char* cs, const char* ct);
NULL
if not found.size_t strlen(const char* cs);
char* strerror(int n);
char* strtok(char* s, const char* t);
strtok
returns tokens
from s delimted by a character in ct.
Non-NULL
s indicates the first call in a sequence.
ct may differ on each call.
Returns NULL
when no such token found.void* memcpy(void* s, const void* ct, int n);
void* memmove(void* s, const void* ct, int n);
int memcmp(const void* cs, const void* ct, int n);
cs < ct
,
zero if cs == ct
,
positive if cs > ct
.void* memchr(const char* cs, int c, int n);
NULL
if not found.void* memset(char* s, int c, int n);
clock_t
CLOCKS_PER_SEC
clock_t
units per second.time_t
struct tm
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_t clock();
time_t time(time_t* tp);
NULL
,
return value is also assigned to *tp
.double difftime(time_t time2, time_t time1);
time_t mktime(struct tm* tp);
*tp
, or -1
if it cannot be represented.char* asctime(const struct tm* tp);
Sun Jan 3 14:14:13 1988\n\0
char* ctime(const time_t* tp);
asctime(localtime(tp))
struct tm* gmtime(const time_t* tp);
NULL
if not available.struct tm* localtime(const time_t* tp);
*tp
converted into local time.size_t strftime(char* s, size_t smax, const char* fmt, const struct tm* tp);
*tp
into
s according to fmt.