c语言标准函数库.docx
《c语言标准函数库.docx》由会员分享,可在线阅读,更多相关《c语言标准函数库.docx(19页珍藏版)》请在冰豆网上搜索。
c语言标准函数库
目录
voidassert(intexpression);
Macrousedforinternalerrordetection.(IgnoredifNDEBUGisdefinedwhereisincluded.)Ifexpressionequalszero,messageprintedonstderrandabortcalledtoterminateexecution.Sourcefilenameandlinenumberinmessagearefrompreprocessormacros__FILE__and__LINE__.
intisalnum(intc);
isalpha(c)orisdigit(c)
intisalpha(intc);
isupper(c)orislower(c)
intiscntrl(intc);
iscontrolcharacter.InASCII,controlcharactersare0x00(NUL)to0x1F(US),and0x7F(DEL)
intisdigit(intc);
isdecimaldigit
intisgraph(intc);
isprintingcharacterotherthanspace
intislower(intc);
islower-caseletter
intisprint(intc);
isprintingcharacter(includingspace).InASCII,printingcharactersare0x20('')to0x7E('~')
intispunct(intc);
isprintingcharacterotherthanspace,letter,digit
intisspace(intc);
isspace,formfeed,newline,carriagereturn,tab,verticaltab
intisupper(intc);
isupper-caseletter
intisxdigit(intc);
ishexadecimaldigit
inttolower(intc);
returnlower-caseequivalent
inttoupper(intc);
returnupper-caseequivalent
errno
objecttowhichcertainlibraryfunctionsassignspecificpositivevaluesonerror
EDOM
codeusedfordomainerrors
ERANGE
codeusedforrangeerrors
Notes:
otherimplementation-definederrorvaluesarepermitted
todeterminethevalue(ifany)assignedtoerrnobyalibraryfunction,aprogramshouldassignzerotoerrnoimmediatelypriortothefunctioncall
FLT_RADIX
radixoffloating-pointrepresentations
FLT_ROUNDS
floating-pointroundingmode
Wheretheprefix"FLT"pertainstotypefloat,"DBL"totypedouble,and"LDBL"totypelongdouble:
FLT_DIG
DBL_DIG
LDBL_DIG
precision(indecimaldigits)
FLT_EPSILON
DBL_EPSILON
LDBL_EPSILON
smallestnumberxsuchthat1.0+x!
=1.0
FLT_MANT_DIG
DBL_MANT_DIG
LDBL_MANT_DIG
numberofdigits,baseFLT_RADIX,inmantissa
FLT_MAX
DBL_MAX
LDBL_MAX
maximumnumber
FLT_MAX_EXP
DBL_MAX_EXP
LDBL_MAX_EXP
largestpositiveintegerexponenttowhichFLT_RADIXcanberaisedandremainrepresentable
FLT_MIN
DBL_MIN
LDBL_MIN
minimumnormalisednumber
FLT_MIN_EXP
DBL_MIN_EXP
LDBL_MIN_EXP
smallestnegativeintegerexponenttowhichFLT_RADIXcanberaisedandremainrepresentable
CHAR_BIT
numberofbitsinachar
CHAR_MAX
maximumvalueoftypechar
CHAR_MIN
minimumvalueoftypechar
SCHAR_MAX
maximumvalueoftypesignedchar
SCHAR_MIN
minimumvalueoftypesignedchar
UCHAR_MAX
maximumvalueoftypeunsignedchar
SHRT_MAX
maximumvalueoftypeshort
SHRT_MIN
minimumvalueoftypeshort
USHRT_MAX
maximumvalueoftypeunsignedshort
INT_MAX
maximumvalueoftypeint
INT_MIN
minimumvalueoftypeint
UINT_MAX
maximumvalueoftypeunsignedint
LONG_MAX
maximumvalueoftypelong
LONG_MIN
minimumvalueoftypelong
ULONG_MAX
maximumvalueoftypeunsignedlong
structlconv
Describesformattingofmonetaryandothernumericvalues:
char*decimal_point;
decimalpointfornon-monetaryvalues
char*grouping;
sizesofdigitgroupsfornon-monetaryvalues
char*thousands_sep;
separatorfordigitgroupsfornon-monetaryvalues(leftof"decimalpoint")
char*currency_symbol;
currencysymbol
char*int_curr_symbol;
internationalcurrencysymbol
char*mon_decimal_point;
decimalpointformonetaryvalues
char*mon_grouping;
sizesofdigitgroupsformonetaryvalues
char*mon_thousands_sep;
separatorfordigitgroupsformonetaryvalues(leftof"decimalpoint")
char*negative_sign;
negativesignformonetaryvalues
char*positive_sign;
positivesignformonetaryvalues
charfrac_digits;
numberofdigitstobedisplayedtorightof"decimalpoint"formonetaryvalues
charint_frac_digits;
numberofdigitstobedisplayedtorightof"decimalpoint"forinternationalmonetaryvalues
charn_cs_precedes;
whethercurrencysymbolprecedes
(1)orfollows(0)negativemonetaryvalues
charn_sep_by_space;
whethercurrencysymbolis
(1)orisnot(0)separatedbyspacefromnegativemonetaryvalues
charn_sign_posn;
formatfornegativemonetaryvalues:
0
parenthesessurroundquantityandcurrencysymbol
1
signprecedesquantityandcurrencysymbol
2
signfollowsquantityandcurrencysymbol
3
signimmediatelyprecedescurrencysymbol
4
signimmediatelyfollowscurrencysymbol
charp_cs_precedes;
whethercurrencysymbolprecedes
(1)orfollows(0)positivemonetaryvalues
charp_sep_by_space;
whethercurrencysymbolis
(1)orisnot(0)separatedbyspacefromnon-negativemonetaryvalues
charp_sign_posn;
formatfornon-negativemonetaryvalues,withvaluesasforn_sign_posn
Implementationsmaychangefieldorderandincludeadditionalfields.StandardCLibraryfunctionsuseonlydecimal_point.
structlconv*localeconv(void);
returnspointertoformattinginformationforcurrentlocale
char*setlocale(intcategory,constchar*locale);
Setscomponentsoflocaleaccordingtospecifiedcategoryandlocale.Returnsstringdescribingnewlocaleornullonerror.(Implementationsarepermittedtodefinevaluesofcategoryadditionaltothosedescribehere.)
LC_ALL
categoryargumentforallcategories
LC_NUMERIC
categoryfornumericformattinginformation
LC_MONETARY
categoryformonetaryformattinginformation
LC_COLLATE
categoryforinformationaffectingcollatingfunctions
LC_CTYPE
categoryforinformationaffectingcharacterclasstestsfunctions
LC_TIME
categoryforinformationaffectingtimeconversionsfunctions
NULL
nullpointerconstant
Ondomainerror,implementation-definedvaluereturnedanderrnosettoEDOM.Onrangeerror,errnosettoERANGEandreturnvalueisHUGE_VALwithcorrectsignforoverflow,orzeroforunderflow.Anglesareinradians.
HUGE_VAL
magnitudereturned(withcorrectsign)onoverflowerror
doubleexp(doublex);
exponentialofx
doublelog(doublex);
naturallogarithmofx
doublelog10(doublex);
base-10logarithmofx
doublepow(doublex,doubley);
xraisedtopowery
doublesqrt(doublex);
squarerootofx
doubleceil(doublex);
smallestintegernotlessthanx
doublefloor(doublex);
largestintegernotgreaterthanx
doublefabs(doublex);
absolutevalueofx
doubleldexp(doublex,intn);
xtimes2tothepowern
doublefrexp(doublex,int*exp);
ifxnon-zero,returnsvalue,withabsolutevalueininterval[1/2,1),andassignsto*expintegersuchthatproductofreturnvalueand2raisedtothepower*expequalsx;ifxzero,bothreturnvalueand*exparezero
doublemodf(doublex,double*ip);
returnsfractionalpartandassignsto*ipintegralpartofx,bothwithsamesignasx
doublefmod(doublex,doubley);
ifynon-zero,floating-pointremainderofx/y,withsamesignasx;ifyzero,resultisimplementation-defined
doublesin(doublex);
sineofx
doublecos(doublex);
cosineofx
doubletan(doublex);
tangentofx
doubleasin(doublex);
arc-sineofx
doubleacos(doublex);
arc-cosineofx
doubleatan(doublex);
arc-tangentofx
doubleatan2(doubley,doublex);
arc-tangentofy/x
doublesinh(doublex);
hyperbolicsineofx
doublecosh(doublex);
hyperboliccosineofx
doubletanh(doublex);
hyperbolictangentofx
jmp_buf
typeofobjectholdingcontextinformation
intsetjmp(jmp_bufenv);
Savescontextinformationinenvandreturnszero.Subsequentcalltolongjmpwithsameenvreturnsnon-zero.
voidlongjmp(jmp_bufenv,intval);
Restorescontextsavedbymostrecentcalltosetjmpwithspecifiedenv.Executionresumesasasecondreturnfromsetjmp,withreturnedvaluevalifspecifiedvaluenon-zero,or1otherwise.
SIGABRT
abnormaltermination
SIGFPE
arithmeticerror
SIGILL
invalidexecution
SIGINT
(asynchronous)interactiveattention
SIGSEGV
illegalstorageaccess
SIGTERM
(asynchronous)terminationrequest
SIG_DFL
specifiesdefaultsignalhandling
SIG_ERR
signalreturnvalueindicatingerror
SIG_IGN
specifiesthatsignalshouldbeignored
void(*signal(intsig,void(*handler)(int)))(int);
Installhandlerforsubsequentsignalsig.IfhandlerisSIG_DFL,implementation-defineddefaultbehaviourwillbeused;ifSIG_IGN,signalwillbeignored;otherwisefunctionpointedtobyhandlerwillbeinvokedwithargumentsig.Inthelastcase,handlingisrestoredtodefaultbehaviourbeforehandleriscalled.Ifhandlerreturns,executionresumeswheresignaloccurred.signalreturnstheprevioushandlerorSIG_ERRonerror.Initialstateisimplementation-defined.Implementationsmaymaydefinesignalsadditionaltothoselistedhere.
intraise(intsig);
Sendssignalsig.Returnszeroonsuccess.
va_list
typeofobjectholdingcontextinformation
voidva_start(va_listap,lastarg);
Initialisationmacrowhichmustbecalledoncebeforeanyunnamedargumentisaccessed.Storescontextinformationinap.lastargisthelastnamedparameterofthefunction.
typeva_arg(va_listap,type);
Yieldsvalueofthetype(type)andvalueofthenextunnamedargument.
voidva_end(va_listap);
Terminationmacrowhichmustbecalledonceafterargumentprocessingandbeforeexitfromfunction.
NULL
Nullpointerconstant.
offsetof(stype,m)
Offset(inbytes)ofmembermfromstartofstructuretypestype.
ptrdiff_t
Typeforobjectsdeclaredtostoreresultofsubtractingpointers.
size_t
Typeforobjectsdeclaredtostor