<assert.h>
-
void assert(int expression); -
用來偵測錯誤的巨集(當引入
<assert.h>後在NDEBUG被定義時忽略。)如果expression等於零,就會在stderr輸出訊息,並且呼叫abort結束程式。訊息裡的程式檔名與行號是來自於預處理程式的預設巨集__FILE__和__LINE__.
[目錄]
<ctype.h>
-
int isalnum(int c); -
isalpha(c)或isdigit(c)。 -
int isalpha(int c); -
isupper(c)或islower(c)。 -
int iscntrl(int c); -
是否為控制字元。在ASCII中,控制字元為
0x00(NUL)至0x1F(US),還有0x7F(DEL)。 -
int isdigit(int c); - 是否為數值字元。
-
int isgraph(int c); - 是否為非空白的可列印字元。
-
int islower(int c); - 是否為小寫字母字元。
-
int isprint(int c); -
是否為可列印字元(包括空白)。在ASCII,可列印字元為
0x20(' ')至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); - 傳回等價大寫字母字元。
[目錄]
<errno.h>
註:
[目錄]
<float.h>
-
FLT_RADIX - 浮點數的基數
-
FLT_ROUNDS -
浮點數的捨去模式
- -1
- 未定
- 0
- 往0捨去
- 1
- 往最近的值捨去
- 2
- 往正無限大捨去
- 3
- 往負無限大捨去
前置詞「FLT」用於float型態,「DBL」用於double,而「LDBL」用於long double型態。
-
FLT_DIG -
DBL_DIG -
LDBL_DIG - 精確度(十進位數字)。
-
FLT_EPSILON -
DBL_EPSILON -
LDBL_EPSILON -
最小的數x使得
1.0 + x != 1.0成立。 -
FLT_MANT_DIG -
DBL_MANT_DIG -
LDBL_MANT_DIG -
浮點數小數部份的位數個數,是以
FLT_RADIX進位為主。 -
FLT_MAX -
DBL_MAX -
LDBL_MAX - 最大值
-
FLT_MAX_EXP -
DBL_MAX_EXP -
LDBL_MAX_EXP -
largest positive integer exponent to which
FLT_RADIXcan be raised and remain representable -
FLT_MIN -
DBL_MIN -
LDBL_MIN - 正規劃後最小的數字。
-
FLT_MIN_EXP -
DBL_MIN_EXP -
LDBL_MIN_EXP -
smallest negative integer exponent to which
FLT_RADIXcan be raised and remain representable
[目錄]
<limits.h>
-
CHAR_BIT -
型態
char中有幾bit。 -
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_MAX -
型態
long的最大值。 -
LONG_MIN -
型態
long的最小值。 -
ULONG_MAX -
型態
unsigned long的最大值。
[目錄]
<locale.h>
-
struct lconv -
描述貨幣格式和其他數值:
-
char* decimal_point; - 非貨幣值的小數點。
-
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; - 貨幣符號。
-
char* int_curr_symbol; - ISO 4217國際貨幣代號。
-
char* mon_decimal_point; - 貨幣值的小數點。
-
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; - 貨幣值的負數記號。
-
char* positive_sign; - 貨幣值的正數記號。
-
char frac_digits; - 貨幣值顯示小數點以下幾位。
-
char int_frac_digits; - 國際貨幣值顯示小數點以下幾位。
-
char n_cs_precedes; -
貨幣符號在負數貨幣值的前方(
1)或後方(0)。 -
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; -
貨幣符號在正數貨幣值的前方(
1)或後方(0)。 -
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
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
categoryandlocale. Returns string describing new locale or null on error. (Implementations are permitted to define values ofcategoryadditional to those describe here.) -
LC_ALL -
categoryargument for all categories -
LC_NUMERIC -
categoryfor numeric formatting information -
LC_MONETARY -
categoryfor monetary formatting information -
LC_COLLATE -
categoryfor information affecting collating functions -
LC_CTYPE -
categoryfor information affecting character class tests functions -
LC_TIME -
categoryfor information affecting time conversions functions -
NULL - 空指標常數。
[目錄]
<math.h>
發生定義域錯誤時,errno會被設成EDOM。發生溢位錯誤時,errno會被設成ERANGE。溢位時傳回和結果同正負號的HUGE_VAL,而下溢時傳回0。角度單位為徑度。
-
HUGE_VAL - 發生溢位錯誤時傳回的值(和結果同正負號)。
-
double exp(double x); -
x的指數。 -
double log(double x); -
x的自然對數。 -
double log10(double x); -
x以10為底的對數。 -
double pow(double x, double y); -
x的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乘以 2 的n次方 -
double frexp(double x, int* exp); -
如果
x不為零,回傳一個絕對值在 [1/2, 1) 區間的數值,並且寫入一個數值到*exp,使得回傳值乘以 2 的*exp次方等於x。如果x是 0 ,回傳值和*exp都會是 0 -
double modf(double x, double* ip); -
returns fractional part and assigns to
*ipintegral part ofx, both with same sign asx -
double fmod(double x, double y); -
if
ynon-zero, floating-point remainder ofx/y, with same sign asx; ifyzero, 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
[目錄]
<setjmp.h>
-
jmp_buf - type of object holding context information
-
int setjmp(jmp_buf env); -
Saves context information in
envand returns zero. Subsequent call tolongjmpwith same env returns non-zero. -
void longjmp(jmp_buf env, int val); -
Restores context saved by most recent call to
setjmpwith specifiedenv. Execution resumes as a second return fromsetjmp, with returned valuevalif 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 -
signalreturn 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
handlerisSIG_DFL, implementation-defined default behaviour will be used; ifSIG_IGN, signal will be ignored; otherwise function pointed to byhandlerwill be invoked with argument sig. In the last case, handling is restored to default behaviour beforehandleris called. Ifhandlerreturns, execution resumes where signal occurred.signalreturns the previous handler orSIG_ERRon 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.lastargis 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
mfrom start of structure typestype. -
ptrdiff_t - Type for objects declared to store result of subtracting pointers.
-
size_t -
Type for objects declared to store result of
sizeofoperator.
[目錄]
<stdio.h>
-
BUFSIZ -
setbuf函式使用的預設緩衝區大小。 -
EOF - 表示資料流結束或資料流讀取錯誤的值。
-
FILENAME_MAX - 檔案名稱的長度上限。
-
FOPEN_MAX - 同時可開啟檔案的數目上限。
-
L_tmpnam -
tmpnam函式需要多大的字元陣列來儲存暫存檔檔名。 -
NULL - 空指標常數。
-
SEEK_CUR -
fseek函式的origin參數值,代表檔案目前位置。 -
SEEK_END -
fseek函式的origin參數值,代表檔案結尾。 -
SEEK_SET -
fseek函式的origin參數值,代表檔案開頭。 -
TMP_MAX -
tmpnam函式最少能產生多少不重複的暫存檔檔名。 -
_IOFBF -
setvbuf函式的mode參數值,代表緩衝器填滿後釋出。 -
_IOLBF -
setvbuf函式的mode參數值,代表緩衝器遇到換行後釋出。 -
_IONBF -
setvbuf函式的mode參數值,代表不使用緩衝器。 -
stdin - 指向標準輸入字元流的檔案指標。程式開始執行時會被自動開啟。
-
stdout - 指向標準輸出字元流的檔案指標。程式開始執行時會被自動開啟。
-
stderr - 指向標準錯誤輸出字元流的檔案指標。程式開始執行時會被自動開啟。
-
FILE - 宣告含有控制字元流所需資訊的物件類型。
-
fpos_t - 宣告檔案游標位置資訊的物件類型。
-
size_t -
宣告用來儲存
sizeof運算子結果的物件類型。 -
FILE* fopen(const char* filename, const char* mode); -
開啟檔名為
filename的檔案並傳回字元流,失敗時傳回NULL。mode可以是以下選項:-
"r" - 以純文字檔案方式讀取。
-
"w" - 以純文字檔案方式寫入。
-
"a" - 以純文字檔案方式添加在尾端。
-
"r+" - 以純文字檔案方式更新(讀取、寫入)。
-
"w+" - 以純文字檔案方式更新,清除原始檔案內容(如果有的話)。
-
"a+" - 以純文字檔案方式添加在尾端,在尾端讀取和寫入。
b(要在第一個字元以後),表示以二進位檔案方式。 -
-
FILE* freopen(const char* filename, const char* mode, FILE* stream); -
關閉
stream指向的檔案,然後以指定的模式開啟檔名為filename的檔案,將stream與之連結。傳回stream,錯誤時傳回NULL。 -
int fflush(FILE* stream); -
釋出字元流
stream的緩衝器,成功時傳回0或失敗時傳回EOF。對不可輸出的字元流使用時,效果未定義。fflush(NULL)會釋出所有輸出用字元流的緩衝器。 -
int fclose(FILE* stream); -
關閉
stream指向的字元流(如果是輸出用字元流,則先釋出緩衝區)。錯誤時傳回EOF,否則傳回0。 -
int remove(const char* filename); - 移除指定檔案。錯誤時傳回非0的值。
-
int rename(const char* oldname, const char* newname); -
把檔案
oldname更名成newname。失敗時傳回非0的值。 -
FILE* tmpfile(); -
建立暫存檔案(模式為
"wb+"),此檔案被關閉或程式正常結束時會被刪除。傳回字元流,失敗時傳回NULL。 -
char* tmpname(char s[L_tmpnam]); -
對
s寫入(如果s不是NULL)並傳回一個唯一的暫存檔檔名。此檔名對於前TMP_MAX次函數呼叫的結果都是不同的。 -
int setvbuf(FILE* stream, char* buf, int mode, size_t size); -
Controls buffering for stream
stream.modeis_IOFBFfor full buffering,_IOLBFfor line buffering,_IONBFfor no buffering. Non-nullbufspecifies buffer of sizesizeto be used; otherwise, a buffer is allocated. Returns non-zero on error. Call must be before any other operation on stream. -
void setbuf(FILE* stream, char* buf); -
Controls buffering for stream stream.
For null
buf, turns off buffering, otherwise equivalent to(void)setvbuf(stream, buf, _IOFBF, BUFSIZ). -
int fprintf(FILE* stream, const char* format, ...); -
根據字串
format轉換參數,並且輸出到字元流stream。傳回輸出的字元數目,發生錯誤時傳回負數。轉換指令包含:-
% -
(可選擇) 旗標:
-
- - 靠左對齊
-
+ - 永遠有正負號
- space
- 正號時加上空白
-
0 - 以0填空格
-
# -
Alternate form: for conversion
character
o, first digit will be zero, for [xX], prefix0xor0Xto non-zero value, for [eEfgG], always decimal point, for [gG] trailing zeros not removed.
-
-
(可選擇) 最小寬度:如果標示為
*,則從下個參數取值(型態必須要是int)。 -
(可選擇)
.(分開精確度標示與最小寬度標示): -
(可選擇) 精確度:對於轉換字元
s,代表該字串最多輸出多少字元,對於[eEf],代表小數點後的位數,對於[gG],代表有效位數,對於整數,代表最少要輸出幾位數。如果標示為*,則從下個參數取值(型態必須要是int)。 -
(可選擇) 型態長度修飾字:
-
h -
short或是unsigned short -
l -
long或是unsigned long -
L -
long double
-
-
轉換字元:
-
d,i -
型態
int的參數,視為有正負號的十進位數輸出 -
o -
型態
int的參數,視為有正負號的八進位數輸出 -
x,X -
型態
int的參數,視為有正負號的十六進位數輸出 -
u -
型態
int的參數,視為無正負號的十進位數輸出 -
c -
型態
int的參數,視為單一字元輸出 -
s -
型態
char*的參數 -
f -
型態
double的參數,以[-]mmm.ddd的格式輸出 -
e,E -
型態
double的參數,以[-]m.dddddd(e|E)(+|-)xx的格式輸出 -
g,G -
型態
double的參數 -
p -
型態
void*的參數,以指標位址輸出 -
n -
型態
int*的參數:到目前為止已輸出的字元數目將寫回此參數 -
% - 不需要參數;輸出%
-
-
-
int printf(const char* format, ...); -
printf(f, ...)等價於fprintf(stdout, f, ...) -
int sprintf(char* s, const char* format, ...); -
像是 fprintf ,但是資料是輸出到字串
s,其 必須大到能保存全部輸出 ,不像字串流。輸出會以NUL結尾。回傳輸出長度(不包含NUL)。 -
int vfprintf(FILE* stream, const char* format, va_list arg); -
Equivalent to
fprintfwith variable argument list replaced byarg, which must have been initialised by theva_startmacro (and may have been used in calls tova_arg). -
int vprintf(const char* format, va_list arg); -
Equivalent to
printfwith variable argument list replaced byarg, which must have been initialised by theva_startmacro (and may have been used in calls tova_arg). -
int vsprintf(char* s, const char* format, va_list arg); -
Equivalent to
sprintfwith variable argument list replaced byarg, which must have been initialised by theva_startmacro (and may have been used in calls tova_arg). -
int fscanf(FILE* stream, const char* format, ...); -
Performs formatted input conversion, reading from
stream
streamaccording to formatformat. The function returns whenformatis fully processed. Returns number of items converted and assigned, orEOFif end-of-file or error occurs before any conversion. Each of the arguments followingformatmust be a pointer. Format string may contain:- blanks and tabs, which are ignored
- ordinary characters, which are expected to match next non-white-space of input
-
conversion specifications, consisting of:
-
% -
(optional) assignment suppression
character "
*" - (optional) maximum field width
-
(optional) target width indicator:
-
h -
argument is pointer to
shortrather thanint -
l -
argument is pointer to
longrather thanint, ordoublerather thanfloat -
L -
argument is pointer to
long doublerather thanfloat
-
-
conversion character:
-
d -
decimal integer;
int*parameter required -
i -
integer;
int*parameter required; decimal, octal or hex -
o -
octal integer;
int*parameter required -
u -
unsigned decimal integer;
unsigned int*parameter required -
x -
hexadecimal integer;
int*parameter required -
c -
characters;
char*parameter required; white-space is not skipped, andNUL-termination is not performed -
s -
string of non-white-space;
char*parameter required; string isNUL-terminated -
e,f,g -
floating-point number;
float*parameter required -
p -
pointer value;
void*parameter required -
n -
chars read so far;
int*parameter required -
[...] -
longest non-empty string
from specified set;
char*parameter required; string isNUL-terminated -
[^...] -
longest non-empty string
not from specified set;
char*parameter required; string isNUL-terminated -
% -
literal
%; no assignment
-
-
-
int scanf(const char* format, ...); -
scanf(f, ...)is equivalent tofscanf( stdin, f, ...) -
int sscanf(char* s, const char* format, ...); -
Like
fscanf, but input read from strings. -
int fgetc(FILE* stream); -
Returns next character from (input) stream
stream, orEOFon end-of-file or error. -
char* fgets(char* s, int n, FILE* stream); -
Copies characters from (input) stream
streamtos, stopping whenn-1 characters copied, newline copied, end-of-file reached or error occurs. If no error,sisNUL-terminated. ReturnsNULLon end-of-file or error,sotherwise. -
int
fputc(int c, FILE* stream); -
Writes
c, to streamstream. Returnsc, orEOFon error. -
char* fputs(const char* s, FILE* stream); -
Writes
s, to (output) stream stream. Returns non-negative on success orEOFon error. -
int getc(FILE* stream); -
Equivalent to
fgetcexcept that it may be a macro. -
int getchar(void); -
Equivalent to
getc(stdin). -
char* gets(char* s); -
Copies characters from
stdinintosuntil newline encountered, end-of-file reached, or error occurs. Does not copy newline.NUL-terminatess. Returnss, orNULLon end-of-file or error. Should not be used because of the potential for buffer overflow. -
int putc(int c, FILE* stream); -
Equivalent to
fputcexcept that it may be a macro. -
int putchar(int c); -
putchar(c)is equivalent toputc(c, stdout). -
int puts(const char* s); -
Writes
s(excluding terminatingNUL) and a newline tostdout. Returns non-negative on success,EOFon error. -
int ungetc(int c, FILE* stream); -
Pushes
c(which must not beEOF), onto (input) streamstreamsuch that it will be returned by the next read. Only one character of pushback is guaranteed (for each stream). Returnsc, orEOFon error. -
size_t fread(void* ptr, size_t size, size_t nobj, FILE* stream); -
Reads (at most)
nobjobjects of sizesizefrom streamstreamintoptrand returns number of objects read. (feofandferrorcan be used to check status.) -
size_t fwrite(const void* ptr, size_t size, size_t nobj, FILE* stream); -
Writes to stream
stream,nobjobjects of sizesizefrom arrayptr. Returns number of objects written. -
int fseek(FILE* stream, long offset, int origin); -
Sets file position for stream
streamand clears end-of-file indicator. For a binary stream, file position is set tooffsetbytes from the position indicated byorigin: beginning of file forSEEK_SET, current position forSEEK_CUR, or end of file forSEEK_END. Behaviour is similar for a text stream, butoffsetmust be zero or, forSEEK_SETonly, a value returned byftell. Returns non-zero on error. -
long ftell(FILE* stream); -
Returns current file position for stream
stream, or-1on error. -
void rewind(FILE* stream); -
Equivalent to
fseek(stream, 0L, SEEK_SET); clearerr(stream). -
int fgetpos(FILE* stream, fpos_t* ptr); -
Stores current file position for stream
streamin*ptr. Returns non-zero on error. -
int fsetpos(FILE* stream, const fpos_t* ptr); -
Sets current position of stream stream
to
*ptr. Returns non-zero on error. -
void clearerr(FILE* stream); -
Clears end-of-file and error indicators for stream
stream. -
int feof(FILE* stream); -
Returns non-zero if end-of-file indicator is set
for stream
stream. -
int ferror(FILE* stream); -
Returns non-zero if error indicator is set for
stream
stream. -
void perror(const char* s); -
Prints
s(if non-null) andstrerror( errno)to standard error as would:fprintf(stderr, "%s: %s\n", (s != NULL ? s : ""), strerror(errno))
[目錄]
<stdlib.h>
-
EXIT_FAILURE -
Value for
statusargument toexitindicating failure. -
EXIT_SUCCESS -
Value for
statusargument toexitindicating success. -
RAND_MAX -
Maximum value returned by
rand(). -
NULL - Null pointer constant.
-
div_t -
Return type of
div(). Structure having members:-
int quot; - quotient
-
int rem; - remainder
-
-
ldiv_t -
Return type of
ldiv(). Structure having members:-
long quot; - quotient
-
long rem; - remainder
-
-
size_t -
Type for objects declared to store result of
sizeofoperator. -
int abs(int n); -
long labs(long n); -
Returns absolute value of
n. -
div_t div(int num, int denom); -
ldiv_t ldiv(long num, long denom); -
Returns quotient and remainder of
num/denom. -
double atof(const char* s); -
Equivalent to
strtod(s, (char**)NULL)except thaterrnois not necessarily set on conversion error. -
int atoi(const char* s); -
Equivalent to
(int)strtol(s, (char**)NULL, 10)except thaterrnois not necessarily set on conversion error. -
long atol(const char* s); -
Equivalent to
strtol(s, (char**)NULL, 10)except thaterrnois not necessarily set on conversion error. -
double strtod(const char* s, char** endp); -
Converts initial characters (ignoring leading white
space) of
sto typedouble. Ifendpnon-null, stores pointer to unconverted suffix in*endp. On overflow, setserrnotoERANGEand returnsHUGE_VALwith the appropriate sign; on underflow, setserrnotoERANGEand returns zero; otherwise returns converted value. -
long strtol(const char* s, char** endp, int base); -
Converts initial characters (ignoring leading white
space) of
sto typelong. Ifendpnon-nu ll, stores pointer to unconverted suffix in*endp. Ifbasebetween 2 and 36, that base used for conversion; if zero, leading (after any sign)0Xor0ximplies hexadecimal, leading0(after any sign) implies octal, otherwise decimal assumed. Leading0Xor0xpermitted for base hexadecimal. On overflow, setserrnotoERANGEand returnsLONG_MAXorLONG_MIN(as appropriate for sign); otherwise returns converted value. -
unsigned long strtoul(const char* s, char** endp, int base); -
As for
strtolexcept result isunsigned longand value on overflow isULONG_MAX. -
void* calloc(size_t nobj, size_t size); -
Returns pointer to zero-initialised
newly-allocated space for an array of
nobjobjects each of sizesize, orNULLon error. -
void* malloc(size_t size); -
Returns pointer to uninitialised
newly-allocated space for an object of size
size, or
NULLon error. -
void* realloc(void* p, size_t size); -
Returns pointer to newly-allocated space for an
object of size
size, initialised, to minimum of old and new sizes, to existing contents ofp(if non-null), orNULLon error. On success, old object deallocated, otherwise unchanged. -
void free(void* p); -
If
pnon-null, deallocates space to which it points. -
void abort(); -
Terminates program abnormally, by calling
raise( SIGABRT). -
void exit(int status); -
Terminates program normally. Functions installed
using
atexitare called (in reverse order to that in which installed), open files are flushed, open streams are closed and control is returned to environment.statusis returned to environment in implementation-dependent manner. Zero orEXIT_SUCCESSindicates successful termination andEXIT_FAILUREindicates unsuccessful termination. Implementations may define other values. -
int atexit(void (*fcm)(void)); -
Registers
fcnto be called when program terminates normally (or whenmainreturns). Returns non-zero on failure. -
int system(const char* s); -
If
sis notNULL, passessto environment for execution, and returns status reported by command processor; ifsisNULL, non-zero returned if environment has a command processor. -
char* getenv(const char* name); -
Returns string associated with name
namefrom implementation's environment, orNULLif 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)); -
Searches ordered array
base(ofnobjects each of sizesize) for item matchingkeyaccording to comparison functioncmp.cmpmust return negative value if first argument is less than second, zero if equal and positive if greater. Items ofbaseare assumed to be in ascending order (according tocmp). Returns a pointer to an item matchingkey, orNULLif none found. -
void qsort(void* base, size_t n, size_t size, int (*cmp)(const void*, const void*)); -
Arranges into ascending order array
base(ofnobjects each of sizesize) according to comparison functioncmp.cmpmust return negative value if first argument is less than second, zero if equal and positive if greater. -
int rand(void); -
Returns pseudo-random number in range
0toRAND_MAX. -
void srand(unsigned int seed); -
Uses
seedas seed for new sequence of pseudo-random numbers. Initial seed is1.
[目錄]
<string.h>
-
NULL - Null pointer constant.
-
size_t -
Type for objects declared to store result of
sizeofoperator. -
char* strcpy(char* s, const char* ct); -
Copies
cttosincluding terminatingNULand returnss. -
char* strncpy(char* s, const char* ct, size_t n); -
Copies at most
ncharacters ofcttos. Pads withNULcharacters ifctis of length less thann. Note that this may leaveswithoutNUL-termination. Returns. -
char* strcat(char* s, const char* ct); -
Concatenate
cttosand returns. -
char* strncat(char* s, const char* ct, size_t n); -
Concatenate at most
ncharacters ofcttos.NUL-terminatessand return it. -
int strcmp(const char* cs, const char* ct); -
Compares
cswithct, returning negative value ifcs<ct, zero ifcs==ct, positive value ifcs>ct. -
int strncmp(const char* cs, const char* ct, size_t n); -
Compares at most (the first)
ncharacters ofcsandct, returning negative value ifcs<ct, zero ifcs==ct, positive value ifcs>ct. -
int strcoll(const char* cs, const char* ct); -
Compares
cswithctaccording to locale, returning negative value ifcs<ct, zero ifcs==ct, positive value ifcs>ct. -
char* strchr(const char* cs, int c); -
Returns pointer to first occurrence of
cincs, orNULLif not found. -
char* strrchr(const char* cs, int c); -
Returns pointer to last occurrence of
cincs, orNULLif not found. -
size_t strspn(const char* cs, const char* ct); -
Returns length of prefix of
cswhich consists of characters which are inct. -
size_t strcspn(const char* cs, const char* ct); -
Returns length of prefix of
cswhich consists of characters which are not inct. -
char* strpbrk(const char* cs, const char* ct); -
Returns pointer to first occurrence in
csof any character ofct, orNULLif none is found. -
char* strstr(const char* cs, const char* ct); -
Returns pointer to first occurrence of
ctwithincs, orNULLif none is found. -
size_t strlen(const char* cs); -
Returns length of
cs. -
char* strerror(int n); -
Returns pointer to implementation-defined message
string corresponding with error
n. -
char* strtok(char* s, const char* t); -
Searches
sfor next token delimited by any character fromct. Non-NULLsindicates the first call of a sequence. If a token is found, it isNUL-terminated and returned, otherwiseNULLis returned.ctneed not be identical for each call in a sequence. -
size_t strxfrm(char* s, const char* ct, size_t n); -
Stores in
sno more thanncharacters (including terminatingNUL) of a string produced fromctaccording to a locale-specific transformation. Returns length of entire transformed string. -
void* memcpy(void* s, const void* ct, size_t n); -
Copies
ncharacters fromcttosand returnss.smay be corrupted if objects overlap. -
void* memmove(void* s, const void* ct, size_t n); -
Copies
ncharacters fromcttosand returnss.swill not be corrupted if objects overlap. -
int memcmp(const void* cs, const void* ct, size_t n); -
Compares at most (the first)
ncharacters ofcsandct, returning negative value ifcs<ct, zero ifcs==ct, positive value ifcs>ct. -
void* memchr(const void* cs, int c, size_t n); -
Returns pointer to first occurrence of
cin firstncharacters ofcs, orNULLif not found. -
void* memset(void* s, int c, size_t n); -
Replaces each of the first
ncharacters ofsbycand returnss.
[目錄]
<time.h>
-
CLOCKS_PER_SEC -
The number of
clock_tunits per second. -
NULL - Null pointer constant.
-
clock_t - An arithmetic type elapsed processor representing time.
-
time_t - An arithmetic type representing calendar time.
-
struct tm -
Represents the components of calendar time:
-
int tm_sec; - seconds after the minute
-
int tm_min; - minutes after the hour
-
int tm_hour; - hours since midnight
-
int tm_mday; - day of the month
-
int tm_mon; - months since January
-
int tm_year; - years since 1900
-
int tm_wday; - days since Sunday
-
int tm_yday; - days since January 1
-
int tm_isdst; - Daylight Saving Time flag : is positive if DST is in effect, zero if not in effect, negative if information not known.
-
-
clock_t clock(void); -
Returns elapsed processor time used by program or
-1if not available. -
time_t time(time_t* tp); -
Returns current calendar time or
-1if not available. Iftpis non-NULL, return value is also assigned to*tp. -
double difftime(time_t time2, time_t time1); -
Returns the difference in seconds between
time2andtime1. -
time_t mktime(struct tm* tp); -
If necessary, adjusts fields of
*tpto fall withing normal ranges. Returns the corresponding calendar time, or-1if it cannot be represented. -
char* asctime(const struct tm* tp); -
Returns the given time as a string of the
form:
Sun Jan 3 13:08:42 1988\n\0 -
char* ctime(const time_t* tp); -
Returns string equivalent to calendar time
tpconverted to local time. Equivalent to:
asctime( localtime(tp)) -
struct tm* gmtime(const time_t* tp); -
Returns calendar time
*tpconverted to Coordinated Universal Time, orNULLif not available. -
struct tm* localtime(const time_t* tp); -
Returns calendar time
*tpconverted into local time. -
size_t strftime(char* s, size_t smax, const char* fmt, const struct tm* tp); -
Formats
*tpintosaccording tofmt. Places no more thansmaxcharacters intos, and returns number of characters produced (excluding terminatingNUL), or0if greater thansmax. Formatting conversions (%c) are:-
A - name of weekday
-
a - abbreviated name of weekday
-
B - name of month
-
b - abbreviated name of month
-
c - local date and time representation
-
d -
day of month
[
01-31] -
H -
hour (24-hour clock)
[
00-23] -
I -
hour (12-hour clock)
[
01-12] -
j -
day of year
[
001-366] -
M -
minute [
00-59] -
m -
month [
01-12] -
p -
local equivalent of "
AM" or "PM" -
S -
second [
00-61] -
U -
week number of year (Sunday as 1st day of
week) [
00-53] -
W -
week number of year (Monday as 1st day of
week) [
00-53] -
w -
weekday (Sunday as
0) [0-6] -
X - local time representation
-
x - local date representation
-
Y - year with century
-
y -
year without century
[
00-99] -
Z - name (if any) of time zone
-
% -
%
-
Local time may differ from calendar time because of time zone.
[目錄]