Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

This appendix dr scribes aU library functions support d b,y C89 and C991.

~ When using this appendix, please lkJeep the ,~" Ilowing points in mind:

.1 In [be interest ofbrevity and clarity, l've omlaed nlany details, Some functions (notably print! and acanf and their variants) are covered 11m de,p'1h elsewhere in the book, so tbeir descriptions here are minimal. For more informatinn ,arbuul a function fincluding examples of how i1"',9 used), sec the sectionls I listed in italic' _1 the' Iowernght corner of UU! function de 'cripbon.

I. I~ in other part of the book, italics, are used to indicate e9g differences, hie name I and prototype of function that were 3!_ ded ill1'9 are shown in italics, Change tn rC819 proto~ypei', (the addinon of the word restrict tOI the declaration of certain parameters) are also italicized,

Functi,rcln ... l i ke ITIilCroS are i ncluded in this appendix (with the exception of til type-geDlerirc macro in c::tgm.aeh .. h,) .. ~,a,ch prototype for a 11ID,cro is, D~'~ lowed, by the word macm.

• In C9191" jlOlm, <math Ii h» functions have three versio - (one leach for float, doub.le, and long' doub.Le). All three are grouped into ~ ingle entry under the nome of the doub I e version, For example, there': ollly one entry (under ,acos) for theacoe, acouE, and acosL functions. The name ofeach addlUotl:a.1 verslon (acosf amJd .a,c'Q,sl!i In this example) appears I~(J the 1efl of itl prototype, The -ecomp Lex Ii' h> function ,I which 01 0 come in three ver-

., ions", arle' treated in a : imllar fa hion .

• 1 MO'1'O,f' Idle <wchar. h.» functions are wide-character vers ion- of function I found in other headers, Unless there s a significant diff renee in behavior. the

'74"7-'

. ·":Ir ... r

7- .11"8' ~~,

Appendix' D' Standard Library' Fu'nc,tians

die cri ption of each wide-character function simpJy refers the reader to' the corresponding function fou nd elsewhere,

lf somc aapcct of ,ft function' behavior is described as, implementationdefined; that means thrat it depends on how the C I ibrary is implemented. The function will alWB[,Y'sleha:' e consi s;'tentli,y, 'but tbe res ul tsmay Viitry from one system ['0 another. (In other \v'ord·· check the manual to see what happens.) Undefined, behavior, on the other hand, ls bad news: not only may the behavior v,ary- between . ystems but th ' program may act '. trangely or even crash,

• TIle des cript lons of tll811)1 -emat.n, h> functions refer to. the terms domah error and lTJR§'(j' error. The way in which these error 1 are indicated changed be'lWI0M1IC8,'91 and C9:9 .. For the C'89 tre tmem 0'·' these errors, see Section 23.,3., F~Of the C919' treatment, ' Ice SeclionI23~,4"

- The behavior of the following funcnoins is affected by the current lncale:

-cct.ype I' h·:> AD functions

;( at.d.i,o " h» Farm laLtt I ·.d inputloutput functions

<s,tdlib; ~ h:> Multibyte/wide-c'h,ilnJctt!'T conversion functions numeri ~ conversion functions

s.t,rccoll, strxfrm

s,trftime

<strin,g " h» <time .,ll>

<wchar F h> wc,slooll~, wc!sftime.~ ,wcsxfrm, formatted input/ourQllut fUJ1ICtiOIU;,~ numeric conversion functions extended multibylc/widc,,,,[:hara,cler eon' en .ion functions

<'w'ctyple OJ h» All functions

The i,salpha function, for example, usually C'b.eC'I~', whether a character Ii, betweena and Z 01' A and Z. n some locale: '~ other characters are considered alphabetic as well,

iab"ort Ab~ort Pro,gram' vC'id a~bo:ct (void) ,;

Raise the s IGAB:RT' signal, If the signal isn ~t eaueht (or iJ 'lh,e sign J handl., r returns), the program term j. natesabnormally and reLlJI'DB an implementatioo .. defined code indicating unsuccessful termination. Whether output buffersare flushed, open streams ar -, clo -Cd'1' or temporary files are removed is i mplementation-defined.

:?II!l' .'l

I~~g'~l"

- t d.L I'b' h

<: 51 I • - 1.'1 ow .,:>

int abs {int ji);

Returns' Ab Q~ote value of t. The behavior is undefined 'if the a- solute value of j can't be

fpp- r- ~ iCe- I'lli r~, J!iiIi d oa ;\'],

I~ ::.1 es -, JII:ll~I.',_.~ .£;~iill£;

B"c"oe Arc ·CD·sine -cmat.h Ii h>

doub.Le acos {double, x) ;'

ac:os'~ flo,at' ecoe i (:floia·t xl ,

,iI.C',OlriS,l long doub'le ac'osl [Lonq double' x),.

R,e,turns' Arc.cosine of x: the return value ls in the .rAnge 0 ito ft.!\. domain erreroccurs if x

isn II t between -I a nd +'~ . 23.3

aCDsal"

a- n'o"""C" S' Ll I_l~ .--" .' '!lliI,

Atc Hype.rbr)llc Cosine (C'99) <'m·ath" h~

d'oubl.e acosb (d'oubl e sc) .~~

t Loat: ecoetd (flo,atx) l

long dorubl,B aco'sh.l tlcng dlaub~e .x) l

R1fl,rU,rns At"e hyperbolic cosine of X~ tile return value i in the range 0 to +00. A domain error

OCC;llI'S if x i less than 1. 231.4

a_B,IC, ,t " II ,m,s Co,n'verl 8ro,"slnIB·DrJ'wn Time to S,tr;ing chaz' = aact.Lme (ccnac s t.ruct; tm * timep1::r) ;

Rill tu me A pointier '[0 a DU II -tenninated string of the form

Sun JUfl 3 11': 4:13: 34 2007\n

constructed from Ute broken-down, lime in Inc IU uet ure pointed flo by t'; mept z; /l:6~3

<' t: irll9 ,. h;>

iii

,8IS1D, Arc Sline'

doub.l.e as i,n tdOluble x) Ii

IQS1,Il~i fl:o,at asi11f (:l1.,Dat xJ';

la.sinl long tloubl,e as.in.l (long dO'uble x),~

RletUfns Arc sine of x; the retum value is in the range -rr./2 "to +ftI2~ A. domain error occur'S

if x isn ~ l between -1. and +1 ~ 23.3

.aIS'~ nh I

I~I _' l.~ .& . .1:..1 :

iil,s,l.,nn,f as'inD.l

Rs"turns

,AlliC ,Hyplsr,btJllc Sin's (C99) emat.h., h»

,d'oubleasil2h (dOLdtJ'le x);

flo'at aainM {float x};

long double as"inhl (lclng d'oubl·e· x);

.Me b,yp~rboLilc sine of x, ,2a4

If the value of exp'reS19.i on is, nonzem. as ear t. does D,odling .. If' the value is, zero, a,s,sert. writes a mes 'age to stderr ( peeifying the text of expr,ession" tbe name lof the sonree flle ,~gntainj~1 the aeU:U~Lr't. and 'the line number of the -a.;,ssert)~ it then terminates [he progrwn by calling ab'ort~ To disable ~s;sert~, define the macro NDEBUG before lnc1udlng <,ass,ert .. h », C99 changes: 'The argument 'i. allowed 'to have a:n.y scalar type:;, IC8'9 specifies that the lype isl into

.,J 10' IC9'9 requires that the message written by as,ser·t include the flame of the function in which the as S ez t appears; ,CI:89 doesn 't have Uris requirement. 24., t

,a t an Arc TBngls,nt dcub Le at an (dOlubl.e xl, ;'

atanf f'lo'at at:an.f (flO'&l.t x} ,;'

at,aDl lang d,ouble atanl (l,ong double x);

R'eturns Arc lang n'~ of.·· : tIt r . U v' ilu ." in th ran" '_ ~~ffi~ 0 +xl:"'.

doubl e at,an21(do,ub,l,e y # double x) ; fl:oat atan21f (float y.. flcJ,at' x);

l.on,g double a, ,an2'~ {long ld,oub'le y, long doub'l,e :x);

Returns Arc .angen loly/x:-, Ilb··. re . ,m Vl~ lue i in the _.~ 11·_ n +1t~, occur L x an _I y are bod] zen I,.



:m81D lerr, IT ~. a,

23.3

~. t a,lJh Are ,Hyp:erbo.lic' Tange'nt (C99) doubl e a ,tanh ,(,d'qub'l e x) l

d'taDh,f fl,(),at a,tanhf (float ) I

a,tanhl long d'ouble ,atanhl (l,ong double xl ,

R,'eturns Arc 11 per ... Iic ang.· nt 0 x, A domain err ·r eccurs if x ill .. n ·'1 between --1 and +~, ..

-'_ ran e r; -,~ ar rna . is equal to ~l r + I. 23~4

at ,ex,i t Register ,Function '01 a,e Ca'i/ad ,B't P"ogram' Exi,t Lnt; at.ex'i. t (vofd (* f'unc ) (voi,d) ) ;

Registers hie fun. tion pointed to by - unc ' .~ a te rmin'~ tion functi 'n. The functi . n 'will bl .. : all .. a i the program erminan . n rme l]y via, rletu.rn or ex! t but not

<8' dlih ", h»

Returns

,abort I.

zero if "~ u c .. ' ful non, ero if it "U' 1_, hilS ~ en reach d),

. an nnnl -,01 Jll ati '8-;dep ndent Ijinlit 216.2

-c :s.tdl ih, ~ h>

dounLe at.of (conan char *nptr') ;

IRIS turns doub.le - alue c IT . _ ~ ing o ,hie lin' est inirJ,~J pa l 01 the tring pointed to

by ript.z that b~ _ . be form of a tll,atini_ - sint number, '.' '",IU n Z,: r L n ~. nv rsion could be perform, d. Tb. FuJrncti I]'I~. be havior i. undefined if the numn r can ~

." f' ,I en ed, 282

1m co I. G'onvslf,t String to Integ'er Lnt; at Of 'L {const; Ghar *nptr);

Rletufn's All Lnt; value corresponding to 1e Ionge st imi'li. _ P' I - ~ ·f the In,~ p . int ··d II by

ap tr th~_t Ik_'< the form to ~ an integer; . TO if n ,I c n ~et' on could b ' P er-

, rmed, 'The functien's beln ]01 i unue inec · ~ benumb '1· 'D~l ee r epresen ed, 26.2

Lonq int atol 'c~on9t char -nptrl;

Return's ,'l,o:ng int ,".~[I!J .. ~ .[[ I spending II . th I' ~ e t initial part ... J the "" ing pointed to by npt r rtrlt ha lb form 1_ f an integen Return ,',,[1' il n c In- ersk n

could b performed, The unction's behavior is undefined if the r umber can't be represented, ,25.2

,a, ,t 0111 Clonvert String to LDn,91 Lon'g In'teg,er tC991 long l,ong l..Dt ato,lI (canst char "'nptr);

Returns' Lo: 9 long int -. alue I. orr P nding II the long . ·t initial part .:f the : tring

pointed '0 by nptr that bas th 'n mn 'an in ,g' r! '. - [urn" ,Z1f!Jl.· if no conver in could be performed, The function' behavi r is und fin d if rh numbei can l be r p ~' ented. 282'

<stdlib.b>

vod.d *b,search (COIIS,t void *key II COBS,t v;oid, =baae ~ size_t memb, IBize~t ad.ze II

int t'*compar) (canst void 'J

conat; voLd 'i') ) i

Searches for the alu ~ p inte to b key ill the orted arra Pi .inted \ b,y hase~ The arra hru nmemb element "e· ell. size byte', long, compar is. a, p' iDI~ r to a comparison function.. hell P" '- - . "1nt ~_ to tb _~' ke ' - I an alTa' elenn nt in that o'rd_ r, the comparison fun ·'ion rnu 1 r turn a nega ive zero 0:[' positi e Inte ... 'e " d _ 'p nding 011 whether the I,.. i I 1,- '8, . , han, e _ ual to I or ,~IlTI'_ _ I , r tb the an - y elern nt,

Returns A pain ,r to an array element that t_·,,'II., e ual to th - e ., R· turns f. nun Pi lin '. r if

tbe . ey is t found. 2a~:2-

btowc cowen Byte to Wide ICharacts'f (e99) 'wint_.t brtOW'IC. (int c l:

Returns Wid, -charact r r 'prior, rin I f c. Return WEOF if C1 is equ ' EQF or Ii ~ e

(when ast to unsigned char) isn t If! alid single ... t1Ylle~-h· rueter in the initial

~ hi fl'-tal. . 21i5

<wchar .. h:>

a,abs

rc',absf cab,sl

ICo,mplex' Absolute Va'/u,e (CS9) <complex ~ h;>,

doubl.e cabs (d'€nlble complex zJ ,.

f,l,oa,.t crabs! (flG'at ICQ,mpls'X z)i i'

Lonq doub.Le cabrsl [Lonq doubl,e comp],ex zJ l

27.4

<complex!lh>

cac'osl R:eturns

d,oUb1.e comp.Jex ,caCDS (.d'oub1~ complex z) l fl0,at clompl.ex C,8,ICCJ.1f3L (fl,oat compl.ex z);

long d,ouble comp'l,ex cacoI,s'J (1.orng Idouble ,cormplrex ,zj i

1_ ompl an . une ' ,I·' b. branch ell ts outside 'Ib.:_ int _ ",a~ [- ~ + I J along lL e r all axis, Th -' return \',(11u.I:' lies in a ,trip matb.eJllaljc,aUy unb unde d along the irnaginai axi . "d in the int .. rv' J [0 x] al 'D, . the re al a' ,i: p 2,7~4

C'a'c-o's' 'f

I .. '_ - ' I 1_

,. -

Cl8co,sh, Complex Ate, Hype~bolic Oosin« (C:99)

ca,co'sllf c.a,co'jib~

Returns

dGub'le IClomple,x ,c_Laclos,11 (do'tili'l'e' compl,e!x zJ'; .flo,~t co"mp,lex c',acc'shf{Eloat eompl.ex z) i

lang 'GQub'le c'ompl,ex c,acosbl (long double ,complex z) ,.

Cmp le #! _ h,_ pe "!boli cc ,in _,' _ 2L _ ith' 0'1 aoch cut at 'J ues II;" th 'n 1 alanthereal ~ xis, The r tum value lies ina hal ~'., np .,f nonnegs tiv V,aiILI',., along the real axis and in t"h interval [-i1t" ,+i1lJ along tb imaginary F,. .ls, 27.,4

"stdlib .,h:>

vo-Ld - ea.l Loc ,( Bize~t nmemb , s.ize_t size) ;,

Allocates a block of m, 'm 'ry for an array with nmlemh, elements, e .. ch with si,z,e byte. The block is cleared b,y ,:_rting all bit -'. zero,

Returns A pointer to th beginning of the block, Return a null poin er iF - block of the

re uested size I_ '"_~~' I I . ll.c· _. ~ 1'7: S

Icarg' C;omp,lex Arg,um'sn" fC991 double carg (doub.l,e comp'lex z)';

float ,r;;'srgr (:floa,t clomplex z);

lo'ng double cargl (l,ong ld'oublle c',o;mplex sl,

Argument pha '_' angle 1'-' Z with ,I b ~,ancb cut along th _. ne 'i ti' e r-eal axis, The return Iu li in the 10.1 rval ~JE- +,x]~ 27;4

carg'~ Q,argl

Re;tu.rns

c,asillf Q,asinl

Returns'

c:complex~b>

,dlouble ·complex ceeis: (double c on'lp 1 ex' z} 1m' f,loat c'c'mplex c~a,sinf{fl,oa,'t c'omplex 2);

lOlng daub'l,«=! compl,ex casinl (lon,g d,oub,l,e c,omplex z) ~

omplex .. csln ·0 z. with br neh cuts outside the inrerval ,-L~ +I].t ng the real axis, The r 'turn alue lie in a " ,E I m:' -, e -- uicall unbounded, Jong the irnagi-

nary Itt ,and in the interval [-a/2-, +,'ltl2] along the real axis, 27.4

e complex .h>,

d,oublle clomplex C!Gtsinh (doub1,s c,omplex s) i c ,sinhf Ll,o,at c'omple'x ,casinhf (float c',omplex z) l

c - s.1nhl lo'ng d'oubl e c,omp 1 lex' casinhl (long do"ub1e c,c'mpl,e~ E);

_Returns I. nnplex t ric b_ p,', rbolic 1 rim _f z; with ranch ell on side the inter _.] [-,i, +i alon ~ 'the im ginary ," . The I, turn _ alue ]"t,e', in a strip mth ema i,cally unbounded

alon -= t11'~ r, ,_I " .. Is and in the int rval [-ift/2 +lK/2] along I ~~I .~ 2'7.4

ail tan Comptex Arc 'Tan,gent (C,'99)

<complex.h>

double clompleK cata.n (d"oubille c"Qrnplex ,Z) l c,atanf LLoei: co,mp,lex ,c~at:anf I(float ,complex z,);

catanl l.ong do'tWle comp'l,ex catan~ (long d'ouble complex z),J~

Returns C mplex a c tangent of z with bran h cut, ,n" ide the m~er" J [-,i +1] alon th imaginary axil': '. "he return value tie L in a, 'Clip mathematically unbounded along the imaginary a" i and LO the interv I r -x/2 +lt/' I along the real i '~ 27.4

le'a t,snh,f ,e,a t,iLn.hl.

Returns

dQuble r]omp,l,ex catanh (d"o,uble complex z);' f,lo,at co'mpl,ex c,at,a'nhf {flaa'- c,ompl,ex zJ;'

Lonq double c,ompJ,e8 catanhl (lang dGynl,e cQmplex z ) /

, 'OEn, ,l_~,_ ~ -" b. P rb: ,lle ' angent ' ,[ Z 1 "Ith branch leu x ouu id ' the Inte ',II' I ,~I ,-, + J] Jon ' the realaxis, The return alu fe' in a strip math, matically unbounded alone the real axis and in ttl l inteNall-inJ2 .. +i1tf''] ',II ,nib the imae 'nary ,I i' 27.4

cbrt Cube R,o,ot (C9,91

doti.bl,e cbrt (double x); float cbrCf(£loa- x};

long ,dloubl'B rC!brtl tlong deublle ,x);

cb'r't;f ,ob'rtl

<math .. h,>

R'eturn's' Real cube r ',-t ':" x.

23.,4

CC,Qs,f ce',os']

,R,etur",s

-ccomp Lex .. h>

do'ub,le c,omple,x ecoe (d,oubl,e co,mp,l.ex zJI; flc;at c,omplex ccoeti (flo1at comp'l,e'x Z)I,OJ

long doub,le ,c,ornplex ocoel. (lc'ng ,doubJe compl.ex z);

emplex CO~ in" of z.

27.4

C'c'os',,hf ccoshl

Com In'tt:::),,,,,", Hf'Up' 'sr,h".I;,,. Cns~';n' -'9' '''gl1JI ILo1I_: _, r"~ lJI·"UIV'~,"",'" VI I, ", 1,ILI, ,a,

double' complex ccosti (do'uble compl.ex ,zJ ,,'" f 1 oa t ,compleK ccoebi: (,f l,oit t ,coR!Pl ex z J i

l'D,D,g dou,~bl'e c,omplex ccoetil: (long do'uble complex z');'

R'eturns' I, omplex byp rbo ~ 'co; inc " z,.

2'7~4

c ,e ,i 1 Ceiling'

[double' ,ceil (doubf e x) ; flolit c1'eilf l i Loet: x) l

C'lej,lf' ice.tll

<math .. h:>

'mall .' h i ~.

'"_ ': ' 1 integer r _at 'I~I gr ater II

23'3

,c,az-pf le,ezpl

,Re'tums

d'oubil,e c,omple'x oexp (,doubl,e ,complex z); iil.oet: oo,mplex e,expf (flc1at co,mp·lex z) i

Lonq d',ouble ,colmplel-, cexpl. ll.onq double cGrBp,lex z);

Cemolex I'C~ exponential t f z.

2.7~4

II

C ~mag ,1,magina'fY Pert of Clomp/ex Numbe.~r (C99)

do'ubl,e c i m,ag· (do,ub"l ,s c:ompl ex z l' ;

c':l.magf ,c.imagl

Rs,turns

float c,imagf{fl,oat comp'lex zJ i

long do,ublle cimeql. (long daub'll!! ,complex z i :

Imagin, _~ p _ of z;

27.4

Clear IStream' EmJr

void clear'err (F'I_LE 1 sltrleam, ; I, Iears the end-r f- file and rrer indicators

~ tream pointed to by 8 t ream,

22'3

'II .~

cLoc k Prooessor CJ:()'Ck c~lo"ck~t €]_c'ck (void) ;1

,Re,:turn,S Elapsed proce ' "ar time (measured i.n "clock ' '" cks' ) since I he beginning 0 . program

execution. (, 01 conv L rt 1111:1:,)1 • econds. divide by CLOCKS, P'ER SEC.) Returns,

- ........---

(clock t) (-1.)1 i- the rime is una ailable or can t be [I' resented, 26.18

cl,ogf clogl

Returns

doubl.e Ic'o,mplex c'log(aouble' c'lomplex 2;)'; :Elloa t cOlmp 1. f!1'X c·l ,og r 'Il f 1 sa t c(Jlmpl,ex z J' ;

loD~g doubl,s complex ,clogl (lo:ng dall'ble cQ,mple'x z) r

'_ om ples natural base-e logarithrn of z ,with ,3 branch ' 'ut alen - tbl D_gative rem I~_- i ;; -be retun alue He in ·"1 i trip rna' hemaf call unt ounded along rh _ real axi _

nd in the in ,Ir'· al [-i,,;' +i"Jt] alona the imaginaf 27.4

II

CO,DJ Co,mp#ex IConjugate {C91§)

C'Q,D,jr conjl

Returns

-ccomp Lex ~ h'~'

doub.i e ,complex cou] (double complex z) I' t 1 oa t cOH1pl ex conj f (f.l ala: t compl ex 2);

long d,ouble' c.Omplex corriL [Lotiq ,d'ouble c,ompllex z) l

I, . amplex c~ njugate D" ,2"

27 .. 4

copysign ICopylS~gn (C:99)

e,opys i gn,f ccpysig,1l1

Rs!turns

~IO"IS

~I,. _'-=-.1

-ematrh .. h»

d'olilile copysi.g!l (d,oub1e x, doubl,e y).t~ iLoat: c,op'ysigIlf(;fJoat:K1f float y);

lang doubl,e c'op¥slgnl (long double1 X, long double v).

23.4

double COIS (doub.le xl ; cosf flo·at coat: (flo,a't ~) l'

,ccu!I'l long doubrJe cael. (long ,d'Duble' x);

,Returns eosin or x (mea mred in radian .'J~

23'.3

C OIS h Hyp,rJ'rbo#c Cosine

doub Le cosh (double x) ;' co'sbf float coebi: (flori2lt x);

,008h1 Lo: 9 ,double coslnl (long ,daublle xJ';

R,sturns Hyperb til. . I 1 rim I ... x, A ran e IT r 1 ' u_· i: hi. mJ.c_ ·lu" xi, £1 .. I Iar _ "

23 .. 3

CPOI' , C,ampl/ex ,PoWrslr {C99) ,<comp,lex _, h:> daubl. e co'mpl ex CPOIir( (doubl e c:otfnp'l,e'~ X I

do'uble Ico'mplex y) ;'

,cp'ow,f float c',ompl,ex cp,o'wf(fl,o'at comp,le,x X,

lo,at Ic·,ompI1ex Y)';

C:'p,c'w:l long ,cl,oubJle co,m.-lex cpowl. tloD'g doubl.e complex x, long d,o,ub,le comp,l,ex y) ;

,Returns

ne nti e

- 1 --

27<4

,c-p,"ojf c;p,r,ojl

Re:tu,rn,s

ecompLex " , ~

doubl,e c'o,mplex cpxo] (d,ouble' G',omplex e) j' f1.,o,at ,complex CPIIOj.' (.'l,oat complex z i ,

long d,oub'le complex cprojl (110 9 d',oUble complex z) ,;

Projlc "0[1 .,' z n I. th ~ Rie ann ph ere, Z is r turn -d unles on f ns tinfinite i ,hi h _ g lh return alu i INF ~I ITY + I '* copysi~ (0 .. O,~

c imaq ( z) ) 27 .. 4

cr'sal RSEJ'/,Pa,rt ot Complex Nu,m,b',sr (C'991 doubl e cr'ea 1 (d'oub'l e ,campl ex z); ereai,f float cres,l! (flo,at compleJx z) i

cre'a,ll Lonq doubl'E! oreall {long doub'le comp,lex ,zJ i

Rei'u,rns R at parr r z.

27~4

ccompLex ii h:>

double cc,'mp ex ce in (double co;mple'x z);, cSIl.n£ £10,a complex c,sinf'(float c,omplex z), ..

c's.in,l .l'Ollg double c'c,mpl'9x cein). (long dOHb~e complex zJ' i

,Re,turns • mplex ~ ~I. 'Z~ ,27.4

a, ,~in,h Clomplex Hyperbolic Sin'9 (eg9)

".. ,I h til:

IL;o ,Sl., D, .1 "".

c,sinbl,

do'ub'l,e COmPlex csinh (d,oublis clo'mplex z) ~ float ICOlm-p~jeX csinhf (flo1a,f; complex e) ,i

long ,daub'1e aG,mplex as'J,nhl (lon,g double complex z);-

Re;turns . omplex ly erb die .' iue·, a.

27.4

clsqrtr csqrtl

doub'le c,ompl,ex csqrt (,d'oubl,e c',omple.x z); float Qlo,mp'lex ceqxt.E (float cotnplex z) I~

lOlng daub,l,e IC.'I oml' 1 ex' c:sqrtl (long double e,omplex et :

Returns Complex .. 1 ua e root of 2 ~I , ith a ranch cut along Uti negative real axis. Th

r tum value lies in the right half-plane (in luding the imaginary axis I., 27.4

ct,Sll Complex Tangent (C99)

,c:tanf et'anl

. .-,.... ~mp,: 1 ClX-c. b ' .....

~ 1~U' ',:..' ~ .. ~ .riJ1/{!'

d10uhle compl.ex c'can, (doub,le ICGmp1e~ z); flo,at ,aomp~ex C!t:an.f (float oompl.ex z),

Lonq doubl.e co'mplex ctanl (long ,d'Dubl,e ,compls'x z) i

27.4

ccanh IComp~ex Hyperbolic Tsn:ge.n:t t1C99)

,cta.nhf ctanhl

Return's

<::co,mple,x ii h,;>

d,oub'l,s cOlmplex' ,ctanil (double 'camp 1 lex' z) , . . float comp1l1ex ,ctanhf (floa.t complex z) i

long doub.Le comp.l ex c:tanlrl (l"ong doub1.e' co',mp'le.x zJ I

Compk '. hyperbolic tang-TIl of z ,

II

ctl.mle

Ootwett Calenldar Time to' Strlng

chaz *ctim,e (conat. ti'me,~t *timer);

A pointer to a string describing local tim- egluivaleDt t"1 De cal nd . toby t.Lme r, Equivalent to ,aeotime (l'Qcaltime' (timer'),),.

U'me Pi inted 26.8

double difftime (time_t tim,s!, time_t 'tim,ell) I;

,Relurns Difference between timeOtb' arli - lim and timel~ 'mea ured in ieconds.

~B"" lijl

e: ,I.-..J

d,i'v Integer Divieion div t div(int numez , l.n,t danom) ;

Betums .' di v IE. uructure containing members nam ~d quat. (the quotient when numez .. di idd b '. denom) and r'e'm ., the remain er), The behavi r 1, un 'fimd i 1= ith r part of' he result can': be represented, 2;112

e.r f Erro'r Function ,~C:99) double erf (d'oublle x..); flo,at erff (floa.t x);

Lonq do'uble' erfl (long double x);

erff Isrfl

«mat.a ,.n>

Return.s'-m x) where err is tlu i Gau I' ia - error functio -

erfc' Co,mp'/S,m,Bntary Er:rD'r Function f(99) double e.rfc (d,olublel x) ;

flioat erfcf (float x} ,~'

lo'ng' doub1.e erfcl ,(lon,g d01.ible x),

erfct x) = 1 ...... c: rf(x) where t rf t ~I th Gaus jag I rror funeti r n., A r In e . nor 0 ,m

'if xi' too large." 23.4

,srfcf isrfcl

eX.i t Exl't lrom Plfog'ram 'voi.d exit (int ertatus);

Callsall fun lion' regi tered -- itb ,atexit fl, hes all 0111' put buffer', close: 31] open stre ,_,m'l. ,IemOYe: an ttl· reared by t"mplfile. and terminates the program, The value' of s,tatus indieau s whether lb,~ rogram terminate d nermally, The only p ortab lei alue fOI IB,tatu,$ I.' I Q ani" EXI'T_S,OCCE8S -Uti indicate

uec essful t rmina ion I plu· EXIT'_FAILURE (ur I ccessful termination I,

9,,5'1 26~2

,<:stdlib,~ 11>

Ex i t ,Exit ttom ,P'ro,gra!m tC'99~r

VrD.1.d Exi,t: tint stat"us),~

- .

<stdlib"h>

Causes normal program rerminaiion. Do .- n t call unctions I." is . en d with atexit: or ignal handlers registe red ,ilb si'gnal. The ".' returned '1- determined In the I arne w' a. ror lexit~,· reth r ut u bUrr·'f. I re DUI.hedpn

treams "-, I ,.-10'1 I. - r ternpon I' t11 ~ ~ are:1l move i ] m lernentarion ... defined ..

2:6,,2

exp IBase~6 ,Expo'n'sntial double exp (doub Le xl, " LLoet: expf (tlo:at: x);

lo:ng doubll e expl t long daub'l ex) ,;

s'xp£ expl

IRls'turns

emat.h oc b:>

1_ raised ',' the P wer x, A I' nge error r ceurs iftb_ magnitude 0'" x it· too 1'. ge. 23.3

axp<2 B:ase'-2' EX:P'onentis'I' (e99) dJouble lexpl2 t doubl.e. x,) ;

float exp,2f (float x),~

liang d'o'uble ,exp,21 (long ,doubie .x);

',~Wl, e error ecurs if the 01 !,gnitud, of x 1 ~ t ""., '[ " "e~

234

expm,l eese-e IExp',on'sni,tia,1 Min',us 1 r(legy} dCl"I£ble e'Xp'mJ.. Idoubl.e x}: fl,oat exp;ml,f (flo',at xJ;

lo,ng do,uble IExpmll (long doubl!6 x) 1

18zl'mlL ,ex;pmll

doub'l.e fabs (doub Ie x) ; £abs'c' El.oet: fabsc (float X)',~

Eabsl ~ong ,double fabsl r( long dou~~e. zc) ".

RSI;rurns' .bsolute value f x,

23.3

e st.df o .,h~

~nt fcl,o,s,>9 (FILE *stream);

Close, the .tre rn pointe 0 by s:tr'earn. Flu ,he· any unwritten output remaining in tbe str am' buffer. Deallec res 01 ... :uJi er if it wa -,I allr c, ted ~ uu ali ~ __ I .

Positive Differen'C6 fC99)

fd'imf fd1ml

Returns

doubJ'e f,d_i.m (doubl"e X, d'oubl]e y) ; t Loet: fdim£ (float. x,f1.,oat y);.

lang ,d,oubl,e fdiml (1011,g Ido'uble X, lO'1:1g d'ouble y)"

Positiv diff rene ~ ot x Ind y:

{:o v ~:~;

,ang! . rror m '.' C 1lT.,

23.4

fe,c 1 IS ar,excI.P t, C~fJar ~/oating-p(J,int Exceptions (C991 int feclea.rexcept (int excepce) ,

A t_,m. t to clear the floeting-poirn ,c' ceptions renr ~-I nled by except;s,

Reiru,~ns Zero if exc,ep·ts is, zero I f if ,3.'0 specified exception' wen successfully cleared;

oth - rwise, r turn a rn ,'n>,:-'r, . value, 27.,6

f'egetslnv Get Floatin,g-Point.Environmen't (C:99) int fegetenv (renv_t *envp) l

Attemp s t rstor the current flatin- =p. int environment in [he -, ject ; imed _' by en.vp~

Returns ,UI Q if th . envrr mment was sue '.,"- fully : tor d: otb rwise, rerum I _ n mzern

alue,

·····-0 if the ' ,talL'- I, I, 'the tstus fL - " nonzero value.

DC _ e '.' 'ully t,oIed"", other .:~ e. __ I urn 27.6

int fe.ge,t,exfJ'epltflag (fe'xclept_t *fla.gpl int excepts); Attemprs to retrieve the tate - 'of the HO',~tin':'~pDbHra:tl1 - n,Et~. re pre - 'flit· ,I by except.a and store -bnl in tb ebie t P dnte ",: .. ' fLaqp,

£1 . g,. -, 'trlo'uD,d GIS,t· ,F/c',Btin'g-,Po,in,t R'Q u,n ding' D'irection' (CeS) ·int fe'getr,o'und' (vcd.d) ;';

Rerturns . alue (I_ the roundin -directi n rna r . · rep~e ieots the urren r unding direc-

tion. R urns t D, _,gab' lu if the r UN, ut roundina direcri )0 . an" be determined . -r doe: D 't match any ~ . und ing-direcrion ma oro Il ,2:7.6

A,ppend;x D S,tandard Libra'fY Functions 75,9

feh,cld,exc,sp t, Save Floating-Point ,Enviro'nm,e'nt Ir,_, .,.~ Lnt: f,ebol,d,exc,ept (£env_t *,en1r'piI);

Saves the current 111 'atiJl;g~p . inl zrr uonmem in thebje - .. lnted to by envp.

! ] ~ , rs ,b· flo ting-p in DDd aue mpi ~ to in tall " nOD"'~, p m de f rall

flo" ing-p [m ·._C_ tions.

Rs'turns ZCSl it non-s . p flo l1I[1G- " int .. eeption handling was succes sfully in t lled: . th-

a nonz . ~o value, 27.,8

<fenv"h>

f eo f Test for End~of-File

<stdiEL.h>.

int f·eof I(FIL-E *'str'E-ram);

,R6',turns A 11 mzer .valu if the eo I.~ f ... fil" indic I" i: set for U '_ ' tream pointed tr b-

stream'". therwis " r _ um_ , erlo'. ,22.3

fs'r,aiseexc',spt: Raise' F~oatjng~PCJlnt ExceptlorJ,S (e99) <::f,env.,b>

.int r.ert2iseeXCep,L (int exceptie) Ii

ArD 111 ['_ [_. r~ · e upporte I. I;} iug-point __ . eptionsrepr ented b ex,ceptrS.

R'et.urns Zero i ,excepl::9 i . zero or if all specifie e'X'L:· ption I were successfully r Ised;

tIl rwise, '-,et rrn ) . aonzei value. 27~,6

int fe,rror' I( FILE ok st; . eam 'I ;

R,s;turns _ ~ n anze 0 value if the e 'Of indicator L s· ,t ~. r the ·tremn pointed to b ' at.ream:

o rherwise, returns l ro, 22: .. 3

£ess t,env s:s,'r F/oating ... Point En'viionment (C'9S)

<fenv.h:>

int fe,fj,etenv.(coDsC fenv t *envp);

Attempt, to ", abli h the floerin -p iint environment repre sented by tile pointe - to by envp.

R'(sturns Zero j. 'the en ir: nm 11: va .. ',00'(':'_-' .~, ullx e t blished: . nherw ~., returns an· :OZ'lO

alu . ,2'7.6

ill,t fe,set9x!G:eptfla.g (co'n,st f,exc,(!pt=t *flagp, int excepts) i

utempt [to 0: er Ole' t1 ati n g=p oj n t statu flags represented by excepts 0 ie

states _ . red in .' obj', ~ t p inred I • b f 1 aqp.

Returns Zr [0 if· excepta i: em or if all .. eified xception weresue _c"," ully set; other-

_ .. e etum nODZr ro v u ,_- . 2'"-6

fese tro'und S,S:t Floating' .. P'Oint R'Qunding .Direct~o,n (C:99~'

'" f '@nv ,. h:.>'

I, t: .1ll

eeetiroutui (int xouruil ,

Aue'ln~pl' to establl h the rounding direction represented by r1ound ..

Re\turnsZe[o jf the requested rounding direction was e tahlished; otherwise, refilms .:?,t non-

zero V~J ue, 27.6

f,sltes'ts1x',cept Test Fioa:ting--Point Exception Flags (egg) in<t £eteBt,exC',ept (int exce~ltsJ;

,<:fenv. h>

Bitwise or of the floaliug-point exception macros corresponding to the currently

, ,

set flags for the exceptions represented by except; s. 2,(.8

c: fenv . h·,>

int feupdateenvtco:n~s't f,env:_t *eln-vp);

Attempt to save the eurremly rais ell floating-point ICXJ:.CPUon ~I install the floatingpoint environment represented by the object pointed to by envp and then raise the saved exception ..

R1eturns Zero if all actions were successfully carried out; otherwise, returns ,;3. nonzero

val lie. 2'7.8

f:f ,1 U,g"b, Flush~' -" B,uffs'.r int fflush (FILE *stl:r~am);

Wtittlf:s fIIny unwritten data rn the buffer associated ""ith stream, 'whil;;:'b points to ,~ . tream that was opene d Ior output or updating. [0 ;st,re,a'm is a null pointer, f f 1 ush flushes aJJ streams that have unwritten data stored j OJ a buffer;

<.stdie .h,>

RI,e"uFn- ~

I ~~~J' '~"I' _I~I

f'g.te,

Reald1 ChIS.ra,cte,r tram ,File int flg,@tc {FILIE *stream);

Reald, a character from the stream pointed to by s'trleam,.

Rle,tums Characterreed from the I, trearn, If fge'te encounters the end of the stream, Jr set, the stream I end-of ... file j ndieator and returns ROF,. If a read error occurs, fig's t e sets the stream's error indlcator and returns BOFI• 22.,4

f t-' -

I .'-,-, '- , . I' ," -

I ge"pois

Gelt· File Poeuon

int fgetpos(FILE * restrict stream, fpQs,~t *' reet.ei.ct: PIOS) ,t

Stores the current position of the stream pointed 10 by sitreanlin the object pointed to 'by poa,

Rei turn 5 Zero 'if successful, If the call faHslc returns I nonzero value and stores an implemen-

ration-defined positive value in ·errno,. 22.7'

f'glets Read String trom Filel char *fgets(char * restrict St int n, FILE • restrict stream);

R, ad_ characters from the stream pointed tD by s,tr'ea'm an, stores them in the arra - pointed t by s. ~"_I': ing (_ 'P'I at th ~·_~·t nco -line ~ h_: n _ ter ( hich i .stored in the string), when n ~ I har erer have been read, or at. nd-of-file, fgets, . ppends a null character to OJ,e string,

Returns s (a pointe r [, he' array in bleb the inp rt i ter ' .. Retum a Il.UU p ~ll]'.er if a re: d ~'r _ cUt· lor fgets n '. unters tb ._ nd of the stream b,-13~ If c_ it has sto .' , any character 22.5

fge' . t'·liill' . .,..,

I~_. -I. -. I _ "n fLji'

ReB'd' 'Wide Cha',ract:ef' 'rom' Fi~e. (C991 win_t_t ,fget'wc ,(FILE *str,e,am.).;

,<:wcharIi h:>

25.5

fgetws RSQ,d Wide S,fr.l'n'g ttom File (C99)

wchar_t *fget '8 (wcn.ar_ restrict B,I in ,- n,

FI'LE * r'est'l-'1ct str'ea,m)1 i

Wide-j_~baracter ver don of fge,t.s~

26 .. 5

f1 010 r ,Flo(J'r

doub Le flo.o,r r( double x); floorf float flolort (flo'at x);

fl0'olrl long Idouble floor] (long d,oubl·e x);

R'etu~ns Larges int ger th l i· le s than or 1.·08J 0 x,

<m,ath., h»

,fm,a, ,Ftaa':ting Mu,/tiply-Add (C9,9) double 'rna (d,ouble x., double y, doubl.e g);

fmaf :float fma.f tf:loat x , fl.oaE y,. float z·);,

f.mal long double f.m'a.l (long do·uble x, lon.g d,ouble Y, Lona dlouble e) /

Returns .x x y + z. Th result ~ .rounded only ncr u ;1ng the rounding mode I.' Ol]i: ond-

ing [0 FLT ROlliNDS. Arange C1TOir ma.~ occur. 23 .. 4

<:.math~l1L>

f.~ -lax ,F'o.a.iing Maximum I(C991

Lmaxf emaxl

Returns

d'oubl,8 fmax (.daubll,e x ~' doubll,e y),f.10'ilIt fma.xf (flo'at: sc, float Y) I"

lOlng Id·oub'le fmaxl {long double' XI ~ong d,ouble y);

_ . .' aximnm 'of x and y. ' on _' argument i· - B num ri value i ." returned.

. nd [hI_ o ther I - numeric, th 2~'.4

<rna.' h ... h:.

double fmin. (double X" d'oUble y); .fm1nf float :Eminf (float x., float yJ /'

t'm1nl l,o'ng Idouble' Em,illl r(l.ong double zc, Lonq d'c,uble r! , .

. Iiulmum .. ', . x ai d .Y~ on argument is a N I and the '. ther is numeric. the

numeric value i" returned, 23:.4

fmod F/aatin'g Modu:ius

ernat.h . h:;:.

doub l.e fmod I('double x, doubl.e y) , £mold'E £10',ac :fm{)df tEIoat x, float Y) IF

fmCJ,d'l lon'g d'oublle' tmodl (long d'oubJ.le x, Io'ng ,doublle yJ ;

Returns Remainder wh n x is di' id, d -y y. If Y' II Z,CTO" eithe a, -I,e main rror ccur or

f open Open File FILE *fope,n (oonat; c'har * restric,t f i.Leriarne ,

conat; char *' «eet r iet: mode) r

Opens the ~JI wbosle name i .. pointed tit'll b fi Lename land a sociat it with I, stream, modes p' , ifie, 'tile rn : de in ' hich tl1 file i ,-' to -', ' p: ned.. I r, the error and land- f- t11 j; ndlcan r

<,stdio" h,>

Returns - file point r _0 be us' - wh m perf rming subse U'.Dt operations on 'the fil I.

Return, it null pointer if tb, rile can't b np ned. 221,,2

fpllC 11 ass i fy F~o'ating .. ,Poinf Classification (C9:9)t int £pcla,ssify(re_lI..,Jloali:ng x l :

Rei turn s - ither p,p IN,FINI'TE'I FP NAN, F'P NORMAL~ FP S,UBNORMAL 1 or FP ZEROI,

_ ~. iiIiIiiiiiIiiii ~

deperu ing 0'0 w·betller x i infinity not ~ number normal, subnormalc or .:. re,

re" : ecti '. Ie] . 23 .. 4

:f'printf' ~ormatt;ed File Wrlte

int fprin'tf (,FILE: '. restric,t str.eam~

conat; cha r * restrict forma:t, il

-r- - rites I, utpu t the- -_I ~ am pointed b s trleam. Th '- tring poime d t

f,ormat I,p- cifie I bo. 'u'· quent _rg mems v in be di nla ed .

. Re,turns Number 0, characters written, Return at n,~U, e value if an error. - ceurs, 22.3

f'p'U t c Wri'te ,Ch'aralc,tsl(, to FII:e int fpute. (int c , FILE *9·trle,am) Ii

rites the character c to ttl -' tream point d to by st,ream ..

Returns c (the eharaeter Wlittt0 )1. If a write error OCIC1],rS" fp'u"tc sets the I tream's error

indicator md ric, urns EO'F~ 22;14

f:pu t _:_ Write' String tOI Filel int f'put.a (coriat; e:har * :t"e,atrict 51:,

FILE 'It rJes'trict: Is,tre.am) ;

- - ri-:_ th sn ing p lnted te by s to l~, stres m pointed t I b,Y s·tream.

_, td.1" - h

<sr .. '.' 10, ''>

R'eturns .': n' nne' "_ It1 I: valu if· U ',., . - ful, Return - E,O'E if a rite lerrot 0: ur - . 22,,5

,fpu,twc Write 'Wide Cha~al,cte" to' File fC919j'

wint t- fputwc!' (w'cllar_t c, FILE "stream)'; act ,- r zersic nf f.put;e ..

25 .. 5

W~;te Wide StrIng to FU:e (099)

int fputw:s (CG'Dst w.char~t * xeet.x ict: e, FIL,E * xeetai.ct: strea',m);

ide-e b ,,' -ter' ersion of fputa,.

<wc:b,ar .. -1>

25.5

,<stdi'o .. .h»

size t fread (vo id * restrict ptr I 9ize~ ad ze ,

si z,€! _ 'IT n emb , FILE ,.. restri at: ,stream) :

, ttem ,'- to' ,e d nmemb elem '0, e - h size b,' II' g., r--'I' I lh, ,. pointe

to - ~ !rtream I d t r;- them in tbe ~ rray pin' - d I 1'11- ptr,.

Rleturns Numb r of element ,8 ctually read, This number WLU be le :- than nmemh if :re,ad! len counter end- -file or' reo, I I IT if occur ~ R erurns Z ~_ I if ither nmemb Of'

iii ItI

S,~ z e l ero,

Frs'e Mem'ory Block void free (void -ptr);

Releases the' memo_- block p _. ed '_: ptr,i[ ptr i'- ,! null nointer th, C'-_ '

bew [1 ' e 'ect.) be bloc mu t ba -,',' n all cat J b '.1 ca. _loc ma Lkoc.

orrealloc. 174

<st:dl ib ,"' h»

f r e:o:pl en, Reopen IFile FILE fre,open (csns,t c c_ar - I!,estric~t filenam'e ~

ona t C :_,ar * rs's,' riot mode.,

FILE * z-eet.r i.ct: stream) ;

Closes the file ,UL loci ted with 's t re am .. tit- D op - -h~- fiJ wilt} - e name i pointed to by fl.lename and ·_SC1It~· i ith str--'am~ The mode oarameter h" s the ame meaninsas ':n ,_ I~ J of fope R leggl i/'l"l -, ~, -I filename 1'" -~ nun '_ int r frs,cp,e'n I' ttempt to chang th- " ream r mod t th t oecifie 'C,~' mode,

.cst:dio '" h»

RSlturn,s' Vallle of at r'eam if nh,' operation U~' eeds R uur I a DUU pointer if tbe file can t

b, pie, ie . 221.2

,fr,sxpf fr,sxpl

double t rexp (dcuhLe value, int *exp); float fre'xpf-{float va.Iue, i.nt *exp) ,~'

long douol e Erexpl (long double value, in,t -Its'xp);

'plilr va I ue inti ]~. ti,ll) p. r J"and an -' p neu n in ueh a --',_1)1 iha[

value = x 2"

i . normalize ," - l~ t utber . sf <. 1, = .. ",tor n in the obje :t pointed exp,.

,R:fj,tUfIlS' /" the fr~ COl. 'n_:_1 part 'Jrfval ue, .23.,:1

int f acarif (FII,E .' neetir i.ct: s,treaml

clons' char -- resrtric,t format, '. ~ " } ;

Reads input i ems "ODltb~ib~,e'anlpoiDJt d to by at r eam The string ] inted t b. format ~~'c_ifie~ the fnrm t of the it ms t bel d.Tbeargumen that 011;' format porn." L ,oblec't"· i- which the 11 ems aIle 0 b· ',.11 red.

Risrurns' UJD'·r Or . ]D- ut item ully read and stored. Rem rs EOF if . n input fail-

ure' OCCUI ". before any items Ian be read, 22.,3'

e s t df.o ,.,h·:>

Lrrt fseek 'F'I"LE *str'leam, Lonq int" set I int whellce) ; Change: the' file position Indicator ror the stream pointed to -.y at.ream. I_

whence is SEEK_SET the ne .' po idol] i' e beginning oftbe Eil pl . ,offSE!"t

b tes. I wher .ce i I SEE,K CUR I Ih n~' ,j ion L the current p . ilion plus

offsetl,c es, f whence i . SEEKE,ND~ the ne pc siti n i th I od .f th '1]1 plu off,set b tes, Th ' value af Q,ffset rna: I be' ne,~ ative. - r ·t'l earn, either off aet; must be z .10 Q[ wh,en€e must be SEEK SET lID offset .

alue 0 It,ine. h a pre ious call 'f ftell~ FD'r bin _1 . reams, f,se,ekmay :not 'IUPPO.r1t all in which w'hence .. ~ SEEK_gNDI~

22.,7

f' 9, e tp 0 S Se:~I. Filsi POI,si.tion

CStd10.h>

Lnt; fsetpos ('F-ILE *lsltrlea,m, canst f'poa __ t, pos) ;

Sets the il" p ition indicaror for the' stream p inc.- I," stream according tc he value pointed to by pos (obtained f OlD' prei iO,·L all:' fgeltp'o,s).

Re'tu,rns Z ro if sue'. e sful.: the call ,I I rei' U ""I - o mzero valu and stores n implemen-

tati n-de ned 1'1: · i: e . Ute in errno,. 22.7"

Returns

Determine File Pas;,tiol(J Io,ng; Irrt ftell (FILE wistre,am,)r ,r

I urrent rue po i non ind.i_llt r I r h strea poi nted to by s t ream~ ,,' the I' ,,]J f '~I r , retu ,I -lL and ~ ores an implm 11 : ~ n ... definedp . itiV1 value in errne~

22.7

e s t.dd.e h'::,

fwid',

G'le',t an,d Slet Strs,s'ml IOr1en,tation (C9:9) int fTil'idle {RILE scr.e'am" .int: m,odeJl;

D -Iennill ., he I urren rient ti Ii ~ all , atn :IDp' to .. 1. i'

;; ~ If · * ih •• at ,L,., Old

onenranon, __ mode' I,. -I." Y' Ulm1~e -. " fw'~de . nee ro m-~· e tne tr'" m '1i--

oriented if it bas, DO DO ntation, If mode is le " ~". than zero, it trie 'to rns .: e th

stream byle-· riented if 1'[ ha no orientation .. 1'" mode is zero, the orientation :i . not changed.

,Fie;turns A positive value if file stream bas wide' orientation after the call a negative value if

it hils, 'byte orientation, or zero if' U has DO orientation. 25, .. 5

£wpr'i,n ,t ,f Wide~Cha,a',ctet Form'a,tJ;ed Flle' 'Write (IC99)

int r'WJ)rintf (FILE lit r'es'tr'ic-t st.t'eam,1

conss wc.har t '* restri~'t: fG'rrnatJ,

Wide-cbaracle'fv,efSioI1 of fp,ril'lt£"

<wc:har' '" hs

2,',1: .:;

_~!!tW

<.std.io .. h.:;>,

Biz'~ t f·wri·te: (const; voi,d. "I/: xeet xi ct: pt.r , aLze t si,ze I SiZ8' t nmemb , FILE '* restrict stre,am);

Wri'les nmemb elements, each B1.ze bytes long, from the' array pointed to byptr (0 tile' stream pointed to by a t: ~Cleam.

,R:e:turn's Number of elements actually Wtlfittell. This number will be les than nmemh if a

write error occurs. In 'CI9'9., returns. zero if either nmemb or size is zero, 22.,6

f-"jj'l's-'c~'n- f-

'0'1,1_', i .:_-'-J r.:- ~ - --

"d' - C'h - t - -~. .- tf;-"-' d' ~'I- R d' (Cy·· 9-~

, . I· .. ··1· , .. ,.,- . : .. --: .. I' .'.. .. . ~ ,-"." .. .-

t .e ·· .. llaralc,er or:ma ,e·· 'I,B, ,ea;··. . ' ..

i..ll't twsceni: (F.ILE ':t restrict st.r',eam!~

conar Ncl1,ar t '" rest.r'i,c,t format ~ .. , ,. ), i

Wide-'cbur',IC[ef' version of fSCClllf. 2.5.!5<

R~aa- d··· C·~·b ~if"!3I"ii"'c'r trom ·1 -C:';Je

_ gil I'_ .' -}If,'~lr,~'g-'-'II~, I~'_" UI I Ir"~'lf' .,'J

-eat.dd,o .. h:>

int glet,c' (FILE *stream) ,;

Reads at character from the stream pointed to by stream. Note: getc 1'<-, norms Uy implemented ,;/ .. , a,11111Cro:, i~" may evaluate ,sltrearn more han once.

R'e',turn's Character read from the stream, If gate' encounters the lend of the stream lt: ets the stream's end-of-file indicator and returm EO F., _ a read error occurs. g'etc sets rhe stream's error indicator and rerum BOP. 22.4

g19: t,ch,ar' R:eEJ'd Ghara,c,ter int g,etchar (v.oid) ;'

Reads at character from the at.d.i.n stream, Note: getcha.r i-, normally imple-

mented a a macro.

Re,turns Character read from the stream. If get char encounters [he lend of the stre m, i:L sets the stream' end-of-file indicator a-nd re UVD, EOF. If D read error occurs, get char' set the stTe8i11'~S error indicator and returns R'OF'. 7 .. ,3" 221.,4

91e ten'v GIS" Envlro'n,m,snt Str:in'g char .'get,env (co,net .chax *name);

Searche Ithe operating s_y rem 's environment list to lee if ,allY string matches the lone pointed to by riame.

cstdlib;,.11>

Ap~'·n-,n, Id·"i·V D

_ . ~e_ _ "".

Sta.nda~rd Library Fu'nctio:n's'

............ ............... hing n __ n:_~,. Renmu , null noin er if 2,6.2

Rfjlturns A. n

,e;,stdio II h:>

char get,s (char * S)I ,

. , ,m th '. s . din ~-" ._ I" n, tire 'I - m in hie, m i iointe

Iy s. Reading '.' . p at tt . IJ~' It ne -line I. hart .. _" r (which i dis card _ d)r at emlof-file, gst:s app. 'OUS a, null character to th 'ling",

Rle'turns' au rhe array on whk, b th in mt i" '., red). _'., urns a null p ,~. [I, if . -

n ad . - -or C" • - i or Ige S,c ncounter he en I. _ the sire ~__ 1"1_" it b 1-, 'I'ed ~:'-

rbaracu rs, 13'.,3 22~S

,ge t'wc ,R,ead Wide' Charac:ter from File (C99) wj_nt_.t gewc (FILE +st: eeunl ,

. id -ehars cter . ersion ' .. 1 get,c.

255

gs t- -c,har Read Widel IC:ha'rslcter fC9:9~ wint_t g[e',twchar tvoi d) ; ide-char cte r ersi n _ getchar ..

<wcha-r .. h>

26.,5

CO'nl~tL'!in' 'C" 'a"e' ·n..-Ja·,' Ttme ·0' BJro'knn- DO·M.tn- U' 7iC':-:- 'Tim.II!CI

I _I'., '.,r~· _ I I., .... - If I ----;_ u:,"_ - II~" I .,1 II, ," _:_,' 1~1 ~'~I '_ :' rlVI ' .-__ . -'. "If II. I' ti

<time , .. h>,

s,tru'ct. tm *gmtime (c,olnst time_t *tim.~r);'

Re,t.urns . inter to ~ true ture c' ntai ning . bra - -'n . n ' 1 '. time qu.i~, alent t . h ' ...

In.', tim- p inte n I b·, t.Lme r. RJ. lUI " nul] P' Inter if be calen ,- r time c n t

b . c n erred t UT-' I.. 2[8,,3'

,hwotf .hyp[ot,l

Beiums

-- t.h h ema '1.,,1' ,>

double bypot (doubl.e XI .doubl e rt : flo'at nypoct (flo,a-_ X'" f~oa''t y);

long d,Q·ubJ.,e hyp[o,tl (long do'ubl,£:! :XI 10n.9" ,do.Hb.lls ¥);

Jx· + y I (til . hyper nuse ' ri ht It~'· n· ie i [' le ?I x and y)~ 'ran, ~1T'·r mai

23,.4

~ 10gb U'nbis'sed Expon'sn,' (C99) i,nr ilogb (d'ouble x); int ilogbf(£~oat xJ;

int: i.Loqb): ("I,ang dauiil.e .x) ;

:l.logbf' ,ilogbl

Return's'

Exp nent I .- x as a aigued integ r: equivalent [- callirn rhe .ITI:'IP nding 10gb

function and 1 ,ring the retur .d value to type Lnt., R tumsF:P _ILQGBO if x i z r .. , INT ]MAX if x i iafinit I d FP ILOGBNAJN 1 ·x is a .... aN~ - ,d main en' .

··[f ra[l:~·- error ~- , . ur in f- ". . ~, 23.4

'!Ii..!< .

i,maxab,s Gfrea'test-- Wldfhl In'tegerf Abso,lute 'Value (IC99) in't:ma.x t 1max,abs (i.nt,max t j);I"'

Ap~lencJix D Standard Libraty Fu,nc,t;Q,ns 767

,Returns .bsolut - alue . - j ~ The behavior i un~d in d·' th ' ' - - olute val U~I( j, ran 'r be

epr'e' . 0 red. 21.2

Ii ' 1 _- ,I,

~maz, ,1. V Greatest-Wldthl Int~g'er Div;sio,n ,eg9)

<inttypes "h>

imaxdiv t lma'xdiv(intmax t J],umeI, i,ntmax t: d,eno,m} ;"

~ -

Rle,turns·ttucture f _ p, Lmaxd.i, v ~ t I - ·.nt· tinin ,me"mb~. nam d quat (the qu 'til u't

. hen numez L di ,j __ ed b~ denom .1 rem' the renu !"'I_ til The h, havior i 1

undefin d if either part 10 'the n suit an't be repr sented, 27.2

i, s a IDUBl Test fOf Alp,hanum'lelric int is,alnum" i . t 0)1;

Returns' A nonzero value if c i alphanumeric and zer I therwis e',~ (c is ,alpb' num eri _. if

either is"alpha (,e)' or isdisri't (c) is true.I 23.5

<ctype"h~

Telst' for Alph'al:)efic' lnt isalpha(int c);

A I10IIZ _ m valu 'c if c i, alphabeti . and zero othe -, i e, In the II~ C! II~ Iocale, c i-

alphalx tic if either is-lower (c l Lsuppez (0) :'If true, 231.5

Ta'B,t' for Blank (C99)

in,c i,sbJ.a,nk (~-t c) l

Rif!J,:turns __ nom ro value if c i a blank ch tr cter that i I Ll ed t, f'. paraie -, ord wi thi n r

line .' f [I . ''" '1 tie ml C U tocale 'I' th blank characters I '" ~, '. ·e . , nd b' 11 . 'n al

I' b ( II \ 1t ,II ).. 23.5

1 '_ len trl Test for ,Colnttioll Character

Returns

<ctype .. .h s

Lnt; Lscnt rl t rnt c) I

. no - er· " alue it" c i . a IC orrol _ haracter and ..... r '011 ,

.

t' -. - , I . •

i' di,g i t: Test for D,~git

int is,digi t (in,t c);'

isfini te Ts'st tt"( FinltJ!J1 N,umbe" (e9S)'

i-Dt i.et isxi.t:e (n al-flo'QlcinB x);

R,9'tur.ns A n. mzern value i' x is finit (zero, abnormal, r normal, bu. no infinit or and 7J:fO others j '. ~

Returns

._,t if ·

" nonze,fO't.Uue I, Ie '.

, "

23.S

ma« 1"0'

Test fair G'fsp:hicIJ'/,Char:acter int isgraph(int c);

A ilion, ',(,'I valu .!,~ c Is a, -, rinting chara

.'

,I, ..

23.,5

Test for IGreater Th'sn (C99)

int i eqxeeces: (real-floasing X, ,Ii 'rl~floa,l,il'tg'y)' ;

macra

Re'tu~ns ( x.}> I' y) . U nl ike tJ~M~~ :> operator, it,~ 9're,a t ,E!·r doesn't ~aise the immlid Jlo(atmg'-

poi 11' exception if one or both of the arguments ism. N,mN'.. ,23~4

Test fo'r Gre',ate'r 'Than or ,Equa,' {C9i9)

l,nt ,1 s.gr,eat,e're·qua,l (real:florrtl'ng ,XI real-{lo,at,ing yJ ;

<math.,h:>,

Returns (x) >=- (y). Unlike the >= operaier, isgreater'equal doesn t raise the

itwolid floati ug-poim exceprlon lf OL"LC or both of the arguments is, a NaN. 231.'4

,i sin,f Test ,tolr Infinity (e99)

int isin:E (re"lll1(J(J'il;~g x.t ,

- ..... ~ h c:maW!., , ~

in tis 1 ,E!'ss (~li!"j,l:flo{Jting X,I r'eal~flo:aJingy); maero

Returns' (x) <: I(Y) ~ 'Unlike the ,< operator, i,sle.B-s doesn't raise the i:',~valid.' floating-

point exception if one or both ofthe arguments, is a NaLN. ,213.,4

.: e ···l e" '8--"S" e.>" qu·····~l

!iiiiiIii '_ ) -j •. _- .. .: ',l_ ) I. I. I' IIIiIII!

i,n,t islessequal (rea! ... jloatirl,f/,KJ, IT!al~.floluting y);' ""'OW

,R'Q:,tums' (X)I <= {y). Unlike the <= operator, isle.s-siequ,al doe n't raise the invelid

floaUng ... point exception If one or both of Ute arguments i a Ni~'. 23.,4

Irit: 1 13'l·ess'grea 'ter (,I!~f!Ql=-j1CJ\Qliltg x I .rea/~flof4tiug y},., macro

R'e'turns ex') ,e: I(Y',) I I (,X)I,~ (y}. U"nlike thi ,e'x,p1ieinisl,sssg'r'eat,er doesn't

raise the inyutld' floating .... powl exception if Ollie or both of the arguments lIS a NaN:;, also .. x and Y are evaluated only once, 2~'.4

<ctype i. h:>

R'QfurnS

,I

.' EI'.' , Il"':Ii'!l:Ii Pllil

!16 ., ~'.1.151!".1

'Test tOI., NaN ,fC99)

in t i sn,an ('J1elf/-{l.oOM\n& x);

A nonzero val ue if' x lsi a N,itN value and zero otherwise.

II L

,~Sllorma, ._

Test ,fa.r ,Norm'al Number (C9,9) i.nt: is'na.rmal (re!a,l~flo'Q.ting x) ~-'

macro

R1e',turns A nonzero value 'tif x ha~, ,I 110rtTlJa1 value (l10t zero, subnormal infinite, or N,BN)

and zero otherwise. 2,3.4

II .!Ii t-'

1S'pr'1'D,i. -!

Test'or Printing ChS,rBcte.r int isprint(int c';

<ctype .,h>

235

[<!:ctype .. h:>

Return[s

I

- u net uanon,

. ,~ , hie __ isslpalce ' r isa.lnum I " tru ' '~,

_ E ,I:__ ,-.I1~'-

,_ ". ept tho' ,"

til' . 23~5

iii

_ ~ S ~ Ipac _ Test for Whi,te-,Sp'B[ce ,C,'h,B"ri'cte.r

lnt 1Bspace(it cJ;

Rs' turn s n I I -~'F' alu if c i _ hi ~I

hit . cb '

, '\n I ii carriase return I( r \ _ r )1

11m the fll elill

-

,(II II,.. , m

b ( I \ t II I~ an

I ~ \v ~ "

23. '

Tes[t for IUn,orde,red (C99)

emat.h .. h>

int isu,Dordexled (real-fioal" X,,

R,etlurntj ] if x an I y I_ -e un ,_ - ' , II

23.4

il'lup'p r[ Test tor ll,pper-,Calse Letter :tnt 1suppisr (int c),

,Returns __ nc , I ru vulu if c .,

cctl_lPe ,~h:>

no zerc

'.'

23.5

,_I 1 ~sl,'a num

[1'est tor AJphanum'sric Wide Cha.racter (egg)1 iDE iswaln,um f'w Int=t we) I'

R'e'turns _ nonz [0 v,~ lue it" we i" al 1,' numeric and " [0 .~i er is alpha ( c) _ r Isw,dlgit I( , c) is rue.

we i 81- hanumeric i • 2S~16

1, s'wal[p[ha[ 77sIst for Alpha,b,stic " e Characfer ~C'991

~ t swalpha {wJ.nt=t we);

R' t aJ if t .b, ~ .",,~ th ~ ..

[,9'u'rn'S n· nzer I v JUc- I we '[ upna ~~' tc ana 2;_, "t 1-1.'[. we ~

1swupplsrl(wcl) r is,w.lower(w,c) istrue. I .. , 'ei" 0 r· \1,,31 '-I ,'_JI_

set of lehsbetic wi, I' char '.[1 - ~'r \ hich n 11) isw'cntrl, is, diglt

iswp[unct ' _ i,sw" 'acle 25.6

<:wctype h»

i, S'[ ',,1,1 a,nk Te,s,1 fair B,/a'n'[k 'Wide IChs,r:alctef' (C9,9)' Lnt: iswb.Jank (wint I we)! ,.

Returns

"- r th 2516

,i ,Blwen, t,r 1 Test for Can'trol Wide C,n'ara~ctar (Gge) int iswc,l],trl (wint t we),~

-

Rs"turns

25.6

Lsxt: i.B'wc-t'yp'e {wint._t wC~'J wc'typle_t deeol s

R'fJlturns ~'nonlJ 1"0 ' alue if the wide character w'c ha: thccr P , I, de, cribed b dese ..

deac must ,alr remrne by I all of w,ctyp,e! tbe current s .ting of 'h

L,IC' CTYPE, an gory must e the, aID! ' uring both '11 'I Return Z'fO nherwise.

'!!!!!!!!!I!

25~6

TB'st for Digit Wide Chara'cter {e99) i,t iswdigit(wint_t we};

Returns ' _ n nzem al ue if 'd'e leo spends to _ de -inlal di, ~ il ' '

o::w'ctype ,,,h:>

25.6

R,'eturns'

Test fair ,G'raph'ical Wide C,hl8IBlcter (C99) int iswgrapb rwint~ we);

, nonzero value if is'ip,rint ('we) i Returns zer I therwis e.

I and i,swspace (we) is :[-1'1",. 25.6

<'we ype. h,>

Test for ,L,o'wer~Case W~de Chara;ctsir fC99)1 2n't iswlow"er(wint_t we};'

R,eturns _ n mzero vahn if WC~ orresponds to lower-c.' letter or is on iOI ,3Ic,-}"-'-

specific set oit wide characters for whieh none of i sw'en'tr 1, i 8'w'di 9 it,~,

,", ,I '~R tI

l..swp'unct,_ or ~,swspace [ true. _" turn tel '0 ], -25.16

,is __ ' . - xis: t Test lo,r,Printing Wide ChalrHcte" (C99) i.nt: i swpsin): lwint_t wc) l

Returns

~C.6, i£"ilti _-'

Test lor Punctuation Wide ChlBtBcter (IC99} ~ll'E iswpunct (wint~c we) i

R,e-turns A nonzero value if we' i_.- iJ priming wil- cb,· f,I!CI,]' that i" one of a locale-specific - t o UJ]I: to, t]1 11 wi e " han cters Ior which neithe r iswspace' II r Lswa.Lnum

i, true, Return zen th rw~< _., 25~6

,. t

~ S"'Punc '_c

<'wctype .. 1 ;>

is' '-spa C'S Test .tor Whlte~Space Widel Ch,ara,ctelr (;C99) int i ewepaoe (w'int_t '~7'C)1 ,"

Returns A nonzr r valu U we is ne 0' 3- local -' _ "_ lie' " t of bite-space wi !,_ -b, I. acten for _- hie' n,D' I i 6wa, nUln is'wg aph, or iB~un,ct is true .'1 'l1 - I zr I ,tb ·rwi e. 25.S

<w'ctype 0; h>1

isu: iswupper (-) i:fJI,c t wc~;

, .........

Rs'turns " n-: .' ," Ii' '. alne ~ we correspond .. , tc an up l'l_r- ~ _SC 1 tter I, r I - I' all a} 1-

specifi 'se~ -' wid ehara ters f r which nOD" Q_ isw,cn'trl" i,s:wdigit, iswpunct,r is'wsplace is true, Re urn zer I herv i . 25,,8

I'es',t 'Of Hsxsdslcima,/-Dliglt Wide Chata~clter {e99)' int iswxdligit (wint_, we) i

A .DO'DZI-[O value If we correspond 'to a b xad Imal zer th

<::wctype"h>

igit . 0-9 a-f'~ A~F) and

~'.l: ttl, ~I .. D'

Tes" fOt Hsxa'ciecfmal D'/gil Lnt; is,xdigit (int c) r

,Rle£utn's nonzero alue t c· a he: a_.~c'im,al igit,O-91 a-f,A~F'. and: . tile wi e.

23~5

Laba L,ong Infs,ger Absolute IValue <s,tdlJ..b _ 'h:>

lo'ng int labs (long int j);

- b· In _ valu If j ~ The ,-I h_ vi It i und fin d · ~ the represented,

-I]ut_ 'v'alu,e I. j can', b, 2'6.2'

l,de~p'r l,de~l

RlfJtu'ms

Combine Fr,action ena Exp'D'nlent

doub.Le ldexp (doub'l.e X,I int exp) ~ til oet: la,expf (flo'at x isu: 'exp); Lonq double, Ldexpl. (leng double X,

x x, -... exp,. A f, nge '[£0 m _ t. , c' _ U[",

<math,.,h>

int exp);

,23.3'

ldiv

Idiv_t - div(long ~nt riumez , Lonq int danom) If

Returns An' ldi:v_t . tnt ture (Jontaini'n,g memb r named quat I, the quotient when nume r is divid db, denomj undrem the remaiuderj.Tf behi ior isunde ned if' - .ith 'f P~[ . _ f "he result can t b. repres nt· d, ,2'6.21

,lgamma Lagarj,th1m of Gamma Fu'n'ction (C99) ,doub'le' .1gam:m,a, (do'uble x);,' rIoa,t 19amm,a:r (float xJ';

long dlo,uble 19am'mal (l,ong d,o'uble x);

19aJllDa,~ ,lga:m.mal

Returns

-emat.h, h>

In ,I: xii ," b. ere T ~. hie U' rnm fun c. , In. '. ran _ error I.e urs if x i' I' nd nlily OCICU'f jf x is a neg rive integer or zen I,.

23"4

': I"

.. "

1 labs LJJ,ng Long' II'nlteg'sr Ab,sol'ute 'Va11lue (CfJ11)

long l,ong int ,11abs (long l,ong int j),;

<stdlib .. h>

RtfJturns-,' bsolute i alu 0 i jj. T~1e -_ J avi r i. undefined if h, absolute ' alue oi j can L b

r,cpr,e - ented, 26.2'

1,1 di v t..long'Long ,/n,tege',r Division {C'99) ll,d,.iv~t lldiv(1ong .lang int Dum'er,

long long int d'e:llomJ;

Returns An 11,di'V:_t structure containing m· mb rs fl- med quot (the quotient wh n numez i '- divided by denom '1_ rem tr remainder '1. The beha iOT i. undefined iJ either pan: of dele Ie - tc "l be repr ~:- nted, 2:62

11, r'i,Zl t Rou'nd to Long Long Jnt8'ger ,Us'ing Curre,n'f Direction (C9:9~1 1on:g long int 11rint (doublJe x} ,i

long long int llrint,f (f1,o'a-t x);

long long .i.nt l1r::tntl (long ,d,;rubl,e x);

12r·t,Dtf 11 r',i,ll tl

Rs'hJrns

----._ -

x r nm e m th,. n ares lnte ·r U sina Ihe cum n~ roundins direction. the

lOUD led value i· au ide tb - ran'_ ~ of the lang long .int te~ the resul i

unsp ·ifie. ~. nd.a domain or rang error ma.· oceuz 23'.4

llround RtJlund to ,Neare'st Long Lon:g In,te;gs',r (C99:)' lCU1g long inc llrotmd (double XJI,

llr,o'uDdf Lanq long' int l1r,oundf (float x)i ,lL

l.lr-o,'ulJ.ldl long long inc l.~rCHjn,d1 (long do'uble x) l

,Returns x founded 't1_1 the nearest mteger, : ith haJfwaY-f:'·' r unded a I __ Y fr m zer i' If the r unded "all e is 10 !.t· id, the 1", nae of th . long 10,ng Lnt type th re ,u1L i

. P ,i' e" ,n" ad,· main or Jiang· e. -~.' r t ~ /;' ur, 23' .. 4

<:math .. h~

<tim.e-., h>

<locale.h>

struct Lconv *loc,ale'c,o,nv (vo i d) ;

Re:furns A pint -r II I"J structure containing inform til n I tb ut h - urren - ~, : sale. 25" 1

at.ruct; tm Loca Lt.Lme l(cc:l1nst t~'me _ *ti'm,sr);

......

Returns A pointer to a tructure eontainine broke n ... dow I lo al time equivalent m 1 the cal.. ndar time pointed to ib~ - inter., Returns ' null pointer j ILb· cale I:: time an

be eORVerb!d. to local t ~ me. 26'.8

l'og Natutal ,L,o,garlthm

doubl.e 110g (deub.l,e x) ; float lQg£ (fJ.o'at x) /

long double lOlgl (long do.u_ble x) i

10gi 10g1

Re,t,urns Logarithm .. f X _' th ba '. e. ,A domain ern r I I ur if x 1- nep,. tive, . r o' ge

may occur -j f' x i s zero. 23.3

1 o'g 101 Common LtJlga',rithm doub Le 10g10 (d.ouhle x) 1

flo'at: logl Of (flo,s,t ,x), i

lang double' loglfJl (long ,doubile x);

Logarithm of x [0 the base 10" ,A domain error occurs if x iSJ negativev A range error ma,y oCCUJ' if x is zero. 2S., a'

logl.IOf 1IoglIO'1.

R.a:"'u' m "~

J 16'111 - I ~

<math .. h:>

1, ,og'l£1' Na,tural Lag,B.ri:th',m o,f' l' ,PluBA.rg'u,m,ent fC'99~1 douplle 1 Qg'lp (d'cH .. lble x:)i /

float log1pf (flo,at x) i

lo.,n:g doUb,.1e log1pJ (Is'ng. doubl,e' x);

l.oglp"f log'l,pJ.

Reitu,ns Logarithm of 1+ x. tOI the ba e e. A domain error occurs if x is less than -I. A,

range error ltlay 'Occur if x is. equal [0 ~ L 231.4

1 o',g:2' ,B,aSie~2 LtJgari'thm' (C9'9j ,doubll,elog2' (do,ub,l,e X),' fl,oat lO'g2E(£loat. xl,

llong doubl e 1 og2 1 '( long dal'abllie x) Ii

,10',9:2£ log2,.l

Logarithm 'of x to the bas. 2, .. A, domain error' OCCltrS if x i", negative, mLa;y occur if xi, zero ,_

. rnn,ge ,erIO:I~ 2l~,4

,emath"b>

doubl.le 10gb (sDubl,E! x) l ,111Ogbt fl,oat lOlgbf (fl'loat x) l

,l,ogbl la,fl,g doub1.e lc)gbl (liang doub.l e x] l'

,R,9,turns ~og,nxl) .. where r is the r!1ldi x of floating-point arithmetic (defined by the macro FL·T RADIX, which '£ypically ha [he value 2,1. A domaln error or range error tllBy

.,......" _.

occur if x is zero, 23.4

1 liil ong: ·-Jmp-:·· ..

I .., I

Non'l(jcal Ju,mp' void longjmp(jmp~buf env, int val);

Restore the environment stored in env and returns from [be caJI of set,j'mp that originally aved env, If va~ is nonzero, it will be' setj mp 5 return value:' ifva.L is 10, set j mp re turn s I. ,2~~4'

,<:setj mp ,. h->

<math '.' h,,..

1,rj,D,'tf' lrintl

Rls,tum!s'

,RIOUtl'd to' L.ong In'te,ger Us.tn,g Curren:t Dfrsiction' l(e9g) l(':llJg i..nt lrint (d'ouble x) l

long int lrintE (float x) l

l,ong int lrin.tl (longdcub-le x ) I

x rounded to lEhc nearest integer u~ ing the current rounding direction, Tf [the rounded value is ou ts ide the range of the Lonq in t type", the result is. unspecified and a domain or range error may occur. 2S)0

A- d" D

. . I'.· ~ j . I'" I - ~ .

I,ppen JX I -

- c th-'- h <IDa ' '0 __ :>

1 r--'.i!!"'Il !I '11 l1"li1 d- f

___ _:__::,ly',UA""'_ ,

1 ong

long 1,ong

illit ],x,ound (d',olub1,e .x) l i11t lc',ound.f (float xJI,'"'

int lxoundl t long doubl,e xt ,

Rle;tu:rns x rounded to the nearest integer with halfway ILi as es rounded uwa.y from zer-o. lf the roun - ed value i outsie e the range of the long int - , pe., til - result is unspecified and a domain or range error may occur, 23'.4'

m,8,lllclc AlloC8';te Mem'ory Block void *rnalloe(size t ~ize);

Allocates a block of memory , itb size bytes, The bleek is not cleared,

R'et,tlrns A pointef' .,. the beginning 0"" the block. Returns a null poierer if I. block of the

re'Q1LIe - ted ,ize c n t be 3J oeared, "7.2'

mb 1 en L,sngth ot ,Mutribyts' Chara,cter int. mhl,e'n I( const char; '* S " si ze t n) i

R'etufns If B '~I a null pointer- return' a nonzero, or zero value, depending OD whether or nOl multibyte charaeters have, state ... dependent encodings, If s points to a nuU character, , returns zero. Otherwise, returns the number of b,yl,es in, the multibyte character pointed to by :s .', returns -] if the next n 'or fewer bpe.s don ii t form a valid mnltibyte character, 26.2'

<stdlib '. h>

-<we,har,~ h»

Si2H3 t mbrlen (cetnst: cb,ar * restrict' s~, s'iz'@' t: 1,1" mbstat:,e t *" r,es-tric't ps),;<

---

Determines the number olr byte in the array pointed to by s that ace reqtsired 'to

complete ,8 multibyte character, ps should point £0 an object ootype mb9,tate,~t that contains the current conversion state. A call of mbrLen is equivalent to'

mbrtow'c (NUL'L,~ S:, n, PS,)'

le- cept that ifp,s is a J1UU pointer th ' address of an imernal object is used instead.

Returns See mbrtolWc. ,25.6

.11110 r tlCWC C:an've.,t Mu,'tlbytel C:har:actef' tOI (C'9Igj

si,zet nlbr,tow'c·' (wcllar t; * restrict P'~C,

const chaJ;" '* r,estrict 8, sizle it .n , mblst:ate~t it restr.ilcf ps),..

[f 8, is a null pointer, 13 call of nlbrtowc i· equivalent to

App,endlx D S'fandard'Library FUrI,ctio,ns ns

thes om ·Ie e . valid mu1 [bl'"' I~' arac -

_ _ ,- .A! ~ -

ve led. into a wid ch 1- act' -. ' pw'c i' In' t a nun. ;, in Ler, the wide char :t. r i " stored

in th _:' objectpoinu d to bi: pwc,. The value I(] p's should - I . pointier t :,1 an a d ect .0

ryp' mbat.a t.e _ t tbat c . ntains the CUJTien' le'n', rsion . t . . pEt i, ,ft Dull ~ ointe r. mbrtlo,wc us· - tnt, mal, ,bj[.:~t tostore the conver ,11 n tbe _,I, sult . f the conversion ~, me nul] wide ha cter, the mbstate t object u ' d durin'; the call

._...

• '. I~.... .' • I I . ,

s te t Ul we initu ml conversu n ,,' tate,

',~'n-

Returns 0 If the conversion produce a. DUn wi e character, Return ' numb, -- btw en 1 :1 d n if th ICD _,r: ion pr 'dUr~ ~' ,," "ide character I Other [than null, 'I' - turned is th " nUID' e '0' bvt 10, ~~" mple , the mul ~ - ,t chars ,( s i_z B_t) ( 2]1 :if the n by e ,', p Inted -0 by s weren 't en ugh to I mplet _' a muJ.ti,byt,e character; Returns (si,ze_t) I( -·1) and store ,E:-LS,E'Q in errno if an ~ DC' dln·~ error C If', ~ 25.5

II' , t

I~,n, ~ I-_'_,

Test for Ini,tlaIICon'V9rsio'n S,tate (C99)

int rnb'sin,jJ t (canst mbstat,B_t *ps,); A nonzero value i_' p5 is . nun p inter ' it ioinr

d -'-be . ~-ft-. l converslon staierotherwi

, n.,;:, - an In l'lll I I ':ovler' OJ) I·' ; I ' r" -_ C, '

(1 I D. rnlls tla.te~t obje t [bal

ro 25.5

JlI'bsr'_' ,owes conven Mulf/byte String' to liVtde Str:ing ~ Resta,rtable r{,C99) ewe _ ar .. h> ,6'1. ze t rnbsr:tow;cls (wcha e- t * r,e'str'l ct aSI t ~

-

C1ons';t char ** rlf!S r.ict: arc,

size t len,. ,mbstate It '* restr~ct pe l ,

ICon ' ~I S i:L,equn -" 0 I mul ib . t_ ' ha ractcr "I m th ' au . im, I~,,' - '(J,- - p- inte : ~o b- arc into a sequence of CO[]i tp mding wid character ',. p:s <,] ould - oint to an object of typ'e mblstatlLe_t th t I, O:D'·· I' til urrent con rsi u state. 11- the argu-

m 0'1 ' Olre pi '10 in,:" to ps '. J1\ II _ I' in' f, mbs rt O'Ules u _ ~ n int ._1' _' ~~I_'ct I

'-1 'e th Ie" n, er ion tate" I dat; in . nun I; inter the 1,11 ce -I ed 'hr . tored in tb arra that it ioim L." '0 er · n continue' u ' _ - and ineludin ,. terminating null character which :,' also tored, Con _ rslen 'tap -. earli r if a r ,qu '_ Dr _- e of b,yte' i encoun red tha d. 11- t orm alid mw tib _ t cb " __ a ter I'(-· L dat, in' a nun I . (i-, t ..- - n len ~ i ,~ -h·_- ,-8,1 -, ers ha ~e been '" ~e~- in

the array, I d.s~. I: n' .' nuU poinn - - 'bj~ l pointed ~ I by src is a igned

eith r _ null pointe (if termins 'ing null h racter "I -r ached) \[ 'ttl ndre I'

jus _- past the 18, m ltibyl ~ cbar eter eonv ert d I if any), . the conversion ends I n ,3 nuU charae I r ar - if dat; . ·n'· L a null p 'inter the r" sul in ,r'a ,1_ is the init ~a1IC 0"" 'Y rsk n ' tate,

R,eturns Number of multi -,' eharacters sue es IUJl _ 01- '-, [~I~ - n L includin any errni-

natins non characrer; Returns 'size -t) (-1) and "tore EILSEQ in errno if a:n invalid mul iby,~ haracteri encoun CTe· • ,25.5

s i ze t lit1b,srtoweiS (wch,ar t * reetzxi at: PIWICS,

canst chaz ..... rest,ri,ct ,S, size t n);

- n- I rt be ' quence c f multib I_I . I r pointed t ,"-. Bin,' 'e u nee

-- ide charact ra stcring utmost.n wide charact r· in thearrav p inted to b' pW'CB.

, onversion ' ':lld· if a null haracter Is enceuntered; it i on erred inte null wid, . '. han C'ICI ..

Re,turn,s _ umbe I f ,ar-r,D elements - - n tin Iudin the null wide Ib I "I --,t ~. D'

,

R turns I(s~z'e~t:) (~l}i-f,anin alid m Itib I 'lob I ',' er is 25.2

<stdlib '" h,>

int rribt owe (wchar_t * xee t ri C! t pwc ,

conat; char .. I,e'st ti.ct: S t si.ae t n) J

s isn 't ~ null poinn r ' !' DluJ,r-_

chara -rer,;, a,'t most n ,'yte·" 'wi]] be exami . ed,

p'wc isn' t a null pointer stor I.' th h wide 'charac~ If in the obj . - t noint ~ d

o by pwc.

Returns If B'~ a nul] pointer fie llIrtl - 11f -,Ier, I , -r . multibyte chara ters have sta e-dependen J n ..... '.·._ ......... ter, returnszero, Otherwi . ~ returns the number f by't - in the rnultibyte character - rinted to b: as ~ re urns ~] · f th 10 ext nut er by1J~ , ,d n f ' arm a V,~ _Id multilr e

11- .e::~ 2c.n

_1 __ ' __ ~'Il i.I.I':';-

<S~ ri.ng" h>

vClid *m'emc'hr (eonat; vo id *51, int C I size t n l i'

R,s,tumIB p ,in' r t the fir', t cecum n of tit - chi" er C ame 'Q - the '..i n harac er I 0

the " j ,C_ I inL be, a.Returns I DU 'int - rife i D 't iti~ und, 23.6

'"

int memcmp (colnstv,oi,d *s~',r conat; vod.d *812;1 91,ize t n) ,;

Returns 01_, ' 1i' e -- ,10 r positr integer; dep n in, on" - hi .. tll r h - fi . n .~. b ~,. cters .. f

lh '~Ie ' point ··~O b:' sl are 1~'" I than "'- I It· or ,'_r I '-='1 than lh __ 1r L n charact , I 01_ the I 'bje _ l pointed (] b 92. 2:3'.16

void =memcpy Ivod.d -.' xeet.x Lct: ,61,

oorrat; void * restrict 82:, size~t n) ;

Copie ~ n charac ters from th object pointe d to, by s 2 into the o1Qj _ ~t P , 'in ted Ito by IS '. Th bella 1 : i I undefine I, the object , I. verlap,

Re,fulrns :91· oint, r t the d nin ['. In) 236

meUUfllQVe Copy Memory S'/o.ak

<string;;h>

.bJ.,ct - bjeet 0' I. rb ,po

Return.s s 1 (j, pointe t - th. de' - tinatie In .

m e'D-IS~ e-" t

I I - - - I -

I - _, _ -, _, __:_ I __:_ - ~

Initia'Uze Me',mor)1' Block

v(J,i.d'·memeet (voi.d *s, tnt c, sizle t n) II'

,.........,

Stores C! in each ,o,f'the first n characters of the 'o~jecl pointed to 'by s,~

Returns s (apointer to the obj ect) '" 23~ 6

mkt; ime ,Co,nVB'r' Blic'ken~Dawn Laca/'Tim,e' to Cs'/s'ndar Time <: t ,:i me ~ 11.,:>

time_t 'mk~ime (~truct. tm *tim,ep,tr)';

Conve S ill broken-down local lime r( - tored in he structure pointed tOI by t; i,mE! .... ptr) into a, calendar time, The members of the rrueture aren't required 0 be 'within their legal ranges; also, the values of tm_wdat,Y (da,y of the' week) and t,'m =-yday (d.aty of the year are ignored, 'mktime stores values in tm_, wday,and t~_yday after adjusting the other mernb ers to bring- them into their pToper ranges.

R\s,turns A calendar tim I!:' corr spending to the structure pointed to by t.Irneptr. Return:

I( t i.n~e_t,) (- 1) if the' calendar ' ime C,1n t be represente . 26.3

.- d _-

_ I I ., . ~ ~

m,o '.

mo· -d-f--:f-

.. J··"I' -

,.'",." I .,1

Splilt iotf) Ints1ger an'rJ ,Frs'ctio',n',al Ra'r;ts cmat.h ~ h>

,doubl1e! modf (double vaI ue , doub'l e * ip~tr) ;

:float modff(f'loat va Lue , fl-o'at *:iptr) ;~'

long' dO'ub.1e' ,moldfl (long Idouble value, Louq d'ouble *iptr);

Splits va 1 ue into Integer ,1311_- fraotional parts: , teres the integer part 'in, the' object pointed .0 by iptr"

zian Crea',te NaN' (C9,9)1 doub1le' nan (C':ODst !char *tagp);

D,.nf' float nanf (c,onst ,char *ta'gp) l

n,c1iDl '1 ong' ,daub,l ena'nl (cDns t: ,char * t,agp1' ;

Returns A "quiet" N~ whose binary P III ttern is determined by the string pointed 'to, b~

t.aqp, Returns zero if quiet N',aN·· aren't upported, 23.4

In,earb:yin t RfJU,nd tOI Integral Va/:ue Using C'urre,nt D'itis'ctio'n (eB'S} ,double nea,rbyint (dou'ble xt :

float 'nea,rby'.1ntf (float" xJl

long d€)~.ble I~>ear:byiDtl (long double x);

,J],tI\Sr:D,y". ',i,I]]' t'f'

, ,

,lJ Is,a rby'.1"n, t]:,

R,sfU,rns x rounded to an integer (in Ileating-poin; f rmat) using the current rounding direc-

tion. Doesn ,t raise the inexact floating-puinr 'exception. 2'3.4

D'Sx"t a ,f't'e,r Next Number Affa'r (C99) ~ma'th ~ h»

double 1118xt,arter (dcn<lb'~e sc, d,oub_le y);

ll,ex't,i!l,fte,r,f' float nexi.eticert: (fl1oat x , fl,oat rt r

D,ex"c,a,f'terl l,ong Idouble nextia.ft,E!'rl [Lonq ,douhle, XI' L,ong "do,uJj'le' Y);'

Re,turns ' ext repr n abl " value ,aD_ r x in 1[1, direction y. Returns the value ju t - fc r ~

x if y -c x 10!(' I:b ~- value just after x if x < y. Returns y if x equal- 1"., A range error rna 0 ~I nrr if the rna; niui 0" x i til hu'~ _ - r,_pr'~'. nta 1 finit _' - alue ~'" " ill

[I, mlt is infinit . r not reprei en .able, ,23.4

next towa,r'ld Next Nu'mbe,r Toward I~C99) <mach .. h>

doub_l,e' 11,~ttowa· d (double XI! long doub.Le yJ;

n~tt,owar,dl f,l,oa-t next ~,o'wardf (:fl,C),a't x, long Idouble y);

nexttowar,dl 10119 d,o,ubl,s' n!!xtt,owa.r,dl (liang dat.zble, XI long do'ub~,e yJ;

Rletums· ext rep - _I eatable valu tier x in the direction 'Of y t ee n,e,xtaft,er I. Return '

Y lCD' erted 0. th fUD tion s lyp -' if x equals y. 23.4·

ple,r ·-'or IPI,,;nt E"orMe'ssa'ge vo i.d perror (CC'Ds,'t chaz * e) ;

'lite Ie 1110,' ing mesa ee to the std'er'I stream:

~,/ri/~8 ,: error-messag«

'"lng i I - I trin'- p. tnt d t by s and ern .'r-,.~ €' 'a' e i" an im _ Ilti D,- , fine

me S-I .. ~ e that mar shes the one returned by th ~ call B trerr,o'r {errno) . 24.2

pow

Powe« <math ~ h>

GO'uhrl e pow I[ douh 1 ex, d·OiU.D 1 e Y-)I;"

float powf (' ~oa't XI :float y)~-

1 D'ng daubl e powl (long ,doub'le x, 1 Gng do,ubl,e Y)I l

powf powl

Rs,turns x raised to he power y.,' dm in or range en-or m. ',' cur in ertain

v _ el\;veen. -,9 and I I .,' •

. hich 23.3

d" h <st r.o i n»

int p,rintf (conat; chaz w _r'estrlct forma't,~ 1' ... );

rl _Ie ' utput [J,. the ,s t:d,Ollt ' rr _ am, Tbe stnng Pi, filed ti,' by f'ozms tsp cifie how subsequent 'arguments will be di spl .. yed,

Re.turns' " umber of character written;

<stdio ,. h»

in't put.c I Irrc ,a it FILIE 'stream);

Writes tb character (:' [0 tbe tream p' ~inted [ bystream~ N'I, ,: putc I, normall- lmplemented as a maer . H may_' aluat 'stream lor' 'lb' " nee,

Returns c (lbe ,,' haracter written). If a write error oc UliS put.c ",ct· the' tream's error indi-

ca.tJ~ and return, EOF" 22 ...

PIU t,e,.bar W~ite Cha'fs',cter int put~har{1nt c);

, . rite" 'b.· character c. [0 the std.,o·utLTeam Note. PIU tchar ,., n rmally imple-

mented a~ , a macro,

-

--m:··,·~ .

7.,3, 22'~4

PU,tl" - W~,~e ,String int put s (const; char' *9)1,;

Wrtt . the strl ',. , inted to b B.·' th h a ='1- r ..

nonnegative valu _ i rue' ssful, Returns EOF if a write err, r occurs c 1,3,,,3 ,22.5

pu t:~_ c Write Wide ChalB'cter to File (C9S) w'int_t putwc (wcb,ac~t c , FI,LE s'tr-.eam);

Wt· ,_ -chr tatcler V'- rsion of put;c. 2S~5

< char,.,h>

,put: rc 'I,·r 'Write IWide, Ch'alractef,(C99)

win,t~ t P!I' wc'n,ar (w'cllar ........ t al , lde-cheracter ver ,i: n. ofput.ehar.

,25.5'

q. ,o,rt, Sort Array

<stdl,ib!! h»

vo i d qsort (v,oid *basel size t nmemb , si-,e t s Lae ,

int I( =compar) (co,n,st vo.i.d *, canst void. ));

,lott.1 the' array p in ed to, by base. Th I,[[~ .. has nmenlb e emern ., e h size

b_ te I ng" compar i' at. p: interto a comp ri "'D fun tien ·0 P , .. ed p l1lnt'cr'·

to _ . I. ' " - -a: ' ,-I -m R' - -, th ]U ' er. '. I if

posiriv integer dependlng on .- h, qu

or reater than th iecond, 17.7, 26.2

I

r'a1,se! Raise Signal

int raise(int sig);

Raises the signal whose numbe i s ig*

<signal"h>

24.3

G- ~n_·e,,.~,'fa .os'- ,8u,.,.Jo-Ranl"""o' m A·"u'mbar

I I(;il. ·-,]'gllg Irr· g! UH, .. ~_ I.,. I U~ I r '''Vi, I ~!

<8Idlib~h>

int rand(voidJ;

R,e,turns A po; udo-ranc om int -ger be' .. '010 and R.AND MAX.

. tdl Lb - . .jLo., ~ ,

<,S . _ _ -=. .. J...JL;!i

void Arealloc(void *ptr, size t size);

p,tr i' assume d to point to a, - ,10 ,t ,0- emoe previously Or tained from cal,loC!~ ma'l Locv or z'ea Ll.oo. re,all,oc allor 3.1: a bl :-.'. 0 siz,e I yte" -, 'in - th '

, 1 ~ ~ '. of th ol

Re,tU'fnS A -p, in' er to the b -- inning IOf I nev memor block, ' emms a DUn P JO-· if a

bloc" of rule requested seize can t b _ allocat -d. 't'7.3

Ae,ma'~nd'er' ,(e99) <math ~ h»

d(11"l:o'l,8 rem,ainc.har',fd,ou'"ble x" do'ubl'i9 y);

f.1,oatremain,die,rc r.flo,alt x .float y).I

long doubl,e' remaj,n-d'erl (leng Q~oubl,e X,/ Lonq d.oubl,e Y) fl

R's'turn.s x - tl'ywncf,e n i' the int'eger' nearest the eX8C value of x/y,., (If xty is halfway between tW'Q1 integers, n L~, even.) If x -1'lY = O~ [be return value bas the same sign as x.. If Y i "" zero, either a domain error occurs or Zf!:[O is returned. 2:1.4

intr,emove~ (co'os,t char *fi.len,ams') i

Deletes the file. whose name is pointed 0 by 'file'nam1e.

Returns ZC[O if ~ ucces: ful IIQDZerO oth 'rw ise,

doub'l'e! rem'quQI (.d,ouble x , ',ciouble Y'~ in,:it "'qu'O)I,;' fl,oa.t ,r,e'm·quor (f,l,o,Clt XI fl~oatYl ,int '*quIOI),~

long d'oubl,e r,e'mqu~ol (lon'g double x , long ,d:oubls' y,

int '~QUo} l

Computes both rhe remainder and th ,_u1olienI .- hen x R,S, divided by. y~ The object pointed Ito by quo is modified so that it contains 11' low-order bits ofthe integer quotient Ilx/ y,1 where no i implementation ... defined but mu t be at least three, The value stored jn this, lobje,ct willi be negative if' x/Y' <: o.

R'eturns Same value ~ the corresponding r'e'm,ain,der function .. If y ~'S zero, either Iii domain error occurs or zero i'" ['etllmled.23~4

r;em'g1J,o,f r'SlD'qucl

re:n!aJTL'~~! Beneme File in't r,ename (conat; char "',o,l,d", conat c,ha,r =new) ;

'Change the name of a file," Old and n,e,w point [,0 ! tri-nB> c:oIDlaini-ng the ' ,]d name and new name, ]-e' pectively,

Return's Zero L' the renaming ], successful, Returm a 11, ,Ilzero value if the open_ ~'DD 'falls

(perhaps because the old file is currently open). 22.,2

<s;tdio '. h>

void re'wind (F'I'LB ~~r' ream) ,;

Sets the, file position indi' ator for the stream pointed '~O b~y stream, to, HIe beg~ r:l-niag of the file. Clears the error and end-of-file indieators for the stream, 22'J7

r in t Rlound to Inte,gral Valuel IUsin'g' Curre',nt D',rectiQ,n .(C9,9) double rint t,doub'le xl ,

f'loa:t rintf l(flo8't xl:

rj,Dtf

,. ·1::-'

T.1.nl,.. ,

long double. rintl (l,ong double· x) ;~

x rounded to an integer (in Floating-point format) using the current rounding' direc-

tion, May rai e 'the inexact floarii ,0"- oint e' ception if the res ult has a different value than Xi 23,4

r01und Bound ftc Nearest 'Integral Value (C,9S) d,oubI,E! round (double ,x,) l

float roundti (floa.t x.) ,;

long do,ub,le I'o,undl (l,ong double x) I

riOUD,df ro'u'J'J,ldl

x rounded to' the nearest integer (in floanng-poim f rman. Halfway cases ,_ e rounded away from zero, 23 .. 4

- 1 s'calb-D

- -

S'ca/s' Floatlng~PDint Number Usin,g tong tntage,. (C99)

Bca,lblnf Bca,lbln,l

doubl e B,calb1.n (d1ouble x, l,oIl.g int ii) ,; flo,at scalb1H-f(float x" long i,n~ :0),,0;

long doutiLe sc:alb,ln,l (long' doubl,e x , Lonq lnt nl ,

,scalbn Scale Floating-,Point N!umbs'r Using ,Integ,sr' (C9~9) double Bcalbn (d'ouble. X, i,n.t ni ,

sea,lbn,f' float ,sc'alb.D,f (flo,at x,int ri] iij

sealbnl long ,diouble g,calbnl (long doub1e sc, int nJ l

R'etur:ns x X F'LT_RADIXn, computed in an fficient way, _A ranse error may DIC-U1'i ,23~4

int acanf l conat; cha.r 'It res,trict fo,rmat:., ".,.);

Read" input item from the stdin stream. The . tring pointed to by fo,rmatpecifies the format of the item to, be read, Th ' arguments that follow f czmat; p ~ in to objects in which the item' are to be stored.

R'eturns Number ef inpuL item successfullyread and. tored, Rl .-turD - BOF ,.'J an input fail, ..

ure occurs be-fore any item, can be read, 3,.2.,22 .. 3

SI e tb'u f e« Butler

td I. '\."

<: B ... 1.0 . :.fJl!>'

void setbuf(FILE * ~estrict stream, c:har ." .restrict: buf) ,;

bu f i· - n l a null pointer, a call 0 a e t.bu 'f i equival t tIDI.: (v,oid) setvbuf (streaml, hu£, _TOFBF, BUFSIZ) ~ Otherwis e it's equivalent to:

(void) ,set.vbuf (str-e.am, NULL, _I'ONBF, 0);'

P,r,Bpare for NOIl'/ocal Jump' l.nt a,et j mp I{ j mp _buf env);

Stores the current environment in env for 0 • e in a later I all of longj mp.

mac 0'0

Rs,turns Zero when i railed directly. Returns ,I nonzero value . hen .r turning from a cal! of

lo,ngj mp, ~4.4

78"2"'-

I. '_

App,endix D Standard Libralry FUnctio'ns

chaz '*setlollca-le{in'- c,ate'gory, C'ODst char 'l'ocal,e);

sets a p - rtion 0 the prog '~. m'i 10 '. e. ,C:Ei tlsgo,ry indicates which portion i'

. ffect d, locale point to' 'bing r ~ r- " -en ing the ,Hle'w Io ale.,

.f ID,ca12 ill. a null p io.er returm _ pointer to tb _ '. trin,g . '.' ,-, ., gGry for the urrent 10·31.c. Otherwi e, returu a pointer to the with cat,eglory 'or the ne locale, R·. rum. a null pointer '. _ tb·

. · d

tnng assoctared

;0 .£': 01

- er, .. (In Ii .- •

,25.1

S-· t B' ffl

.~ '1 :' •

,B ·Uef

- - - -

-cat.dd.o .. h>

Lnt; setvbuf (FILE ., xeetzx-i at: ,str'eaml, cha r '* xee I,--.._..":,-t buf

\,.,. =- ~ I t......L ..L. ''"- - .... _ L ,1

Lnt, mode , size~t ai,ze');

. ;11,R,·e', the butferinz IO.~ the stream pointed ~cc. by Ea:r:eamo Th value of mode an be either ....... IO'FJ3F I -- D but ering) I __ IOLBF, line ufferingj, .... - IONBF' (1,0' bufferius )1. If buf "I a Dil11 pointe a buffer i automa · _ all ,~~H sea ec ~ -., needed, Otherwi e. bu.f p' sims to a memory block tb ~t can be used ,'. rh .. btl, eft, a iae is [be I umb ,f bytes in tb rlc e ,~. M te: ,setvDluf mu i be - -IJ·, after the str - am jr 'p 'D _ d but before any othe r "_p. - rl_" rion '. are _ erformed . - n· .

Rei,turns Zero of the operation is successful, · .. eturns a DI 0_ en v, Iue if mode is invalid 'or

the request can t b honored 221.2

<"sig'nal 01 h»

vod.d It *sign,al'( int s~ig, v01d (*fun,c') (int) , ) (int) ,

nstalls the fun ticn --I : inter toy fu'nc' I. lb_ handl r for th ~ignaJ Lb· se nWID'"" ber is sig., a 'sinl- SIG_DFL as the second argument cause default handling for

the signal 'P"~ 'ling SIG_IGN uses the sign - 'tO~1 ~':_ 111" red

Re~turns _ pointer 0 he pr . i1U.1 handler for thi signal: return BIG ERR I II ,d -,,' 1_, a posiilv value in errno if the hamdJ ~r can t b . in talh~d,,~4~8

~,"""""'h ,I t B~,~I£~~.

Sign B:it. (C99)

int si,gnbi t (,rre!ullloathlg x);

D nzero value " the Ign -_ xi negativ . and zero otherwise,

be any numb - r in clu ~ ing infinity and 'N'~

Rie,fur:ns

be " ~ IDe I I;: x lJl ,~-~y 23.4

sLinl IS1111

Sine

doub l.e ad.n (doubLe x) ; flo,ae ,sin,f (f.loa't ]C)I i

lon,g' dOluble s inl: (~ong double x);

<math.h>

23.3

S Ii nh Hypelr.bolic' Srlne

doub'l,e Isinh (double xli;

s-i·nllf i Loet: sfr1hf (:fl,oat x) I"'

s,inhl Lonq double sinhl (lo"'g clcruble x) ;

Returns Hyperboli sir ot x.. ranze errnr occurs if th masnitudeofx isto large, ,23.3

snp,r,j,n t£ IBfJ',underJ Fo,rm'sttsld String' Write (C9'9) <,st'di,o ~ h>

int sprin,', f (;cha,r * restri,c,:t e, size~t rr,

CIOllBt Ichar ~, xes zz iot: Earmet: r I!~")'

E:_ W ',al~'nt tVI fprintf"ut " ' h' I" ict r in the aIT2: ' point to b' s inst 'ad CI writing them, tc Em tream. NI mor th F=OE 1 _har,· " ten ," ill b "rn ten 'the

- y", be urim P' 'inLed to by format' ,. fiCi h I suh equ 'Ell: arguments win

be di pls '" d.Store . null ha -e . r in I ~ .. ay at til nd f 0,,1 put,

b~ _ . 'ro,red in tne array n ,,' includina ' h ~n n ' 1,'0, ,L r stri '" ti n., Returns _ nati " . Iue i an

ncodlng _ rror 0 cur.

22.8

int spr'in-fl(char .. resuir ict: s ,

coriat; char s-eet r i at: -ormat, "" ~) i

.Iqiuivi 1 m l ,fpriRtf bnt s torei charae r in I arra pointer to l -, 51, inst

f ritin tb .m to' ,8 tres m. The sirina pointe d bJ b forrnat p lfie ho . rub equ nt argumen . ~ ill - e displayed.Store I I. null character in the array at the end of o put

Returns Number of characters stored i the atI[,SlY'jl n" t includins th ~ nullcharact - ~ in . 99 ..

'fl. tum' II n _ gati e alue if . enc , ing erro ...' urs, 22~1J

a gr' t Siquare' Boo:

doub'Le sqr·t (d,cuh~e _e'l; floa· s'q11tf (fl,oat -) l

lCJng double sqr:tl ~lon9 doubl;e x) l

sqrt,f Sllqrtl

void az'and (uns iqned int Iseed) ,

U"CS seed lO initiali e dle sequence 0 . "Pli eudo-random numbers produced b· . all ..

ing raD,d~

int s;Bcanf (conat; char W cle,s,t,rict; ,S, I

conat; char * r,estric,t format I' .. I.' ., ) ;

"'Iui/[,en' fscanf nn reads eharacters J nu th ~'trinl' pointe to a lnsread 'f reading Idl em from a I t[, R' • The strina pointed tn . Y format specifie the fornu till·. it ms to b ~, a " -he argu 'lent that follo flO - mat p, int '[II objec _. in 'which the items are to be stored,

'784 Appendix D Sitandarcl LibraI}' Funr:tlons

Re,t,U'rns Number' of input item s succe ,fully read and tored, Returns EOF if an input fall-

ure oecur be' , re any item could b Il ad. 22.8

s t,:r,ca t ,String GOlnlcaten'B;,tion chac *strcat (c,b"ar "i:' restri,ct 151,

canst chaz .. reecr i as: 92);'

, vppends charact ''I'' from the string peinted (0 by 912 t. th ,- . trins pointed to' by 91.

R,eturns s~ (a pointer 1,1 the conentenated string), 13,.5. 23.,6

,<s'tring. h:.

<string ~,h~

chaz * strchr· ( const ch,ar *8" int c);

Rs,turns A pointe 1.0 the firs OCICutTen~ of he character c in the .. tring pointed f b s.

Return a -~ ull pointer if ch n'tfound, ,23.6

Strfn:g C:ompar:ison' int st'I"c'mp (conat; chaz .8;1, conet; aha.r "'62)l;

R:eturns A negative zero or J10~,··",1 in: .. ger, depending on . b ther the tring pointed [0 by'

s,l is les .tban e _wdo grea . r than the 'trine pointed 0 by ,92. 1B.5" 23,.6

s,trcoll String G'omp,sr.lsan Using Locale, .. Speclftc' Co.llatlng Beouence

int atrcof.Ltconst; char' *sl, onst char *82);'

Returns A negative, .... ero, or positive integer depending DC whether the string pointed to by. ,51,1 it' : less than equal to .• r zreater than the srring pointed. .by 8.2'., _ be.c.'· mparison

i· perlormed a cording t'DI the rules 01 ~ the I urrent locale I L(~, C10LLATE cate

23·I1l'

.o

<st,ring '. h~

st:rc:py' Sltrlng Copy

char' *str'·cP¥ (chax * x,esf:ri,ct aL,

cons t char '* restrict s2);

Copie ' the string pointed 01 by 82 into the array pointed to by sl.

Returns s 1 (a pointer t'CI the destinarionj.

<string., h:'J!

13 .. 5, 23.6

si2e~_t st.Jt"c'spn(clolnst. cha r *81, coriet; char ""s2),;

Returns Length of the longest initial segment of the string pointed to by 811 that doesn't

contain any character inthe tring p in'ted to b S,2. 23.6

., h

!!(,BtrLng'., :>

ch,ar ·stre~rro,r (int er rnuml ,

Return's' ,A pointer to a strin con' - ining an error messag c I corresponding to the ~ alee EJ_'

errnu.m. 24',2

Appendix ,D Standard' Lib'r:a'r,Y Fun'c,tions 7,85

<ti .. me i h»

size t strftime (cha • re'stri,ct :9, size_t maxad ae , cons chaz 'It- restrict tcrrnat.,

't" rt; t . t j ,_ t~' ~)

cans'· St:Z"U'C ~ zm r,es, - ' ~C~ 1'mep'lL.r;

S, ' ric' , rr y pointed bv s, und :'T C ntrol ihe I, ~. , poi D' .Ied

by" ozmat.. ~ hi' format string may' contain ordinary , h racters which arc copied ur hanged, and on' rsion specifi '" ~- hlch . r - repl 1-" d bl. values from tbl uruc ...

UI poinn d " by tirneptr .. The maxs Lze param er Iimits the numoer .f charDeter,'; (inclu. in _ 'th, null _ haracter) that IcaI1 be st "lied.

Re,tuffl'S Number 0' character I stored mot ~11 Iuding t11~ terminatin .null ch __ ~ " r). R :lrn o if be num aer c chs . cter '0 b ' storec (m_ lu ., th null charnel', -'"- eed

maxad ze. 218 .. 3.

8, t r'l en S,tring ,Length' si2'e~rt s,trle,n (corrst; char *s):

Rt3',tur:ns L ngth ofthe ~ lring pointed t: by s not including th DUn character, 1,3.,5t ,23.6

<string .. h>

char *strnca.' '(char 'Ii xeetzx i«: 511"

conat; char ... xeatzr i ot: s'2 I aize~t n);

, ppends charac en Irom the ", fE(' printed '~, 8,2 I he.s rins p inted to 'Y 911" Copying stops when ,.' null character i enc unter d or n, haracters hav ieen co 'II,d.

'Ill' , U")'

, 'c·

13~S 23.B

<Btring.,h~

int strncmp (cons,t cha r *81, canst chaz "'s2 f' size t n) i

Return's A negati- ',ro-,rp 'I iti- , intege [., depending on wheth r lh,- ~ rst n eharacter 0

., hie array pointed 'to b s 1 are less than 'gual Lo. grl ,at'_ r than t:J " tirst n charas '-

.• r I the arra point "mp- '" n s i. nullch _" ,len un-

t- re in ,e'i ther array, 23."

cbar *strncpy' (Ichar ':Iv restrict 5'1 f

,con'St ehar '* klestr '·'et 52, S.iZ'B_t n) ;'

Copies " he irst n ~h~ me, ~ rs 1 he __ " ~' point ,d-, 'b,~ s2 into th, arr _ p inted

b sl>1 If it encounte "E ull chsracter in 'th, arr pointed _' 'b_ s.2 strncpy adds null characters tal th aIT',B, pointed t,. by 81 until a toral c :n I ~',l1aract rs have beenx ritt en,

Rl .,' -

, e urns

<s--ring ~ h>

char . strpb'rk.(c'SD.st char *iS1, conat; char *9,2:);

Rletu,rns A P' iinter to the ieftml.·' t char, - etl - 'r in the string Pi inted to by s 1 that m_ tches 811:_

char , ter in '[he, tring pointed to by $' 2. Rerum ~I a null po.m,ter if no rna . hi .. foun ~ 23.,6

s trrclIr' Se,Bfich ,S',',"ing In R,s'verse for Ch'fl,rac,ter cst,ring',~ h»

'c'h,ar '*s,tr'I'chr (Icanst char *s,~, int Ie);

Returns A poin r t -I he Iast occurrence of the I bar- eter '0 in, th string pointed t 1 b s.

R turn ~. null pointer if c is a t. ·-ound. 28.18

s trsp'D S'earch String to" Initial Sp,an ot Gh'a,ractets in Set e::strin'9 h>

size t strs.pn (const char *81, .conat; ohaz "lq;,2);

~

Return,s eagth of the longest initial segment in the trin cr pointed 'II : b a 1. [h· 1'[ consu t

en" irely ot characters in the ,ninO' Pi in d to be- ,8,2'.. ,23~6

char *e,trstr(c'o'nst char. "s:l" conat; chaz *e2)';

Rs,turns' A pol nter t;1 01- fir· occurren in the trifle, p oin ted t b_ s 1 re ' ,::'. IDeo ~. (;]1 charac ers in the i rring pointed to by 82. Returns ,8 nuU 'p inn r if no mat b j

it und, 29.6

<stdlib .. 11>

doub.Le at.r -[0(1 (canst char * re,stric,t npltr,.

char .. Ilt9'stri,lct 'en.'dptr');

""P' white- pace charac ,- , in th string p. inted '_t1 bynptr then convert subs 'quent character iO['D' a double value If endptr isn't a null pointer strtod m difies th object p .. in " d EO by endpt.r so tb t it point to th fit st lef 0'" r 'character; I 01 doub Le value is found. or' i- has Ih_ wrong form, s,trtod stor '. npt.r in the object p inb~l_ to' by endpt r, If tbe number ii_III Iarg r small .0 represent, i st re ERAN'GE in ermo. C99 chan te ': 'The' strin pointed ,t ' _,-

nptr may OlD 'ain h; ad eimal floatin -poin nnmbe I in finity, or

neth r ERAN'GE :,' ,I ,ter,ed in errnlO' - h n th number i ' -00 '- mall ., represent II imple ,-' nt_ti m-defined,

Rlslturns Tbe conver ed number, Returns zero if n·' le- n ersion c[]u~d ie p rformed. If th numbe is too Iarge tn mpre' ent return . plus or minus ROGEI_ VAL!., dp odin .. ' In the number': sign. eturns ro 'i the number .i~- toe small to represent, C 9 change: If tbl.· number ito .mall [0 re -re'cnt strt.od 'U - a alue whose magnim 1_ i n - ~ reat -"r . ,- '_1 the malle 'e- n- nn alized po-. ~Li' dcub'Le. 26,,2

s t,r to f CO,nVB'ft StrIng to Flo,s't tC99)

fl,oat· str~of icoast: chex .' Tie's xLct: nptr, char *~ restri,c't ,e.naptr) i

-"' d'l-'b b <SiL·.·" 1. .»; I>

Returns The converted number. Retnrn zero if D,D conversion could be perform ·'d,. If the number is, too large to represent, returns plu 'r minus lITJ'GE_VAL,FI dep ending on the' number' si ,~ 1 - the numb r is l" m!· n to reprc ent -I turn a alu who e rnagnitu e t II 1- '. ,L than - 1 '1 est 1[- led -10 iti ,. - Loat; 26}~

intmax t strtoi,max (canst char *' rf!!stri,ct: nptr,

char" xeeturi ct: ,en'dptr', int bas,e);

Bl:rtoimax i' id_ t~ea1 _01 strtol- e. ce -,t ' hat it com ern a string '_- alue e ' typ~ Lnt.max _ t (th - wide t signe intcaer ,t. p ..

Returns' Tb Icon . let ed number. Return I ze if DO conversion could. be performed, If tb.,e'

num r an't be epresent n tum INTMAX _ MAX or I.NTMAX~MI·N- a 'pending

on be Dum '.1, r ". " ism., 27I2'

tr'to,k S'earch' String for 'To,ken' char strtok.l(char 'ii' 'xeetx i ct: sl t

conat; char 1.1 restrict:. 92) ,;

~._ arc he ne -,nn'_ p' iEW 91 ~. r . , ' cen COo-,I', ng , character not in 'b .string pint" d to b}1 82" If I~_ tok n exi, t-, the char ". - f - II : - ing !t . ':_ ranged to a null chara ter; f 81 Is a. null pointer; a sear mb b gun by the most recent call of at.r t ok is continued: thes arch begin imm d" tely" r the null char, ter ,(1., the

11 ,f the previou t - .' n.

R'eturn,s A:p, int r Ito tb first ·-h, tact r'_ the token. R '[0-- '. f a nun point <1- if no .r' en could be fOllnd"i23. e

I,

<8 rl.n:g '!! :>

's,ti'r"to._---·ll 0 tt S--, .", t L - I 'f'

,_.Olnvel_ ' I~- ,rlngl.O long, ,nllag'er

<stdlib .' h»

long int strtol (,'const leha,!" .. restrict nptr t

char ** restrict endp _·r, int ba,se), I;

,'~,ki_ps, white-space character in the' ,- ~iDg P in e, to by npt r then com rts suhseQ,U n characters in 0_ long tnt value. IfbasLe i~ bel: e m _ and 361 it 1: used as tb '. dix of -1 number, 1_ base i z:'f ~ the nu _ ' r .. ~' mad to . ecimal unl i i . gin .'ibol·.ctaJ·'r'·ithox.rOX hexadi -inll, Ilrendp'tr'iu'i mull pointer, s·tr-tol modifie the obje,et poln d to' by eridpt.r "',0 that it poi , . t: - Ute first leftover haraeter .. If no long int value js found, or if il. 11 ,. the' wrong, f rrn, strt10l t Ir-: np -r in [hie, 'bjl-' _ polnt to b.· endpt.r; '- ttl number

m't be repn -11' ed, it : {j. r s ERA~IGE in e,rrno"

R,etu,ms Th onvert d num oer, Return .. 'r. i n ' - nv. j :111 oul ~ perform _ d, -;" the number can 't b- represented, r etums L'ON'G _MAX or LONG __ MIN dependin _ on the numb r'I' sign. 2,5~2

long double 5'trtold{const obsu: .. relstri'ct nptr, c'na1H ~* ,rest.ri,ct ,en,dp,tr)';

7'8-'8',

.' ', ..

. _ ,_

s.trtoilid j. id nti alit' strtod except t it c D' en - string tc a long doub 1 e value,

ReturnS' The eonv rt ,1- nD111b._T. Retu =, z..' r 'I if'nocorr ersioncou! 1 p -di rm d. If 'the number i ' to ,I large to I"_prl- -' _ nl retu n _ [us or rninu I HUGE "VALL, de I ending o,n the number' "I sign. If th ... number : --. too 'mall La repres ent return a value 'who":' m_alg~ nltud I i_ DO. gr-eater than the small st normaliz d po, iti Ie' Long doub l e. ,26~2

~stdl,ib .. h:>

lo'ng Lonq int ,st1?tol1 tcone _ eties: * rescx ict: npltx, char ** reetzx i ot: ,ea,dptr., int beee) i'

strtoll ik identical 'to s trtol except tb tit C 11 erts i uring to a lang l,ong int value,

Relturns The COD", rile" number, R tum': z' TO j ~ DO conver l, 11 could be per', mn sd, '- ne number can be repre ented. r tu - LLO:NG_MAA lor L~,O'NG_MINt depending on th number · an, 2'"{l2

ungj_,gn,ed long int s:tr't,Qul (conat; chaz * restrict npt:r .. cha r ** restrict eridp't.z , int. baBe);

strtolulJ,~ identical It' at r"tol xe pi th __ It it C ,IT' eru a tring It- an una ~'gnled Io,ng; i nt value.

Rleturns' The convert - d nU111b " RlUfO' f ,I i [I: I' ven i :~1 ~ ould ". pc ormed [ the

nm er le_ n "t be repr anted etu D' OLOING-_MAX. 26.2

s tr,rtoull IConlvert S',trin,g' ItO Un's'igne'd Liang' '-Ding Integer (C9:9)' <stdlih., h;;>

rJnsi9D.ed long lo'ng i,nt strtoul1 (

canst char 1t re'st1-ic-t npi:r ,

cha,r ** restrict enapt.x , intE. 1Jase);'

stl!to,ull iii ntl u l" strtol", .eept tha 1 1,1 n errs a string La all unsi.qned long Lonq Lnt, - alue,

Returns ITI e corr erred numb r, Retu " I_I if n ' , -0" ersion could be pet' "in ed, I Il ,.-1

numo I an't b ,I repres nted, return tlLLONG_MAX,. 26.2

s trlto'umax ICo,nMert ISlt~lng to Unsigne1d Greate's't-Wldth Integer (G9'9) <~nttypes,~ h:>, uintnuvc t aErtou,max .(~onst: cbar * restrJ:lct npt:r ,

ehaz .. I rB'strict endptr,

int base);

strtoumax i' i ntical t ' strt'ol ex pt lh'-_ i CCID'ven a ,trilng te valm 01 type ud ntmax t f he, id ,[ unsigne d [11 J I --T t Pi_ '.

Betume TIle' nverted number, Return ro i n _·0 ver iion could be pe rmeo, II be

nurnbei can't be represented, return. UINTl'(AX_IVIAJL 27.21

s t r,x f rm 1fan,srorml String ,sizre t :strxfrm (cnaz' .' .restrict ,Sl j

-

canst: char if rlf2B ric;t: s2" sizle_t n);

Tran iform , the. mag pointed 0 ,ry 92, pi, cing the firs n·, bar crers If the result-s-including the Dull character-e-in the ,W _:'3y pointed to by e'1.· alling s't.'rcmp witb two transformed strings ShDU~d produce fh . ,i m outeom (negativc, zero or positi e) ,_'. callins s,tI'c'loll withthe I riginal trings, If n i zero, 81 i· I' Ilowed _ be , __ null pointer,

engtb of the transformed itrin r, 1f 'this VI _iu· is n '. r more - the ,e' 'n tent " array pointed ,to by s,l areinde erminate.

tl1e ,23.6

15wpr '~ntf Wide .. Chara,cte', Formatted ,S'tring 'Write (C9'9)

int ,S'wpri.ntf (,w,char._t: - xeer r+ct: 9.1 ei ee t D,

const wcha r' t :If- .r 'es tr'i c G f i3rma t I ". '") ;

E, _uiva]ent to f'wp'rintf, but" 'tOT, .. wid char cters in the array pointed to by S:

ins read o writin th '_ m (10 .~ ".- -: m i' The ,I'; n , p in ted by f ozma t- .- ecifie

lIJ'Ow subsequent arguments will b di" ]a~ ed.N tha n w~d, ehara ters will

be written. '£0 the a_ITay~ including a termi natmg null-wide chara ter,

Returns ' .. 'umber of wide characters ston d in tile array, not including the null wide charac-

ter. R _ 'turn" a negative value if" 11 ,n··, ding rtf Deem' - the Dumb r a wide character to b written is n or run re, 2S,5

<wchar .,h>

int eweceni: (con,eE: wcl1ar~t '. I'estrict s ,

cons r wcba,r' t .... r'e,st~-ict form'a:t, ",~ ~), ;

, ... id _ -character 'Version of aacanf. 25.5

eys'-- t- em "

,-' . !. . . .'- -' ..

Petiorm Op,era':t:ing'-Sys'te.m Oommsna int ,S y~;rte;m, { cons t char * st. ring) ;

Passe " the string point d ,.r by s·tring t I the perating svst sm CO ' d pro

Ices. or ( hen) to be executed, Program termination may QICCur ,I. .... , result of,' .e. 'U - ing th comman J ..

R,etufns H string i a nun pointer returns a nonzero V, JOJe if ' I '. ' rnmand poe '. r i

,ii, ailable, If s tr'in'g i n t a nul] p inter, ,sy:s,t1e.m return" an implement tiondefined ~,.' lue I • 'it -e"rurns at all I. ,2,5.,2

t an

<math '. h:>

doub l.e tan (doub'Le x) j t:anf float tanf (fl,Qrat xt ,

t,anl l,o'ng dDub~e' tan] (long double xF;

R'eturns' Tangent Or x (measured in radians),

23.3

719ifJ Appen'dix D Sfandard' Library' Ihunc,tions

tanhf ta.a:bl

Returns

Hyperbo,/ic Tangent <rna tll ~ h>

doub'l e t anh {doubl,e x) I;

float tanbf (flloat xJ;

llong dOi1Jble, tanbJ: (long d,QubJe xl ,

per --" - lie tang ent of x, 23.3

't"ga'mmaf t gamma 1

IG'slmma Fu,nctlon ,~C'99) <mat.h;;h>

double' tgamma ('doubl,e x);

flo'at t'g;amma~(float x);

long d'oublle tga,mmal (lon,g d01uble x:) l

Return's rex), where T isthe gamma function. A domain error orrange error muy [U::'CUI if-x

i -. __ Dreg" tive inteaer . '.' range er ,.: ·r m' I ·--ur if' th m~ 'gni ud 01" x i

larue Of' too small, 23.4

til .ame

C'urrent Time'

<time 11,>

tim-a t time {t.;ime~'t. *'tiln.rer) ;

Returns' urrent calend r time, R turns (t irne 't) (-1) i - th - aloud _ time i ",n''r ~_ ail-

able, If Lme r i - n ~ t ,I nul] JP inter; al o stores the r turn value in the object poi 0 led t b.' t Lme r.. :2'8" 3

tmpl f i 1 ie C,rreate TempOI7BLry', FILE *tmp,fille (vo.Ld) i

Cr-eatcl ,I: temporary ill . that wlll aJutomattlc· ]. be remov d who nit's -)0'-' d lor he' program ends, 0 aen the ~le in n wb U mo e.

R'eturn's A file pointe' to be used when performing sub quent operations I n 1h Il ~

R torn, , I . nutl pointer if ' __ temporary file can t be crear d .. , 22.2'

<:stdio.h>

'tmp:nam IGe,nls'rate 'Teml,'o~a,y' IFilfJ Nairne char '" t.mpnam r{ char * s l :'

Generates a nam Dr temp Irmy fil ',. If a i a null Pi -I'illter t.mpnam t ,- tb fil name iD! ,I static obj e.el. Otherwise j t copies the fi 1 ' Dame mto th, charac te r ar - _~y pointedto by a, [Th rrayn11ul he' ~ mg enough t ,·'ttoI'eL_tmpnam, haracr 1'.,.1

R,flturns _-~ minter 10 th file name. R nnms a null pointer if _~ file 11 me can't be enera ' ..

22.2

int tolower(int eli

Betume If c is an upper-co. se letter, returns th OO"i£ upper-e tse letter, returns c un ~ benge d.

lower-ease 1 tter, ··'C m nt an 23.5

toupper ConltSrt to' Upper ICasel int t.ouppe r (int c.);

Standard Library Fun',ctions

Re'turns I- c· i' a low ~-C'·'_'I'c lette ~ rena - the 'CDIT -'pnding upp, r ....

J. wer- - , .. : e Jetter, return·· 'C~ un~_ hange d"

C isn't 23.6

wint t t,owc't,ran,s (win't ;to w.c'~ wctr" 'n,B t: dese};

~ - -

R(jltur.ns ·-ap,p d alu o'we usiag th mapping cribed b:y deac, d,esc must be a

valu re turned b:y a call ,of w,c:t .. z ana: 'the '~DJTeDt settins of the L'C'_CTYP'E, carea:ory mus t be th~ ,, __ m . during both . all· .) ,25.,6

t,owl,lo _' ·'e'r Conven Wide ,Ch'ara',eter to Lo'wet' Case (e99) c:w,ctyp'e . h»

'w,int t towl,o:wer (wint we)' ;

- -

Returns If i:B wupp e r (we: ) i· true, returm a eorre '.0 nding w·ld haracter f or . fbJ .. , 11 iswlo'w,er]' 'rru· in 'the 'CUDi~'DI locale, if u - ,I cbar cter e dsts, 0' herwi "

Jf: 'urn 'W'C unchan .. · ed, 25.,{J·

to'wupp,Slr ICo,nve,rt Wlrde Cha'rs,eter to Upper Case {C9'9j wint:_ t toW'UpP,er twint_ t "f,C') t~'

,R:elurn,s If i sw1 0 .. -cer' ,( we) is true, returns :0 EDIT _ I__ nding '. id ch _~I- er _-' J whi _,h iswupper is true in the eurren 1'0. ale itu h a I. hi' a-',-'[ e, . sts, Otherwise, r turn' we un h ng '_.~ 25.6

tru,DC Ttunl,cate to Nea,rest Integra'i Valu,s (CB9) daub'] 61' erun e ('d'cnd)l,e x)';

trun,e,f £l"oa,t trunc'f (float xJI l

t.:ruD,cl l,ang double truncil (l,ang d,ou.b,le XJI l

Returns. x r· UJ~ . cd to the integer (in fl 'ia'ting,"'p' int _. rm ~ t) nearest 0 it but no larser ill

m '. - itudi ,"' 23~4

-cmat.h ~ h s

ung',e t.c tsueea ,Chraracter int, unqet;c I( int c FILE ·litre,am);

Push " the eharac . c back I,. [1'1. he tream pint d ~O b stream and '. 'the

str d-of-file indicator; ~ h ~ numb r .' '- h h ~ I ... I b, . pu b -': back

b nseeutiv . -, ' I .. , of unqeuc variest onl -he -, call is I, uaranteed to ,'Ur I.'" sed,

Calling a file positioning func ion I(fseek, fs,etpos~ Of ,rewind) can eo the pu . bed-back char cteJi(· ,) [6 be os 1.

Rle'turns C (lb. pu 'hed-ba k cl ar _ ter), Retu .", EOF if' ,- . attempt [ mane t· push bae .

EOF'. r L'p~ h back t ._c many l-_h. _,ct=L ·ith·1.l1' r d or ' e pcsitloning . per; -

tioo. ~4

ung .. t- "NI"C

'. I~ ~; .--' I 1"1 -r ' ._1

IUn,r:ea'd' Wide Ch'ars'ctsr (C9,91

win1t_ t ungetwlc (wint ,t C, FILE *stre,am}; '" 'ide-cbs aeter version of unget:c.

c:w'char .,h,>

25.,5

va a,r'g ~etch ,Argu,m,snt ttom \laria'b~e' Argum,en,t List'

-

R's-tHms-'

!~'. ·w" .' .~:

,typ'e via _,ar'g (va_lis- ap , t"l',e); macro F etches an argument in th variable arsument list ass , ,jatl_:ld _ i, ~h ap then modi ... file, ap '0 th.at th' next tse 0' va_arg etches the folio' ing rgument. ap mu' t ha e be, n inin" ilized by va_star't • or va_copy in C9- ) prior to (hie ,ti t ue ,f va=arg·,.

Vr lue 0 the' ar ~ ume U ., a ssuming that it typ _'1 (after the def ul tions h " e been applied) ii' -(lImp-Jibl wild! t rpe,.

BrgM eru pl}- '01, ,,- 26~ ,

,':a coov ll!',s

- -

Clopy Variable ,Argumlent Ust (C99)

<stdarg h>

vo,id va cloplytva li,st: deetz , va list exc] I '~WC' I I

!!!!!!!!!!I' - -

Copies sr'c into de,st" The value fdest will be the ame a' I!va_sta,rt bad been applied "I d,e,st 'II'; HOWled b tho, same sequence 0-[ va _ arg application I hat was used to reach the pres nt ' ate ,f s, re,. 2,6" t

void va enid (va list ap);

- -

Eo,d' , the pro:_ c~ ", ing , f lhe-' ariable argument list associa -' I , 'with apf!

26.1

va st,a,':~ t Start Pf(ocess'ing ,otVaria'bJ'e ,Atgu'm',B',nf List

~

voLd va_,start (va_list. ap ~' p srn ~ "')1 ; rna 'IV' MOil b_:_' invoke, be " ~ ce ',ling I' vari ble I ' gurnent U " I Ini .,~ lize ap for .I. ter use by va~arg ~n,d v~_en,d. ,pl,ulJ'n'l.N is th ' name of Ulc Ja't ordinary param ter

the on ~' ollowed by, " ~ )., 26. "

v:fp,riJ tf Form,atted' File Write' Us'in'g Variab'te Argu'm'sll,t List <st>dio ,. hs

int vfprintf (FILE w res,t,ri,ct at.r'eam,

const; 'char '* xescx Lct: f'ormat'l va_li,st arg)';

" .. ~'1Ii 1 I f I, 11 Ii • b'l ' ' n-· I

qiuvalent t ,I fprlTIt I -1~] tIl ,_,-' - ne ~ -Dum nt t _ pt ce,_, -"

arg~

Returns

Nurn ier of characters writt n. Ret rn

- -

Pormettea File R1e,afi Usin,g Variab,/e A,rglumf!l'nt List fC9'9) int vfscanf ('FILE • res';t,ric,t s'tx:ea,m',

canst cb,-~Il.- *' res:tr~'c~ form,a.tr va_D,et arg) l

-qllliv:alent tOI 'fsc:,anf with Ul- . anablc argument li t r placed b- arg .. ,Returns, nmbe -, of input items sucees fully read and stored. Re'tum·, EOF if an input fail-

fo- an' jtems ,- an be, r ead. 216 . .1

vfwpr in t f Wids,·,Ch'srs,cter Form'atls',d Ftil:s' 'Write Usln'§ \taria,blel Argument List tC99~'

<:wchar " h,>

Lnt: vf'~'rint,f (FI.LE ~ r,E!s'trict S"Creilm,

Clonst wchar t * rest,ri,c,t f'erm'at, va_lise a.rgJI l

Wide ... character ver ,~'Dn nfvfprintf.,

...

2§.5

v'f'ws,c,aD,f Wld9-Ch'at,Bc,ter Form,atted ,File R's,sd Us;ng Var,;abl,'e' ,A, mem L . (e99)

Lnt: v,t:wsc~anf I(F,I,LE *' rest.r',ic,t strea,m,

co'nst wcb a l."" II: zt x'e'B'.tri,c:t rorma,t"

........,

'va_l,ist ,EJ.rg);

Wid.e--cbar'3 .. ter version o ~ vf acan f,

tnt vprintf (conat; cha.r * restrict fo,rmat" va list a.J~lg)'; Equivalent t printf with 'the variable argument H l replaeed byarg.,

R· t"

I,·'· u ", ..

.. 0, Uftn.s

int vscaof' (lcQ,ns't char * xeet xLct: £,orma,t I va list argJ i Equivalent Co' acanf with the variable argument lisr r-eplaced. by arg,.,

Number of input item ~,ulc'!Qe~: fully read and stored, Returns EOF if 2Ll11 input failure. eecurs before any jtems ,CLm be read, 26.1

,iii tf'--' vs'np~,r£,D .,,~~'

, '

isit: vsnp'rint.fl(cb;,a.r W' !ls,s'tri,lct 51' siz,e_' t n, canst ,char ~ res'cri,lct Lorm,at.1 va list a,r:g);

~

Equivalent to snprin'tf with the varisbl "argument USlt replaced by a'rg.

RS'lturns Number '01- characters that would have been '. 'tolled in, the array pointedte by s (not including the null character) had tbere been 0,0 length restriction, Returns a negative value" ifan encoding error OC'ClJlfL. 2:6.'

int vsp~intf(ahar * restrict S,

canst chaz .. res't,rict forma,t;, v'a_list a:rg) ;

Equivalent to "spri.ntf with the variableargument list replaced b1y larg ..

Re"turns: Number' of characters stored in the array poiu to by ,5 nol including the Dull

character.In C919,~, remrns a negative value if an encoding error OC'CUf51'1 26.1

V[S'IC '_, nf Form'B,tted String R,Bad Using [Van~a'ble Alrgument List' (,e99) <stdio h,:> int vss'c'anf t coast: [char if: r,estri,ct So,

canst ,cbar 'ilt ':;,estJ:.i,ct [ormatl

v,a_li~t arg),~

Equivalent to SEu::an£ with the variable -,gunl n " It re placed by argo

R[e'turns Number of inIP''Ul i [en, 'UI" " funy f:..[_ d [' nd I tored, R eturns S[OF if an input ail-

W" aCCD, before any i'~--'m' can be read, 28.1'

V' _ ,,It'pr in t f Wide~Chara,(1ter Form[stted S'trin:g Wri~e' Using Variabte Argument ,List ~099j'

int vB'lNprin,tf,(~c,bar~'t II" restrict e , size_' 1:: III con,st wc'h,ar t: .. r'eB~rif!t format"

~

~'a~,lisl - arg.J ,~

quivalenrto swprintfwith the variable argument Ii -' replaced by arg~ Retur:ns Number of 'wide chara ten storedin th array, point d to by a, not includin I the null wid ,_h u-' [el, r, R 'urn' a neg, ti: 'e alne i -c_ an encoding rr r- occurs or the numb r of, ide ·'bara / e~ [ , 0 b ~ ,(tten i - n r InOIi _ ~ 250:5

<wcbar~h:>

VS-'~~'~'c,'-. n f',

, I..,'QI _" [~~ _~I

Wide~C-h'aracte,. Fornlatted St~in:g R'ead Us,;ng Va'rl~ab:le A rgums,nt, List (e' .,~

i.nr: V8lws'canf ('C'Q'Ilst wch~~_,lt 'Jre'strict S i canst wchar. t '* .restr~ct form,atj va Li.et: arg),;

........

II' tf" vwpr" D,·· ~- I

25,,5

Wide"ICharactet Form[atted 'Write Using Variable A,rgume'nt List~C99}

in;t vwprintf ,(C'ollst wcnar _ t 'i' restxict f,o'l1l'J[at, va_li_st ,arg) i'

'Wide'-ch.arac '_f .' rsic n " C vp,rintf-

<wcha,r ., h~

25.5

l11Vscanf Wide'~C'ha,acte'r F:o'rmatte'd Read' Using Variable A,rg,ume'n't L;st(C99)

int: vwsciluErc;ons 'W'char t l* xeetsr i ct: f,O'Z1ll'at", va_lis[t argJ I'

id - -charac .er vet 1, n or vs oarrf.

25:.,5

. ; ,crtomb Contlie,rt IWids' Ch'B)facter tOI Mu'ltibyte ,C'h'aractar ~ Res·tarta~ble<wchar i h" ( 9)

siz,e t wc'rtomb lchex : restrict. S/' wchar t we,

~ - ~

nIDls'tlate_t '* restri,c,t ps);

s j a null poin I, n a eall 0 f wcrtomb, i equiva ern ~[. I

wcr ~ omb [(buf I L" \0 I IPS)

huf i an internal buffet _ 0 ". rwis wartomb, ,; nvern we from " wide ch racter in' H, rnultibyte chara t r (pos,sllbJy in,c1udinS shift sequenees _ whilcb it SIOI - m the ,array poin I d to' bya, The value '-'P',S - hould t, _ ,3 pointer 'l,a an objec't

Or - e mbat a i Ie t. thm C'·, aim the leDIT '.D[ conversi n state, IpS:!" c null

pointer .. w,ort'Q,mb uses In intern I]. ~. ctt .' re the con ers ior state. _~ we ", null ,idle characr 'I w'c:rto,nib sroresa null b __ e preceded '-'I a shif sequence ~f necessary to restore the initial shift state, and the mbsta,te_t, object used during t111· II i left in the initial conver "OD I tate.

Return's ,". umbe T . ~-: . ytes s rt)r,_d in tb ., -a- - incln. ing s I ", e 'un "',~ If w'e i ~ n l ':_ '_ ~ d

,', id ~'h,ar,act r ti, un .. (size t) (-1) ,aD . '0 I .. E:ILSEQ' _ errnol~ 25.5

WCSC,i! t Wld'e .. SI~/ngl CO,ncats,t1:atio,n' (Cfjl~)

"cbar t itWC8cat fwchar' t res"t let Sll,

~

cens't w,cb.ar t * restri:c't 8,'2);

"'·Iae~ h, raeter sion i 'f s~rca't.

25.5

'WC',S ,cbr S'eatc'h' Wide' Srrlng' tor Chli,r8'(:ftef' (C919)

wcha t 1trwc'Js'lchr(,colnst char t e , we·bar t: c); ,-' ide-e harae . r .' rsio '0 st.rch~~

rc:wcha,r ~ h>

iJlt' WtCEJCmp (c'cnst: wctJ.ar_1t *'s~j const; w'cb,ar_t ·s2) l , id ~I haraeter version -~~ st'rcm,p~

25.5

we ,S,C 0 1 ,1 'Wjde .. S'trin,g ICol1l:par:ison' IUsing Lo'csl:e-Specific Gollating ,Sequ9'nce (C'9~)

int wc'scoll {clons" wc:har.:._t *sl, ocnsr; wahar t '*'s2} l

<w,ch,ar ,. 1'1>

we SrCpy 'Wide~St~ing Copy {:C99)

w'clJar t ':twc'S'lcpy(w'C~b,ar_t ,.. -r,es't.rict sJ.;

consc w'cnar t ,.. r,estxic,t s2)r;

<wcha.r ~ .b">

Wcsc1spn Search Wide S,tr,ing IfOr Inilia} Sp,an ,of ICh,arSlc,tslB Nr:J';f in' Set €'lAu:!ha,r ,.h> (e99)

25.5

-- -f~t ,. - tiles' ,. '.l.me

'Write FOrmatted' Dste Bind 'Tl.me 10' Wide' String ,fC9B)

e.ize t w'csflE:ime ('wc'bar~t it restri,ct e, ,size_t maxsizB" COD,st w,e.har t -- T't!strict format, ,c,onst SC'XLlCt tm w re6tr'ic' eimept~,);

we'sl en Wide-,Strlng' Length (C99)'

size t W'cB'len {cons,t wC'nar t *s) ," lde-characte ers "Oil of t;,trlen.

wcaD,ea't' Bo:unded Wtde,-Strl'n,'g' ,Con'catentation' (C9,9~'

wchar t *wo,s'nca:t (RI'char_t it' restr~ct ss ,

c'onst 'wcbar t: r,estrict 82, siz,e:_,t nJ';

"',' ide-char cter ersi m I f strncat

c,wch _r~, h»

<w'char [ii h:>

into wcsncmp [ccmet: wc:ha.r t ~"B~,/ aons't 't'loha.r t .5,2,

- iiiiiiO

ei.ze]: n.J' l

Wild e-ch racter er ion 01 ,B,trncmp~,

25 .. 15

w,c;ba,.r_ *~I'csrnlcpy (wch,ar~t "" restr'jet 81 i

c'ons;t wcb'~r t 'it J:.':estrict 82, ,sizs t n);

--

W·,de~,c,baracter version of str,~ o:,ply.

wcspbrk Ss',a'rch Wide, String for On's of a Self of Characters (C99) 'w'cha~_' t *w,csp.brk {c'Ol"l',st wchar_t *'131,

C!Ollst w,clla,r t *S2) l

Wide ... character version of B,trpbr'k.

,~w'cha,r ~,h,>

2B.5'

.- t',·lI'r'I'h' Lli'lT' h .....

IIIos. 'fM't ~ . '-, ~ IiI. ~I

wcbar t *wcsr'c'br (conet: 'we'.bar t *-,s" w,c,h,ar t c) /'

'!!!"""!!!!! ~

Wt ie-charaeter 'Vel .ion of strrc'hr.

25.5

F.l'iI"'"I B r' t:L 'O-I~~I S" .'

nr'I~, '.j' . _-! ·····:~IILI_, ,I

e i ze t wcsrtomb,s (ch,ar .. I,e,stri,ct ,dst"

canst wallar t: .'* restrict 8r,e" Biz'e~t' len,

mbstate~' t * res.t:rlct' ps);

ICon' eft -,I a. sequence of wide charaeten from tbc' array in dir,e.:t}y pointed to by s rc into a , equence of co '_'C, rending muJtibyt- eharacters that be lrL in tb .,' cen '\7_ rsion state described by the object pointed to b- pe, 1- ,ps,:it, it null pointer, wcsr"to'mbs uses an internal objiect to tore the cenverslon state. If dat, in t I, null porn' er the converte d ch ,(a 'eli, -, e then - tor ed in till' arrla~ point ~ d ~O' b_ det.. Conversion continues up to and includin terminating null wi, de character, whleh is ilso stor d .. CIOn er .. ion : top earlier if a wide characte i reached thai doesn't correspond to a valid multibyte 'hara~'ter Of-' ~i' dat; 11'n l a null pointer

·,

conv r In en I, t

umb r of byte ill __ 'e resultin multibyt h racn r snce , not _D ~'Judin·, an

terminating nul] Ch.,E c er, Return '. ( s i 2a3 _'l:, (~~) and stor __ , BILSEQ i n

ez rno if ,~I wid'~'h cte ' j: nc unt d th t d, e n t corre pond to J ' , Ji'c- mul j ....

"I te char JC' rHO ,25.5

,

WC,SISPID Search Wide Sfrfng fO'f Initial Spen iof ·Cha'/8oters in Set (eB9) <'wchar!> h>

ei.ze t wcsspn (canst 'wcl'l2itl'"'_t *'s1." canst wabar t )\0' -)I;

.. 'i I_:-~- hara iter ' erst n 0 at.:: spn, 25.5

Ses,Fc:h Wide S,tring tor Subs,trlng {eg9)'

<wohar,,'h.>

25.5

,- .-~

, ~

convert Wide String to DOUlbie (OB,e)

d'oi'ub1e' wc's:tod (lclons't wlc'bar~ t .. reer.ri.ct: np r,~, wchar t ** restric't e'n~ptr");

<we" a. b:>

r ersi nf at rt od.

Conven Wide String to Float (C99)

floa.t wc:sto'f(acnst wchaT_' t 'It restric,t .nptc1 w'C~har t 1!f*, re1strict endptr)';

s,tr-o' .

<wchar .. h>

2:5.5

--Slt:- Ii -

wei, -c~max

iIJtmax t Wlcs.toimax {canst wlcha -~t ,. re,st ict npt!r, wahar t i''' reecr ict: endpt ', int ba.seJ);

. ide .. ! '11 ~" acter -

"_- strtoimax~

27.2

;C'S tlclk Se,B,r:c,h IWidel String for Token (e99)

wch.ar t +vaecok: lwcha t.. res L ri ct sl, conat w1c'har t restrict

<wchar .. h>

7'Q···18··

- -_"I': ,',

A ~ .. D-' ,ppenulx . 'I

typle' wc·ha:r'_'t * that WICst,O]( modifies to keep track of its pregres .. If 811 is a null pointer" this lobj'lect must be the same one u sed in a previous call of 'w,cstok;, i[~ determines which 'wide strins is, to be searcbed and where the search is I~O begin,

Returns A pointer tc the firstwide character 'of the bJ,l{Ien,. Returns a null pointer if no 'token

'could be found, ,25.5

1 o "'ng' .; n t 1\".;;'iI'r"I!lr:l!' t ol. .( .1!"'IJ""'\-'J'i"I' ~ t tr. 1')'91 l-. .~ r t .,., r~ ,~' ·t- r i FlIt' n" 'p·t r

-':"'~""-~'_' "£'-'." '~M'~_h.1I' rW' ~~~iI,g' w'.~J;~w, _' _ ~~ '~~ _" "- .' I

iW"[cnar it 'it. reer rics: endpt:x , int ba..se);'

Wide"'lcb,1f8cter' version ef Bt,r't.loI. 25.5

wc'stold

C,nn" ven 1:lJ1;~#J2j1 S! " f.'f"'~ng- fn LD' n l,rIi D'nlli [~bc-'~:~ "C'" '9·· '911'~'

L~t 1. '~'Dl I "IV'~IIU'lGi l.~ .. 1"1' i' I(U1 '. I, ~' UIW' .'Ig;: ~' -,:_' --:_'I

lon.'g doub.le wc's tOil ld l(cl,ons't w'cha,r~t .~ res,·tric-t np't:rll w'cb,ar t ** restri,ct endpt,r);

Wide'-Icharrac'~er 'version 'of strtold,. ,2:5.5

lon.g l·on,g in.:t:wcrst,011 (c'c,n_,st ~cbar e ,. re,stric't npt'r, Wrcna,r t '** xeetzxi at: e,ndl~rtr"

~

intbass') ,~~'

Wj,de,-char,IC[erV,er,'iCrn; 0_' strtoll ..

25.5

,<9t.dlib 11, h»

sf.ae 't. w'cstomb.s (char '* reet.ri ot: a,

canst wcha,r t * r',e,s'triC'E P"WCB, j. sizs_t n.) ;

C,oIDve:r1 a sequence of wide characters into coni:·, pending multi by' " character '. PIW'e,E\1 paints, to an array containmg the wide characters. Tbe multibyte character .. are stored in the array p" 'iDled to by .s. Conversion end ~ If ,I null character i stored or if .. toring a mnltibyte character 'wou1.d exceed the Hoot of n byl_s,.

Return's Number of byt1e stored, not including the terminati'n,g nu.n character, if ,any..

Returns (s i z e _ t)1 (, = 1 )i f a wide character is encouutered that doesn' t correspend tOI a ' alidmultibyte character, 25.2

we s tou:,1 Co,nvert W~'de String tal IUn'sig:nedL,on,g Integs'r (099) unsigne,tj' Lonq dsu: WC'8'tloul (

lG:'onst' 'Wlcba_r~'t \'It- r'6strict npltr,

wc'har t ,*~ res,.tri"c,t ,endptr't int bas,e);

-. "

~i: II!'( ':''-'I~~I

we s t Qull Co,n'rtls,rt Wide 18trln,g to ,Un'sig'nred L.:o,n'g Long' Integer IC· uns.igned 1o]'l,g ,Le,ng in,t wc .. stoluJ1 (

c'onsrt waha:r~t * re,stri,ct ~ptr, wcha.r_t** cest.r'l.et endpt,r', int blase)';

Wi,de-lcbui8Lcf,er version of s trtloul 1.,

<wch,ar",h~

WC __ ~I to'1UnaX Co,nvert Wide' Strin,g to Un'signed' Grea',te'st-Width In,teg,sr <inttypes ",h:>

~. "',.~

ui.ntmax t wcstoum~ax(C'Qnst wcbar~t '* restrict nptr, ,cba·r_t *:t - 'e-striat ,s',ndp,t I int base);

id -character -, ersion of ,strtouma.x.

27.2

'I'.III':C· 'S' .,.. I"·~·~.t -.\~-

Tran,sfo'rm' V1I~de 8,fring (C99)

,I ~ f- (1 .' - -, r'.,....~' -, t 1

,S1.ze ~. weax, rmWClar t: ' .r.eBIL-.4-~C S. ~,

- -

conat; wc-har t rest,ri,c],t 821) s i.ze t nt.,

Wide-character version of ,strJITrm" 25.5

<wch,ar" 11:>

wc't:,ob ICo'lnVrstft' 'Wide Ch'srac.t6Ir fa B:yte (C9'9) int wctob {wi,nt t: c);pc

R,sI,turns Single-byte representation ,- c a' uns,igned chax . ~ '0 erted b, int~ '.' ir

E'OF jf c do r .. .n 't correspond l one muIti,by e charact r in tile ini ial shif - t __ . ess

iC ... 1

c:wchar h~

we' 'ta- mb- ,

.' - . _I, -, I' . :'

td-l '. b h

<s I. 1_ -: ,~. >,

int wotomb'(char *5" "c'har_t w€) "

Converts th wi chan '_I' ' stored in wc into ,_,I multib ,,[ I. haracter, .. S isn't a Dull pointer store - ;th - 'rlecl-U It. In lb· -ra,y that s _ I in '"

Rs,turns If IS i a null pin' r tum', n nzem I . rn val - dept nding ' . - hether or nc ,

rnultib tl - ch a ,rtl cT' ha e _ t 'Je ... d pe ' dn _ - RlCI - ' in, .. 0' - i c-, return th nu - bel' of :by1,e in the mu.Uibyt character that c srre pond: to W'C,: return, ,."".1 if w.e do isn t corresp ad to IS alid mul tibyte ehara, t r, ,2S~2

we t ran, . ' D,ef/nle Wide~Ch'arac,tef ,M'appin'g' (C99) kf'ctrans t we trans' (clonst cber *property);

Rsrturns _I prope,rty identifies a _'- '_' m ppmg 0' "i ~ charact r- i!:IC_I' d"'ng tc the LC CTYPE rate I I 'of tb~ CU'JTent II C,a}"1 1i urns a n nze r ." alu _" '_, u .. - n be u_ ed as th. second MI,u,en.( t the to'w'ctrans function: I 'lb. rwise, returns zero,

25,,6

wctypl,l@~t wctype (canst char'pr,ope.rt:y) "

Returns proper'ty id ntifie a alid clas "-ide character according to he

LC ........ [!TYP,E~-~ " 'g. -, - ,.'. tile cum nt locale, retur _ iCi n.. I '~ero value 1st. an b - u ed as, th 8" cond argument to (be, iswctypl'e tu ction; otherv t 1-, tur ,-', r' ~ 2S}J

WJIi,sm,cbr Sealiah Wids'-1Characlter ,Memory Block for Ch',aracts'r (G99~ W'ch,ar t *w.memchr t couet: If'char t re , w,cll,ar t C1 size t n);

" c-. d !~ h,arac.ter erslc If memchr;

<wchar~h>

25.5

in t tim'e',mcmp (cone t wc'ba,r_t ,.. ,s 1" cen e t wchar t * s,2,. e i xe t: n) ".

Wide-character version of rnemcmp,

IflDsmcpy CO;py 'Wjde'~Cha'ra'c~er Mem',D'TY ,B'/ock (C'99)

!:;,,:I',C· 'h'· a-'r t.r 'W'II .. Tn'lslm· C1ny'. (m ... · .. ""'h' 'ar t * r-·o's,'tr.1.~ c t s·ll

'AI' 'W U~ ., :. r, I, W'L".· '. _ I: , , a c I . _. j I. tI'

IC.O,.llSt Iw,c,har' t ,. re's't'rict s21~

.......

si ze_' t si) I"

Wide~-char,ac_ r ersion memepy,

1VJDemmove C,opy Wi:ae-,C,hara,c,ter Memory Btock (C9,9~'

<wchar_h>

'wcnlar t *'~emmo've (we,har t 'ltsl, conac wahar t *,92',

~ -

s.i.ee t nl :

Wide-character version 01 m:e'mmov@'.

25.5

'I"01"""·em· .. ( '-~'Sie t

.. .,..I.::_ _ ' ~. :.____-,

Ini,tialize Wlde .. Ch,ar:acti9,' Memory Block tC99)

<wchar~h>

wchar t ""wrnems,8't (_.clJ.a,r t Wide-character ersion 0 ,. memseti.

"13-;-'

-- "

wchar t c, size' t nJ l

20.5

wpr i,n t.,f WidB'''",Chara~cte'r Forma' .ted 'W~ite rC9Y)

int wprintf(cons't . ,C"llar t 1Jo rs'stxict -':ormat", 'W"""de charac _ - - - "0 of . i t f'

1 ~ 1= _' ~-i;. I~r ver',l n' ~ ~ pr _j n' ~

25.,5

<wahar .~ h»

int wscanf ('c'on,st JV:char t: * reetzr.i.ct: Iorm,at", .... l : 'Wide-choral rer ver ion 0 acanf ..

25.5

You might also like