home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
msdos
/
c
/
jplc1.arc
/
USEGUIDE.SI
< prev
next >
Wrap
Text File
|
1988-07-22
|
171KB
|
4,034 lines
.cw10
.po17
.pn 1
.PN 1
.FO 1-#
1. I N T R O D U C T I O N
Thσáá purposσá oµá thi≤á manua∞á i≤á t∩á describσá thσá usσáá anΣ ì
installatioε oµ thσ Portablσ ├ Subroutinσ Library«á Thi≤ librar∙ ì
i≤á ß collectioε oµ module≤ writteε iε thσ ├ languagσá (Referencσ ì
[2])¼á tha⌠á i≤á capablσá oµá equivalen⌠á operatioεá iεá multiplσ ì
environments«á Thσá librar∙á i≤á availablσ iεá sourcσá forφá fo≥ ì
compilatioεá anΣ integratioε int∩ ß systeφ librar∙ t∩ replacσ thσ ì
hos⌠á vendo≥ ├ library«á Listing≤ oµ thσ portablσ ├ librar∙á arσ ì
containeΣ iε ß separatσ documen⌠ (Referencσ [15]).
Thσá conten⌠ oµ thσ librar∙ consist≤ oµ function≤ whicΦá minimizσ ì
thσ visibilit∙ oµ system-specifiπ I/╧ formats¼á thσ usσ oµ systeφ ì
commands¼á anΣ thσ reliancσ oε specifiπ systeφá resources«á Somσ ì
customizatioεáá i≤á necessary¼áá however¼áá t∩á accommodatσáá thσ ì
ideosyncracie≤ oµ eacΦ ne≈ host« Somσ oµ thesσ ideosyncracie≤ caε ì
bσá removeΣá b∙ prope≥ definitioε oµ parameter≤ iεá heade≥á file≤ ì
includeΣá wheεá thσ portablσ librar∙ i≤ recompiled«á Other≤á ma∙ ì
requirσá ß smal∞ amoun⌠ oµ codσ alteration«á ┴ late≥ sectioεá oµ ì
thi≤á documen⌠ contain≤ informatioε anΣ procedure≤á fo≥á adaptinτ ì
thσ portablσ ├ librar∙ iε sucΦ cases.
Thσá systeφá I/╧ interfacσ i≤ restricteΣ t∩ thσá function≤á sbrk¼ ì
close¼á creat¼á exit¼á lseek¼á open¼á read¼á unlink¼á anΣá write¼ ì
supplieΣ b∙ thσ hos⌠ ├ languagσ vendor«á Thesσ arσ assumeΣ t∩ bσ ì
compatiblσ witΦ UNIXtmö conventions«á Anothe≥ functioε ¼á rename¼ ì
i≤á assumed¼á eithe≥á addeΣá b∙ thσ ├ languagσ vendo≥ o≥á b∙á thσ ì
installe≥ oµ thi≤ library«á Thσ floatinτ poin⌠ arithmetiπá systeφ ì
interfacσ consist≤ oµ onl∙ ß fe≈ functions¼ sucΦ a≤ chrstc¼ fint¼ ì
ldexp¼á astof¼á anΣá ftoa¼á tha⌠á requirσ somσ alteratioε oµá thσ ì
sourcσ code«á Thσ remainde≥ oµ thσ librar∙ utilize≤ thσ standarΣ ì
Kernighaε anΣ Ritchiσ (Referencσ [2]⌐ ├ languagσ features.
A≤á man∙á oµ thσ UNI╪ librar∙ function≤ a≤ werσá deemeΣá portablσ ì
werσá includeΣ iε thσ portablσ ├ library«á Thesσ bea≥á thσá samσ ì
name≤á herσá a≤ the∙ d∩ iε thσ paren⌠ library«á Othe≥á function≤ ì
havσ beeε addeΣ fo≥ greate≥ utility.
Description≤á iε thi≤ manua∞ follo≈ thσ UNI╪ Programmer'≤á Manua∞ ì
format╗á iε fact¼á thσ description≤ oµ thσ commoε function≤á werσ ì
adapteΣ froφ thσ paren⌠ manual« Thσ tex⌠ i≤ collecteΣ int∩ ß se⌠ ì
oµ subsections¼ whicΦ appea≥ wheε applicable:
áááááThσá headingé oµ eacΦ entr∙ give≤ ß ver∙ shor⌠ descriptioε oµ ì
áááááthσ purposσ oµ thσ function≤ iε tha⌠ entry.
áááááThσá nameé subsectioε list≤ thσ exac⌠ name≤ oµ thσ heade≥á o≥ ì
ááááásubroutine≤ covereΣ unde≥ thσ entry.
*UNIX is a Trademark of Bell Laboratories.
èáááááThσá synopsiséá summarize≤á thσ usσá oµá thσá functioεá beinτ ì
ááááádescribed¼á includinτ requireΣ includeé statements¼á formats¼ ì
áááááanΣ passeΣ parameters« ┴ fe≈ convention≤ arσ used:
ááááááááááBoldfaceé word≤ arσ considereΣ literals¼á anΣ arσá typeΣ ì
áááááááááájus⌠ a≤ the∙ appear.
ááááááááááSquarσá bracket≤á █ ]é arounΣ aε argumen⌠ indicatσá tha⌠ ì
ááááááááááthσ argumen⌠ i≤ optional« Wheε aε argumen⌠ i≤ giveε a≤ ì
áááááááááá'name'¼ i⌠ alway≤ refer≤ t∩ ß filσ name.
ááááááááááEllipse≤á '...ºá arσá useΣ t∩ sho≈á tha⌠á thσá previou≤ ì
ááááááááááargument-prototypσ ma∙ bσ repeated.
áááááááááá┴ fina∞ conventioε i≤ useΣ b∙ thσ command≤á themselves« ì
ááááááááááAεá argumen⌠á beginninτ witΦ ß minu≤ sigε '-º i≤á ofteε ì
áááááááááátakeεá t∩ meaε somσ sor⌠ oµ option-specifyinτá argumen⌠ ì
ááááááááááeveεá iµá i⌠ appear≤ iε ß positioε wherσá ßá filσá namσ ì
áááááááááácoulΣá appear«á Therefore¼á i⌠ i≤ unwisσ t∩ havσ file≤ ì
ááááááááááwhosσ name≤ begiε witΦ '-'.
áááááThσá descriptioné subsectioε discusse≤ iε detai∞ thσá subjec⌠ ì
áááááa⌠ hand.
ááááá┴ seσ alsoé subsectioε give≤ pointer≤ t∩ relateΣ information.
ááááá┴áá diagnosticséáá subsectioεáá discusse≤áá thσááá diagnostiπ ì
áááááindication≤á whicΦá ma∙á bσ produced«á Message≤á whicΦá arσ ì
áááááintendeΣ t∩ bσ self-explanator∙ arσ no⌠ listed.
áááááThσáá bugséáá subsectioεá give≤á knowεá bug≤á anΣáá sometime≤ ì
ááááádeficiencies«áá Occasionall∙á thσá suggesteΣá fi°á i≤á als∩ ì
ááááádescribed.
.pa oè.PN 1
.FO 2-#
2. H E A D E R L I B R A R Y
Thi≤á chapte≥á describe≤á eacΦ oµ thσ portablσá librar∙á standarΣ ì
heade≥ files¼á whicΦ contaiε definition≤ oµ constant≤ anΣá macro≤ ì
t∩áá bσá useΣá wheεá compilinτá use≥á programs¼áá anΣá als∩á wheε ì
recompilinτ thσ portablσ librar∙ itself«á Iε addition¼á global.hé ì
anΣ stdio.hé definσ globa∞ datß structures╗á global.hé i≤á requireΣ ì
fo≥á eacΦ mainé segment¼á anΣ stdio.hé i≤ requireΣ fo≥ al∞ program≤ ì
which use buffered i/o.
Generally¼á al∞ macro≤ anΣ constant≤ defineΣ iε heade≥ file≤á arσ ì
captalized¼á s∩á tha⌠ thσ use≥ ma∙ kno≈ tha⌠ the∙ arσ such«á Thσ ì
exception≤á arσá thσ globa∞ variable≤á errnoéá anΣá progname¼á anΣ ì
definitions of stdin, stdout, stderr, tiny, and utiny.
Generally¼áá al∞áá system-dependen⌠á constant≤á o≥á switche≤á arσ ì
containeΣá iε thesσ heade≥ files«á Thu≤ customizatioε fo≥ ßá ne≈ ì
systeφáá primaril∙á involve≤á changinτá onl∙á thσá heade≥áá file≤ ì
(stdio.h¼ mathcons.h)« Howeve≥ somσ subroutine≤ ma∙ als∩ requirσ ì
modification«áá Seσáá thσáá customizatioεá note≤áá fo≥áá furthe≥ ì
informatioε concerninτ thi≤ subject.
The portable library standard header files are:ì
.uj0
áááááctype.h standard character-type macros
ááááádefs.h standard definitions and selectors file
áááááerrno.h standard error number definition file
áááááglobal.h standard global variable header file
ááááámathcons.h constant file for math functions
ááááámathtyp.h header file to declare math functions
scrnio.h terminal display data file
ááááástdio.Φ standarΣ buffereΣ i/∩ definition package
ááááástdtyp.h standard defined-types file
.uj1
.paè.hectype.Φ ctype.h
Standard Character-Type Macros
NAME
áááááctype.h
SYNOPSIS
ááááá#includσ <ctype.h>
áááááBOOL ISALPHA(c)
áááááint c;
ááááá« « .
DESCRIPTION
áááááThesσá macro≤á classif∙ ASCII-codeΣ intege≥ value≤ b∙á tablσ ì
ááááálookup«á EacΦá i≤ ß predicatσ returninτ nonzer∩á fo≥á TRUE¼ ì
ááááázer∩á fo≥ FALSE«á ISASCII i≤ defineΣ oε al∞ intege≥ values╗ ì
áááááthσá res⌠ arσ defineΣ onl∙ wherσ ISASCII i≤ TRUE anΣ oεá thσ ì
ááááásinglσá non-ASCI╔ valuσ EOFé (seσ stdio.h)«á Thσá condition≤ ì
áááááfo≥ TRUEé are:
.uj0
áááááISALNUM(c) c i≤ aε alphanumeriπ character.
áááááISALPHA(c) c i≤ ß letter.
áááááISASCII(c) c i≤ aε ASCI╔ character¼ codσ les≤ thaε 0x80.
áááááISCNTRL(c)á c i≤ ß deletσ characte≥ (0x7f⌐á o≥á ordinar∙ ì
ááááá áááácontro∞ characte≥ (les≤ thaε 0x20).
áááááISDIGIT(c) c i≤ ß digit.
áááááISLOWER(c) c i≤ ß lowe≥ casσ letter.
áááááISOCTAL(c)ááááá cé i≤ aε octa∞ character.
áááááISPRIN╘(c)áá céái≤á ßá printinτá character¼áá codσáá 0x2░ ì
ááááá (space⌐ througΦ 0x7σ (tilde).
áááááISPUNCT(c) c i≤ ß punctuatioε characte≥ (neithe≥ contro∞ ì
ááááá áááááno≥ alphanumeric).
áááááISSPACE(c) c i≤ ß space¼á tab¼ carriagσ return¼ newline¼ ì
ááááá áááááo≥ formfeed.
áááááISUPPER(c) c i≤ aε uppe≥ casσ letter.
.uj1
áááááThσ followinτ usσ thσ ISUPPERé anΣ ISLOWERé macros¼ anΣ returε ì
áááááß character:
.uj0
áááááTOLOWER(c)é return≤ thσ lowe≥ casσ oµ c¼á o≥ π iµ i⌠á i≤ ì
ááááá lower case.
áááááTOUPPER(c) returns upper case of c.
.uj1
èSEE ALSO
ááááácorrespondinτ lis⌠ oµ functions.
BUGS
áááááBecausσá thesσ arσ implementeΣ a≤ macros¼á sidσ effect≤á ma∙ ì
áááááno⌠á bσá handleΣá correctly╗á e.g«á ISALPHA(*s++⌐á ma∙á no⌠ ì
áááááproducσ thσ intendeΣ result« Usσ thσ functioε forφ oµ thesσ ì
ááááámacros in such cases.
.paè.hedefs.h defs.h
Standard Definitions and Selectors File
NAME
ááááádefs.h
SYNOPSIS
ááááá#include <defs.h>
áááááMAX(a, b)
áááá ...
DESCRIPTION
áááááThe following operators are defined in defs.h:
.uj0
áááá AND replacemen⌠á fo≥á '&&'¼áá thσá logica∞á 'andº ì
ááááá operato≥.
áááá FOREVERé samσ a≤ 'fo≥ (;;)'¼á cause≤ aε infinitσ loop« ì
áááá IS á replace≤áá '=='¼áá thσá logica∞áá equivalencσ ì
ááááá operator.
áááá ISNT act≤ a≤ thσ non-equivalencσ operator¼á '!='« ì
áááá NOT substitutσá fo≥á '!'¼á thσá logica∞á negatioε ì
ááááá operator.
áááá OR replace≤á '||'¼áá thσá logica∞áá inclusive-o≥ ì
ááááá operator.
áááááThe standard constants defined in defs.h are the following:
EOF (-1)
FAI╠ áááá 1
FALSE áááá 0
NO áááá 0
NULL 0
SUCCESS áááá 0
TRUE áááá 1
YES áááá 1
áááááAls∩ iε defs.hé arσ severa∞ macros:
áááá ABS(x)é return≤ thσ absolutσ value of x.
èáááá GZ(x)é return≤ xé iµ xé i≤ greate≥ thaε zero« Iµ not¼ ì
ááááá i⌠ return≤ zero.
áááááLURSHIFT(n¼ b)é return≤ thσ valuσ oµ lonτ né afte≥ aε unsigneΣ ì
ááááá right shift of b bits.ì
áááá MAX(x¼ y)é return≤ thσ large≥ oµ ° anΣ y.
áááá MIN(x¼ y)é return≤ thσ lesse≥ oµ x and y.
áááááSGN(x)é return≤ +▒ iµ ° i≤ positive¼á -▒ iµ negative¼ ì
ááááá o≥ ░ iµ 0.
áááááURSHIFT(n¼áb)éá return≤á thσ valuσ oµ in⌠ néá bit≤á afte≥á aε ì
ááááá unsigneΣ righ⌠ shif⌠ oµ bé bits.
áááááExamples:
áááááááááááiµ (statement▒ AN─ statement2⌐ ...
ááááááááááá° ╜ GZ(x);
áááááááááááFOREVE╥ ...
áááááááááááiµ (op▒ I╙ op2⌐ ...
áááááááááááiµ (op▒ ISN╘ op2⌐ ...
áááááááááááwhilσ (NOT x⌐ ...
áááááááááááwhilσ (statement▒ O╥ statement2⌐ ...
ááááá large = MAX(x, y);
.uj1
SE┼ ALSO
ááááálist of corresponding functions.
BUGS
áááááBecausσ ABS¼á GZ¼á MAX¼á MIN¼ SG╬ arσ implementeΣ a≤ macros¼ ì
ááááásidσá effect≤á ma∙ no⌠ bσ handleΣá properly«á Fo≥á example¼ ì
áááááABS(i++⌐ ma∙ bσ incorrect«á Usσ thσ functioε form≤ oµ thesσ ì
ááááámacros in such cases.
.paè.heerrno.h errno.h
Standard Error Number Definition File
NAME
áááááerrno.h
SYNOPSIS
ááááá#include <errno.h>
DESCRIPTION
áááááerrno.héá define≤ erro≥ numbe≥ values«á Thσ onl∙ tw∩ useΣá iε ì
áááááthσ portablσ math librar∙ are:
.uj0
áááááERANGEé computeΣ matΦ valuσ i≤ ou⌠ oµ computablσ range.
áááááEDOMé functioε argumen⌠ i≤ no⌠ iε defineΣ domain.
.uj1
áááááOthe≥á value≤ oµ errnoé ma∙ bσ returneΣ b∙ systeφá call≤á anΣ ì
ááááábuffereΣ i/∩ functions« Typica∞ errnoé value≤ returneΣ b∙ thσ ì
ááááásysteφ call≤ useΣ b∙ thσ portablσ librar∙ are:
.uj0
áááááENOENT file does not exist
áááááE2BIG argument list too long
áááááEBADF bad file descriptor
áááááENOMEM not enough memory for requested operation
áááááEEXIST file already exists on create request
áááááEINVAL invalid argument
áááááENFILE exceeded maximum number of disk files
áááááEMFILE exceeded maximum number of file descriptors
áááááENOTTY not a terminal or device to which calls apply
áááááEACCES invalid access request
áááááEIO i/o error during read or write
áááááENXIO no such device or address
áááááEPERMé modificatioε forbiddeε excep⌠ t∩ owne≥, superuser
áááááEFAULT bad address
áááááEXDEV cross-device link attempted
áááááENODEV no such device
áááááEFBIG file too large
áááááENOSPC no space left on device
áááááEROFS read-only file system
áááááEMLINK too many links to a file
.uj1
SE┼ ALSO
áááááglobal.h
.paè.heglobal.Φ global.h
Standard Global Variable Header File
NAME
áááááglobal.h
SYNOPSIS
ááááá#include <global.h>
ááááámain(argc, argv)
áááááSTRING *argv;
DESCRIPTION
áááááThi≤á heade≥á declare≤ ß globa∞ variablσ errn∩ anΣ ßá globa∞ ì
ááááávariablσá strinτá progname t∩ bσ useΣ iεá thosσá case≤á wheε ì
áááááargv[0▌á doe≤ no⌠ contaiε thσ prograφ name«á Thσ programme≥ ì
áááááma∙áá usσáá thi≤áá variablσáá t∩áá recorΣáá thσáá name¼áá a≤ ì
ááááá
ááááá strcp∙(progname¼ "<prograφ name>")╗
ááááá
áááááIµ arg[0▌ doe≤ contaiε thσ namσ oµ thσ invokeΣ program¼ theε ì
áááááthσ samσ effec⌠ i≤ obtaineΣ viß
ááááá strcpy(progname, argv[0]);
áááááThi≤á filσ als∩ contain≤ outrow[]é anΣ outcol[]é whicΦ contaiε ì
áááááthσ ro≈ anΣ columε value≤ oµ al∞ outpu⌠ channels¼ indexeΣ b∙ ì
áááááuni⌠á number«áá Fo≥á buffereΣá i/o¼áá thesσá arσá giveεá b∙ ì
áááááfp->_unit╗á fo≥ unbuffereΣ i/o¼ thσ uni⌠ number≤ arσ STDOUT¼ ì
áááááSTDERR¼ anΣ filσ descriptor≤ returneΣ b∙ open.
.paè.hemathcons.h mathcons.h
Constant File for Math Functions
NAME
ááááámathcons.h
SYNOPSIS
ááááá#include <mathcons.h>
DESCRIPTION
áááááThi≤á heade≥á filσá contain≤á thσ value≤á oµá thσá followinτ ì
ááááámachine-dependent constants:
.uj0
áááááááááá BIG10╪á 10▐(2▐(BIG10X-1)⌐ ╝áINFINITYì
áááááááááá BIG╪ 1╢ ¬ log2(INFINITY⌐ - ▒
áááááááááá DPRECISIO╬ (int⌐ PRECISIO╬
áááááááááá INFINIT┘ machinσ infinity¼ 2(MAXEXP-1⌐
áááááááááá INFINLE╟ INFINIT┘ » sqrt(2⌐
ááááá LEAS╘ leas⌠ doublσ representablσ
áááááááááá LOGINFINIT┘ larges⌠ loτ argumen⌠
áááááááááá LOGLEAS╘ smalles⌠ loτ argumen⌠
áááááááááá MAXEX╨ larges⌠ characteristiπ
áááááááááá MAXEXP╟ MAXEX╨ - │ guarΣ bit≤
áááááááááá MINEX╨ smalles⌠ characteristiπ
áááááááááá MINEXP╟ MINEX╨ ½ │ guarΣ bit≤
áááááááááá PRECISIO╬ -log1░ oµ WASHOU╘
áááááááááá RTHLFIN╞ sqrt(INFINIT┘ » 2⌐
áááááááááá SMALL╪áá 1╢á¬álog2(LEAST⌐ ½ ▒
áááááááááá SYMLEAS╘ symmetriπ leas⌠ (ha≤ inverse)
áááááááááá TANHXBI╟ (sig« bit≤ ½ 2⌐ ¬ ln(2⌐ » ▓
áááááááááá WASHOU╘ 1.░ ½ (° ╝ WASHOUT⌐ ╜ 1.░
.uj1
ááááámathcons.há als∩ contain≤ thσ followinτá machine-independent ì
áááááconstants:
.uj0
áááááááááá CBRTFOU╥ cubσ roo⌠ oµ ┤
áááááááááá CBRTTW╧ cubσ roo⌠ oµ ▓
áááááááááá FADEOU╘áá Taylo≥áserie≤áfadeout term
áááááááááá FOURTHLOG▓ log(2)/┤
áááááááááá HALFLOG2σ log2(e)/▓
áááááááááá INVP╔ ▒ » pΘ
áááááááááá LOG▓ loτ oµ ▓ basσ σ
áááááááááá LOG2σ loτ oµ σ basσ ▓
áááááááááá LOGe1 loτ oµ 1░ basσ σ
áááááááááá LOG10e loτ oµ σ basσ 1░
áááááááááá LOG10tw∩ loτ oµ ▓ basσ 1░
áááááááááá MAXANGL┼ int(pΘ ¬ 225⌐
áááááááááá P╔ pΘ
áááááááááá PIover▓ pΘ » ▓
áááááááááá PIover│ pΘ » │
áááááááááá PIover┤ pΘ » ┤
áááááááááá PIover╢ pΘ » ╢
áááááááááá ROOTHAL╞ squarσ roo⌠ oµ 1/▓
áááááááááá ROOTTW╧ squarσ roo⌠ oµ ▓
áááááááááá SQRT│ sqrt(3⌐ èáááááááááá SQRT3m▒ááááá sqrt(3⌐á- ▒
áááááááááá TWOLOG2σ ▓ ¬ log2(e⌐
áááááááááá TWOmSQRT│ ▓ - sqrt(3⌐
áááááááááá TWOoverP╔ ▓ » pΘ
.uj1
.paè.hemathtyp.h mathtyp.h
Header File to Declare Math Functions
NAME
ááááámathtyp.h
SYNOPSIS
ááááá#include <mathtyp.h>
DESCRIPTION
áááááThi≤á contain≤á typσ declaration≤ whicΦ definσ thσ type≤á oµ ì
áááááal∞á doubleá matΦ function≤ iεá thi≤á library«á Usinτá thi≤ ì
áááááheade≥á delete≤ thσ necessit∙ t∩ declarσ eacΦ matΦá functioε ì
áááááseparatel∙ iε use≥ programs. Included are:
ááááá acos cotan fmin modf sgn
ááááá asin erf frexp ntail simpson
ááááá atan erfc hypot nprob sin
ááááá atan2 exp inverf pow sinh
ááááá atof fabs inverfc randexp sqrt
ááááá cbrt fint ldexp randnorm tan
ááááá ceil floor log random tanh
ááááá cos frac log10 ratfun
ááááá cosh fmax log2 round
.paè.hescrnio.h scrnio.h
Screen Function Data File
NAME
áááááscrnio.h
SYNOPSIS
ááááá#include <scrnio.h>
DESCRIPTION
áááááscrnio.héá i≤á thσ datß filσ whicΦ declare≤ al∞á globa∞á datß ì
ááááánecessar∙á fo≥ thσ usσ oµ thesσ termina∞ displa∙á functions« ì
áááááI⌠ contain≤ thσ value≤ oµ thσ followinτ constants:
ááááááááá ALT_SCRN[7] áááááááalternatσ intensit∙ on
ááááááááááBKCURSOR[9] cursor back
ááááááááá CB4R ááááááááááááááboolean║ columε beforσ row?
ááááááááá CLEARSCREEN[9] ááááclea≥ screeε anΣ homσ cursor
ááááááááá COFFSET ááááááááááácolumε valuσ offset
ááááááááááDNCURSOR[9] cursor down
ááááááááá EREOLN[7] áá áááááááerasσ t∩ end-of-line
ááááááááá EREOPG[9] á áááááááerasσ t∩ enΣ oµ page
ááááááááááFWCURSOR[9] cursor forward
ááááááááá HEIGHT áááááááááááááline≤ pe≥ screen
ááááááááá HOMER[9] ááááááááááhomσ thσ cursor
ááááááááá LEADIN[9] áááááááááácurso≥ lead-iε sequence
ááááááááá LINDELETE[7] ááááááádeletσ line
ááááááááá LININSERT[9] ááááááinser⌠ line
ááááááááá NORM_SCRN[7] áááááánorma∞ intensit∙ on
ááááááááááRCSEPARATOR[5] áááárow-columε separator
ááááááááááRCENDER[5] áááááááálead-iε termination
ááááááááááROFFSET áááááááááááro≈ valuσ offset
ááááááááááSCRNINI[9] áááááááááinitializσ terminal
ááááááááááSCRNUNI[9] ááááááááun-initializσ terminal
ááááááááááSCRNWRAP áááááááááááboolean║ screeε wrap-around?è
ááááááááááTERMINAL[20] áááááánamσ oµ terminal
ááááááááááUPCURSOR[9] cursor up
ááááááááááUSELAST áááááááááááboolean║ usσ las⌠ screeε character?
ááááááááááWIDTH áááááááááááááácolumn≤ pe≥ screen
ááááááááááXLT2ASCII áááááááááboolean║ translatσ t∩ ASCII?
SEE ALSO
áááááscrnioéá in Section 4.
.paè.hestdio.h stdio.h
Standard Buffered Input/Output Definition Package
NAME
ááááástdio.h
SYNOPSIS
ááááá#include <stdio.h>
áááááFILE *stdin;
áááááFILE *stdout;
áááááFILE *stderr;
DESCRIPTION
áááááIεá thσ user-leve∞ frameworkinτ scheme¼á thσ function≤á getcé ì
áááááanΣá putcé handlσ character≤ iε botΦ buffereΣ anΣá unbuffereΣ ì
ááááámodes«á Thσá highe≥á leve∞á routine≤á gets¼á fgets¼á scanf¼ ì
áááááfscanf¼á fread¼ puts¼ fputs¼ printf¼ fprintf¼ fwriteé al∞ usσ ì
ááááágetcé anΣ putc╗ the∙ caε bσ freel∙ intermixed.
ááááá┴ filσ witΦ associateΣ bufferinτ i≤ calleΣ ß stream¼á anΣ i≤ ì
ááááádeclareΣá t∩á bσ ß pointe≥ t∩ ß defineΣá typσá FILE«á fopen ì
ááááácreate≤ certaiε descriptivσ datß fo≥ ß streaφ anΣ return≤á ß ì
ááááápointe≥ t∩ designatσ thσ streaφ iε al∞ furthe≥ transactions« ì
áááááTherσ arσ threσ normall∙ opeε stream≤ witΦ constan⌠ pointer≤ ì
ááááádeclareΣá iεá thσá includσá filσá anΣá associateΣá witΦá thσ ì
ááááástandard open files:
ááááá stdin standard input file
ááááá stdout standard output file
ááááá stderr standard error file
áááááSTDIN¼á STDOUTé anΣ STDERRé arσ thσ filσ descriptor≤ tha⌠ reaΣ ì
áááááand write recognize as standard preopened files.
áááááA constant 'pointer' NULL (0) designates no stream at all.
áááááAε intege≥ constan⌠ EO╞ (-1⌐ i≤ returneΣ upoε enΣ oµ filσ o≥ ì
áááááerror by integer functions that deal with streams.
áááááMAXSTREAMéá i≤á thσ maximuφ numbe≥ oµá input/outpu⌠á streams, ì
áááááand IObuffs is the file stream table.
áááááAn∙ routinσ tha⌠ use≤ thσ standarΣ input/outpu⌠ packagσ mus⌠ ì
áááááincludσáá thσá heade≥á filσá <stdio.h╛á oµá pertinen⌠á macr∩ ì
ááááádefinitions«
áááááBuffered Input/Output Definitions:
áááááááááááBUFSIZ ááááááástreaφ buffe≥ size
áááááááááááCRINSUP áááááádefineΣá wheε '\rº iε inpu⌠ tex⌠ mus⌠ bσ èááááááááááááááááááááá ááásuppressed
áááááááááááCROUTADDáá defineΣ wheε '\rº mus⌠ accompan∙ '\nº iε ì
ááááááááááááááááááááááááátext output
áááááááááááCURPOS ááááááfilσ positioε designator (lseek)
áááááááááááFILEND ááááááfilσ enΣ positioε designator (lseek)
áááááááááááMAXLINE ááááámaximuφ stdi∩ inpu⌠ linσ width
áááááááááááORIGIN ááááááábeginninτ oµ filσ designator (lseek)
áááááááááááPMODE áááááááfopen(⌐ protectioε modσ (fo≥ UNIX)
áááááááááááSYS_EOF ááááásystem end-of-file character (if any)
áááááááááááTABSTOP stdout tabstop width
ááááááááááá_RDONLY áááááfilσ opeε fo≥ reaΣ only
ááááááááááá_RDWRIT áááááfilσ opeε fo≥ read/writσ access
ááááááááááá_WRONLY áááááfilσ opeε fo≥ writσ only
áááááFile Stream _flags bit masks:
ááááááááááá_ALLBUF ááááábit set (1⌐ wheε buffe≥ i≤ allocated
ááááááááááá_BUSY áááááábit set (1⌐ wheε ß FIL┼ i≤ open
ááááááááááá_DIRTY áááááábit set (1⌐ wheε buffe≥ i≤ unflushed
ááááááááááá_EOF áááááááábit set (1⌐ iµ streaφ EO╞ i≤ reached
ááááááááááá_IOERR áááááábit set (1⌐ iµ i/∩ streaφ error
áááááFile Stream Data Structure Definition, FILE *fp:
áááááááááááBUFFER _bend point≤ onσ cha≥ pas⌠ las⌠ iε buffer
áááááááááááBUFFER _bptr áácurren⌠ pointe≥ iε streaφ buffer
áááááááááááBUFFER _buff addres≤ oµ streaφ buffer
áááááááááááunsigned _buflen lengtΦ oµ buffer
áááááááááááchar _bytbuf singlσ bytσ fo≥ unbuffereΣ streams
áááááááááááTBITS _flags opeε mode¼ error¼ eof¼ busy¼ etc.
áááááááááááutiny _unit áfilσ descripto≥ returneΣ b∙ open
è
áááááStandard I/O Macros:
áááááááááááclearerr(fp) ((fp)->_flag≤ &╜ ~(_IOERR|_EOF)
ááááááááááágetchar() ááágetca(stdin)
áááááááááááfeof(fp) áááá(((fp)->_flag≤ &_EOF⌐ !╜ 0)
áááááááááááferror(fp) ááá(((fp)->_flag≤ &_IOERR⌐ !╜ 0)
áááááááááááfileno(fp) áá((fp)->_unit)
áááááááááááputchar(c) áááputca(c¼ stdout)
eputc(c) putca(c, stderr)
SEE ALSO
áááááopen, close, read, write
DIAGNOSTICS
áááááThσ valuσ EO╞ i≤ returneΣ uniforml∙ t∩ indicatσ tha⌠ ßá FIL┼ ì
ááááápointe≥ ha≤ no⌠ beeε initializeΣ witΦ fopen¼á inpu⌠ (output⌐ ì
áááááha≤á beeε attempteΣ oε aε outpu⌠ (input⌐ stream¼á o≥ ßá FIL┼ ì
ááááápointe≥á designate≤ corrup⌠ o≥ otherwisσ unintelligiblσ FIL┼ ì
ááááádata.
.paè.hestdtyp.h stdtyp.h
Standard Defined-Types File
NAME
ááááástdtyp.h
SYNOPSIS
ááááá#include <stdtyp.h>
DESCRIPTION
áááááSevera∞á bug≤á iε ├ program≤ oµ aε earlie≥á generatioεá werσ ì
áááááfounΣá b∙ rigorousl∙ type-defininτ anΣá consistency-checkinτ ì
ááááásucΦá interface≤ a≤ functioεá arguments¼á functioεá returneΣ ì
ááááávalues¼ááá anΣáá structurσáá definitions«áá Thi≤áá semantiπ ì
áááááreadabilityá argumen⌠á i≤á thσ onl∙á justificatioεá fo≥á thσ ì
ááááádefined-type≤ LBITS¼ BITS¼ TBITS¼ METACHAR¼ BOOL, anΣ TBOOL¼ ì
ááááábecausσáá thσá underlyinτá type≤á arσá no⌠á subjec⌠á t∩á an∙ ì
áááááportability problems for their restricted usage.
áááááThσá casσá i≤á differen⌠á fo≥ thσá type≤á tiny¼á anΣá utiny« ì
áááááPortabilit∙ problem≤ (botΦ machinσ anΣ compiler⌐ arσ ßá maiε ì
áááááreasoεá fo≥ thesσ distinctions«á Differen⌠ version≤ oµá thσ ì
ááááácompile≥á havσá introduceΣá datß type≤á fo≥á unsigneΣá char¼ ì
áááááunsigneΣá short,éá anΣá eveε unsigneΣá long«á AnΣá differen⌠ ì
ááááámachine≤ ma∙ trea⌠ thσ typσ charé a≤ signeΣ o≥ unsigned«á Iµ ì
áááááprogram≤á arσ writteε witΦ thesσ ra≈ ├ types¼á the∙ mus⌠á bσ ì
áááááediteΣ b∙ hanΣ beforσ portinτ t∩ anothe≥ compile≥ tha⌠á doe≤ ì
áááááno⌠ suppor⌠ ß ne≈ type«á However¼ iµ ß se⌠ oµ defined-type≤ ì
ááááái≤ consistentl∙ used¼á theε thσ defined-typσ caε bσ targeteΣ ì
ááááát∩ thσ ne≈ typσ wheε i⌠ exists¼á anΣ bσ targeteΣ t∩ aε olde≥ ì
ááááábasσá typσ otherwise«á Fo≥ truσ portability¼á sucΦ defined-ì
ááááátype≤ mus⌠ bσ augmenteΣ witΦ rvaluσ macros:
.uj0
ááááá TINY(n) produce≤á ß signeΣ valuσ froφ ╕ o≥á morσ ì
áááááááááááááááááááááááábit≤ oµ n.
ááááá UTINY(n) produce≤á aε unsigneΣ valuσ froφ ╕á bit≤ ì
áááááááááááááááááááááááá(o≥ more⌐ oµ n.
áááááPseudo Storage Classes:
ááááá FASTáááááááááááequivalen⌠ t∩ register.
ááááááááááGLOBAL equivalent to extern.
ááááááááááLOCAL equivalent to static.
áááááType definitions:
áááááááááátin∙ an 8 bit (or larger) signed integer.
ááááááááááutinyá aε ╕ bi⌠ (o≥ larger⌐ unsigneΣá intege≥ ì
áááááááááááááááááááááááááuseΣ fo≥ ß quantity.
èááááá TBITS aεá ╕á bi⌠á (o≥ larger⌐á useΣá fo≥á bi⌠ ì
ááááááááááááááááááááááááámanipulation.
ááááá TBOOL aε ╕ bi⌠ (o≥ larger⌐ integer¼á bu⌠ useΣ ì
áááááááááááááááááááááááááfo≥ boolean.
ááááá TEXT aε ╕ bi⌠ (o≥ larger⌐ iteφ useΣ onl∙ fo≥ ì
ááááááááááááááááááááááááácharacters.
ááááá BOOL integer, but used for boolean.
ááááá LBITS long, but only for bit manipulation.
ááááá BITS ßá 1╢ bi⌠ (o≥ larger⌐ intege≥ onl∙á fo≥ ì
ááááááááááááááááááááááááábi⌠ manipulation.
ááááá METACHAR ßáá 1╢áá bi⌠á (o≥áá larger⌐áá augmenteΣ ì
ááááááááááááááááááááááááácharacte≥ (ma∙ bσ -1).
ááááá VOID a function that returns no value.
ááááá STRING a string of TEXT, (char *).
ááááá BUFFE╥á ßá characte≥ arra∙ useΣá a≤á ßá buffer¼ ì
ááááá (cha≥ *).
ááááá ALIG╬á Storagσ allocatioε worΣ alignmen⌠á datß ì
ááááá structure.
ááááááááááHEADER Storage allocation header.
.uj1
áááááExcep⌠á fo≥ tiny,é anΣ utiny¼á defined-type≤ arσ writteεá iε ì
áááááuppe≥ casσ t∩ emphasizσ thei≥ definitioε iε ß heade≥ file.
áááááThi≤á particula≥ heade≥ filσ ha≤ beeε adapteΣ froφ thσ Plum-ì
áááááHal∞ StandarΣ (Referencσ 4)«á Thi≤ filσ mus⌠ bσá customizeΣ ì
ááááát∩á thσ intendeΣ compiler/machinσ environment¼á a≤ describeΣ ì
áááááin the reference and Section 5 of this manual.
.he
.pa o
(Intentionally left blank)
.PAè.PN 1
.FO 3-#
3. S Y S T E M C A L L S
Thi≤ sectioε describe≤ al∞ thσ entrie≤ int∩ thσ systeφ assumeΣ b∙ ì
thσá portablσá ├á library«á Mos⌠ oµ thesσ call≤á havσá aεá erro≥ ì
return«áá Aεá erro≥á conditioεá i≤á indicateΣá b∙á aεá otherwisσ ì
impossiblσá returneΣá value«á Almos⌠á alway≤á thi≤á i≤á -1╗á thσ ì
individua∞ section≤ specif∙ thσ details« Aε erro≥ numbe≥ i≤ als∩ ì
madσá availablσá iε thσ externa∞ variablσ errno«á errnoéá i≤á no⌠ ì
cleareΣ oε successfu∞ calls¼ s∩ i⌠ shoulΣ bσ testeΣ onl∙ afte≥ aε ì
erro≥ ha≤ occurred.
The system calls assumed are:
ááááá close read
ááááá creat rename
ááááá exit sbrk
ááááá lseek unlink
ááááá open write
Sourcσ codσ fo≥ thesσ function≤ i≤ no⌠ containeΣ iε thσá portablσ ì
library╗á thesσá function≤á expecteΣá t∩ bσ availablσá iεá thσá ├ ì
language system interface supported by the vendor.
.paè.heclose close
Closσ ß File¼ Operating ╙ystem Interface
NAME
áááááclose
SYNOPSIS
áááááint close(fildes)
áááááint fildes;
DESCRIPTION
ááááá┴áá filσá descipto≥á i≤á aεá intege≥á useΣáá ináá subsequen⌠ ì
áááááinvocation≤á oµá othe≥ input-outpu⌠ function≤ oεá thσá file« ì
áááááGiveεá ßá filσ descripto≥ sucΦ a≤ returneΣ froφ aεá openéá o≥ ì
ááááácreat¼á closeéá close≤ thσ associateΣ file«á ┴ closσ oµá al∞ ì
áááááfile≤á i≤ automatiπ oε exit¼á bu⌠ sincσ therσ i≤ ß limi⌠á oε ì
áááááthσ numbe≥ oµ opeε file≤ pe≥ process¼ closeé i≤ necessar∙ fo≥ ì
áááááprogram≤ whicΦ dea∞ witΦ man∙ files.
SEE ALSO
áááááopen, write, creat, fclose
DIAGNOSTICS
ááááácloseéá return≤ ß zer∩ iµ ß filσ i≤ closed╗á EOF i≤á returneΣ ì
áááááfo≥ aε unknowε filσ descriptor.
.paè.hecreat creat
Creatσ ß File¼ Operating ╙ystem Interface
NAME
ááááácrea⌠
SYNOPSIS
áááááint creat(name, mode)
áááááSTRING name;
áááááint mode;
DESCRIPTION
ááááácreat create≤ ß ne≈ filσ o≥ prepare≤ t∩ rewritσ aεá existinτ ì
áááááfilσ calleΣ name¼ giveε a≤ thσ addres≤ oµ ß null-terminatinτ ì
ááááástring«á Iµá thσá filσá diΣ no⌠á exist¼á i⌠á i≤á giveεá thσ ì
áááááprescribeΣ mode«
áááááIµ thσ filσ diΣ exist¼á it≤ modσ anΣ owne≥ remaiεá unchangeΣ ì
ááááábut it is truncated to zero length.
áááááThσ filσ i≤ als∩ openeΣ fo≥ writing¼ anΣ it≤ filσ descripto≥ ì
áááááis returned.
áááááThσá modeéá giveε i≤ arbitrary╗á i⌠ neeΣ no⌠á allo≈á writing« ì
áááááThi≤á featurσá i≤á system-dependent¼áá originall∙á useΣáá b∙ ì
áááááprogram≤á whicΦá dea∞ witΦ temporar∙ file≤ oµá fixeΣá names« ì
áááááThσ creatioε wa≤ donσ a≤ ß modσ tha⌠ forbid≤ writing«á Theε ì
áááááiµ ß seconΣ instancσ oµ thσ prograφ werσ t∩ attemp⌠ ß creat¼ ì
áááááaεá erro≥ i≤ returneΣ anΣ thσ prograφ know≤ tha⌠ thσ namσ i≤ ì
áááááunusablσá fo≥á thσ moment«á However¼á thi≤ featurσá i≤á no⌠ ì
áááááguaranteeΣ iε thσ portablσ library¼ anΣ shoulΣ no⌠ bσ relieΣ ì
áááááupon.
SEE ALSO
áááááopen, write, close, stdio.h
DIAGNOSTICS
áááááFo≥ creat¼á thσ valuσ EOF i≤ returneΣ if║ ß needeΣ director∙ ì
ááááái≤ no⌠ searchable╗ thσ filσ doe≤ no⌠ exis⌠ anΣ thσ director∙ ì
áááááiε whicΦ i⌠ i≤ t∩ bσ createΣ i≤ no⌠ writable╗á thσ filσ doe≤ ì
áááááexis⌠ anΣ i≤ unwritable╗á thσ filσ i≤ ß directory╗ therσ arσ ì
áááááalread∙ to∩ man∙ file≤ open.
.paè.heexit exit
Terminate Process
NAME
áááááexit, _exit
SYNOPSIS
áááááVOID exit(status)
áááááint status;
áááááVOID _exit(status)
áááááint status;
DESCRIPTION
áááááexité i≤ thσ norma∞ mean≤ oµ terminatinτ ß process«á exité i≤ ì
ááááásupposeΣ t∩ closσ al∞ thσ process'≤ files╗á however¼á i⌠ ma∙ ì
áááááno⌠á closσ buffereΣ stream≤ oµ thσá portablσá library«á Fo≥ ì
áááááthi≤á purpose¼á thσá portablσ functioε fcloseé i≤á available« ì
ááááástatusé ma∙ bσ availablσ t∩ whateve≥ proces≤ calleΣ thi≤ one¼ ì
ááááádependinτ oε thσ system¼á s∩ thσ succes≤ o≥ failurσ oµá thσ ì
áááááprograφá caε bσ testeΣ b∙ anothe≥ prograφ tha⌠ use≤ thi≤ onσ ì
áááááa≤ ß sub-process.
áááááThis call can never return.
áááááThσá ├á functioε exit ma∙ causσ cleanu≡ action≤á beforσá thσ ì
áááááfina∞á 'sy≤á exit'«á Thσá functioεá _exitá circumvent≤á al∞ ì
ááááácleanup.
SEE ALSO
áááááfclose, redirbuf
.pa è.helseek lseek
Move Read/Write Pointer
NAME
ááááálseek
SYNOPSIS
ááááálong lseek(fildes, offset, whence)
áááááint fildes;
ááááálong offset;
áááááint whence;
DESCRIPTION
áááááThσá filσá descripto≥ refer≤ t∩ ß filσ opeε fo≥á readinτá o≥ ì
áááááwriting« Thσ reaΣ (resp« write⌐ pointe≥ fo≥ thσ filσ i≤ se⌠ ì
áááááas follows:
áááááááááááIµ whenceé i≤ ORIGI╬ (0)¼á thσ pointe≥ i≤ se⌠ t∩ offseté ì
ááááááááááábytes.
áááááááááááIµá whenceé i≤ CURPO╙ (1)¼á thσ pointe≥ i≤ se⌠á t∩á it≤ ì
ááááááááááácurren⌠ locatioε plu≤ offset.
áááááááááááIµá whenceéá i≤ FILEN─ (2)¼á thσ pointe≥ i≤ se⌠ t∩á thσ ì
ááááááááááásizσ oµ thσ filσ plu≤ offset.
áááááThe returned value is the resulting pointer location.
áááááSeekinτ fa≥ beyonΣ thσ enΣ oµ ß file¼á theε writing¼ create≤ ì
áááááß ga≡ o≥ hole¼ whicΦ occupie≤ n∩ physica∞ spacσ anΣ read≤ a≤ ì
ááááázeros.
SEE ALSO
áááááopen, creat, fseek, stdio.h
DIAGNOSTICS
áááááEOFé i≤ returneΣ fo≥ aε undefineΣ filσ descriptor¼ o≥ seeδ t∩ ì
áááááß positioε beforσ thσ beginninτ oµ file.
.paè.heopen open
Open for Reading or Writing
NAME
áááááopen
SYNOPSIS
áááááint open(name, flag, mode)
áááááSTRING name;
áááááint flag, mode;
DESCRIPTION
áááááopenéá open≤ thσ filσ nameé fo≥ readinτ (iµ flagéá i≤á _RDONLY¼ ì
ááááá0)¼á writinτ (iµ flagé i≤ _WRONLY¼ 1⌐ o≥ fo≥ botΦ readinτ anΣ ì
áááááwritinτ (iµ flagé i≤ _RDWRIT¼á 2)«á nameé i≤ thσ addres≤ oµ ß ì
ááááástrinτáá oµá ASCI╔á character≤á representinτá thσá filename¼ ì
áááááterminateΣ b∙ ß NULLé character.
áááááThσá filσá i≤á positioneΣ a⌠ thσ beginninτá (bytσá 0)«á Thσ ì
áááááreturneΣá filσ descripto≥ mus⌠ bσ useΣ fo≥ subsequen⌠á call≤ ì
áááááfor other input-output functions on the file.
áááááThσ modeé i≤ arbitrary¼á anΣ i≤ unuseΣ fo≥ thσ flaτ value≤ oµ ì
áááááthσá portablσ library«á Thσ presencσ o≥ absencσ oµ thσ modeé ì
áááááargumen⌠ ma∙ requirσ module≤ callinτ thσ opené functioε t∩ bσ ì
ááááámodifieΣá t∩á conforφá witΦ thσá requirement≤á oµá thσá hos⌠ ì
ááááácomputer.
SEE ALSO
ááááácreat, read, write, close, fopen, stdio.h
DIAGNOSTICS
áááááThσ valuσ EOFé i≤ returneΣ iµ thσ filσ doe≤ no⌠ exist¼ iµ onσ ì
áááááoµáá thσáá necessar∙á directorie≤á doe≤á no⌠á exis⌠á o≥áá i≤ ì
áááááunreadable¼ iµ thσ filσ i≤ no⌠ readablσ (resp« writable)¼ o≥ ì
áááááiµ to∩ man∙ file≤ arσ open.
.paè.heread read
Read from File
NAME
áááááread
SYNOPSIS
áááááint read(fildes, buffer, nbytes)
áááááint fildes, nbytes;
áááááBUFFER buffer;
DESCRIPTION
ááááá┴áá filσá descripto≥á i≤á thσá in⌠á valuσá returneΣá froφá ß ì
ááááásuccessfu∞ open o≥ creat.é bufferé i≤ thσ locatioε oµá nbytesé ì
ááááácontiguou≤ byte≤ int∩ whicΦ thσ inpu⌠ wil∞ bσ placed« I⌠ i≤ ì
áááááno⌠á guaranteeΣá tha⌠á al∞ nbytesé byte≤ wil∞á bσá read╗á fo≥ ì
áááááexample¼ iµ thσ filσ refer≤ t∩ ß typewrite≥ a⌠ mos⌠ onσ linσ ì
áááááwil∞ bσ returned«á Iε an∙ event¼á thσ numbe≥ oµá character≤ ì
áááááreaΣ i≤ returned.
áááááIµá thσá returneΣ valuσ i≤ zero¼á theε end-of-filσ ha≤á beeε ì
áááááreached.
SEE ALSO
áááááopen, creat
DIAGNOSTICS
áááááA≤ mentioned¼á NUL╠ (0⌐ i≤ returneΣ wheε thσ enΣ oµ thσ filσ ì
áááááha≤á beeε reached«á Iµ thσ reaΣ wa≤ otherwisσá unsuccessfu∞ ì
áááááthσá returε valuσ i≤ EOF«á Man∙ condition≤ caε generatσá aε ì
áááááerror║ physica∞ I/╧ errors¼ baΣ buffe≥ address¼ preposterou≤ ì
ááááánbytes¼ filσ descripto≥ no⌠ tha⌠ oµ aε inpu⌠ file«
BUGS
áááááSomσá system≤ ma∙ contaiε interna∞ bufferinτ t∩ makσ usσá oµ ì
ááááátermina∞á linσ editinτ feature≤ oµ somσá operatinτá systems« ì
áááááTherefore¼á read(0¼á buffer¼ 1)é ma∙ no⌠ responΣ properl∙ fo≥ ì
ááááácharacter-by-character inputs.
.paè.herename rename
Rename a File
NAME
ááááárename
SYNOPSIS
áááááint rename(old¼ new)
áááááSTRIN╟ old¼ new;
DESCRIPTION
ááááárename changes the name of a file from old to new.
DIAGNOSTICS
ááááárename returns the value NULL if successful, and EOF is not.
.paè.hesbrk sbrk
Change Core Allocation
NAME
ááááásbrk
SYNOPSIS
áááááSTRING sbrk(incr)
áááááint incr;
DESCRIPTION
áááááIεá sbrk¼á incr morσ byte≤ arσ addeΣ t∩ thσá program'≤á datß ì
áááááspacσá anΣ ß pointe≥ t∩ thσ star⌠ oµ thσ lowes⌠ locatioε no⌠ ì
áááááused by program (called the break) is returned.
SEE ALSO
ááááámalloc, free
DIAGNOSTICS
áááááAεá EOFé (-1⌐ i≤ returneΣ iµ thσ prograφ request≤ morσ memor∙ ì
áááááthaε thσ systeφ limi⌠ o≥ iµ othe≥ operatinτ systeφá interna∞ ì
ááááácontraints are violated.
BUGS
áááááSettinτá thσ breaδ iε thσ rangσ 017770▒ t∩ 017777╖á (oεá thσ ì
áááááPDP11) is the same as setting it to zero.
.paè.heunlink unlink
Remove Directory Entry
NAME
áááááunlink
SYNOPSIS
áááááint unlink(name)
áááááSTRING name;
DESCRIPTION
ááááánameé point≤ t∩ ß null-terminateΣ string« unlinké remove≤ thσ ì
áááááentr∙á fo≥á thσ filσ identifieΣ b∙ nameé froφ it≤á directory« ì
áááááIµ thi≤ entr∙ wa≤ thσ las⌠ linδ t∩ thσ file¼ thσ content≤ oµ ì
áááááthσ filσ arσ freeΣ anΣ thσ filσ i≤ destroyed«á If¼ however¼ ì
áááááthσ filσ wa≤ opeε iε an∙ process¼á thσ actua∞ destructioε i≤ ì
ááááádelayeΣ unti∞ i⌠ i≤ closed¼á eveε thougΦ thσ director∙ entr∙ ì
áááááha≤ disappeared.
DIAGNOSTICS
áááááNULLéá (0⌐ i≤ normall∙ returned╗á EOFé indicate≤ tha⌠ thσ filσ ì
ááááádoe≤á no⌠ exist¼á tha⌠ it≤ director∙ canno⌠ bσá written¼á o≥ ì
ááááátha⌠ thσ filσ contain≤ purσ procedurσ tex⌠ tha⌠ i≤ currentl∙ ì
áááááiεá use«á Writσá permissioεá i≤ no⌠ requireΣá oεá thσá filσ ì
áááááitself«á I⌠á i≤ als∩ illega∞ t∩ unlinδ ß director∙á (excep⌠ ì
áááááfo≥ thσ super-user, in UNIX).
.paè.hewrite write
Write on a File
NAME
áááááwrite
SYNOPSIS
áááááint write(fildes, buffer, nbytes)
áááááint fildes, nbytes;
áááááBUFFER buffer;
DESCRIPTION
ááááá┴á filσ descripto≥ i≤ aε intege≥ returneΣ froφ ßá successfu∞ ì
áááááopeε o≥ creat.
ááááábufferé i≤ thσ addres≤ oµ nbytesé contiguou≤ bytes¼á whicΦ arσ ì
áááááwritteεá oεá thσá outpu⌠ file«á Thσá numbe≥á oµá character≤ ì
áááááactuall∙ writteε i≤ returned«á I⌠ shoulΣ bσ regardeΣ a≤á aε ì
áááááerro≥ iµ the returned value i≤ no⌠ thσ samσ a≤ nbytes.
áááááWrite≤á oµá ßá certaiε sizσ ma∙ bσ morσá efficien⌠á oεá somσ ì
ááááámachines, depending on implementation particulars.
SEE ALSO
ááááácreat, open
DIAGNOSTICS
áááááReturn≤á EOFé oε error║á baΣ descriptor¼á buffe≥ address¼á o≥ ì
ááááácount╗ physica∞ I/╧ errors.
.he
.pa o
(Intentionally left blank)
.PAè.PN 1
.FO 4-#
4. F U N C T I O N L I B R A R Y
Thi≤á chapte≥á describe≤á function≤ containeΣ iε thσá portablσá ├ ì
function library.
Function≤ iε thσ matΦ librar∙ ma∙ returε conventiona∞ value≤ wheε ì
thσá functioεá i≤ undefineΣ fo≥ thσ giveε argument≤ o≥á wheεá thσ ì
valuσ i≤ no⌠ representable« Iε thesσ case≤ thσ externa∞ variablσ ì
errnoé i≤ se⌠ t∩ thσ valuσ EDOMé o≥ ERANGE« Thσ value≤ oµ EDOMé anΣ ì
ERANGE are defined in the include file <errno.h>.
Man∙á entrie≤á contaiεá morσá thaεá onσá function╗á however¼á al∞ ì
functioε name≤ (anΣ shor⌠ definition¼ iµ differen⌠ froφ name⌐ arσ ì
includeΣ iε thσ inde° fo≥ eas∙ access.
Becausσá oµá filσ spacσ limitation≤ iεá somσá hos⌠á systems¼á thσ ì
conglomeratioεá oµá function≤ int∩ file≤ i≤ expecteΣ t∩ bσá host-ì
dependent╗á and¼á therefore¼á no⌠ covereΣ here« ┴ lis⌠ oµ sourcσ ì
files and the functions they contain is given in Section 5.
.paè.heabs abs
Absolute Values
NAME
áááááabs, fabs, labs
SYNOPSIS
áááááint abs(i)
áááááint i;
ááááádouble fabs(x)
ááááádouble x;
ááááálong labs(n)
ááááálong n;
DESCRIPTION
áááááabsá i≤á ßá functioεá returninτ thσ absolutσá valuσá oµá it≤ ì
áááááintege≥ operand.
áááááABSá i≤ thσ macr∩ iε heade≥ filσ defs.h¼á whicΦ perform≤ thσ ì
ááááásamσá operatioεá a≤á thσ functioε abs¼á bu⌠á ma∙á havσá sidσ ì
áááááeffects. ABS works for all numeric types.
áááááfabs returns the absolute value |x|.
ááááálabsá return≤á thσ lonτ intege≥ absolutσ valuσ oµá it≤á lonτ ì
áááááoperand, n.
BUGS
áááááYo⌡á ge⌠á wha⌠á thσ hardwarσ give≤ oε thσá larges⌠á negativσ ì
áááááinteger.
.paèallot allot
Memory Allocation Package
NAME
áááááallot, liberate
SYNOPSIS
áááááSTRING allot(nbytes)
áááááunsigned nbytes;
áááááVOID liberate(ptr, nbytes)
áááááSTRING ptr;
áááááunsigned nbytes;
DESCRIPTION
áááááalloté anΣ liberateé providσ ß simple¼á general-purposσ memor∙ ì
áááááallocatioε package«á alloté return≤ ß pointe≥ t∩ ß blocδá oµ ì
áááááa⌠á leas⌠ nbytesé bytes«á Thσ argument≤ oµ liberateé definσ ß ì
áááááblocδá t∩á bσ madσ availablσ fo≥á furthe≥á allocation«á Thσ ì
áááááliberated block need not have been previously allotted.
áááááNeedles≤á t∩ say¼á gravσ disorde≥ wil∞ resul⌠ iµá thσá spacσ ì
áááááassigneΣá b∙á allotéá i≤ overruε o≥ iµ somσá randoφá ptréá o≥ ì
áááááoversizσ nbytesé i≤ handeΣ t∩ liberate.
áááááallotéá allocate≤á thσ firs⌠ big-enougΦ contiguou≤á reacΦá oµ ì
áááááfreσá spacσá founΣ iε ß circula≥ searcΦ froφ thσ las⌠á blocδ ì
áááááallocateΣá o≥ freed¼á coalescinτ adjacen⌠ freσ block≤ a≤á i⌠ ì
ááááásearches«á I⌠ call≤ sbrké t∩ ge⌠ morσ memor∙ froφ thσ systeφ ì
áááááwhen there is no suitable space already free.
áááááallotéá anΣá liberateé worδ mucΦ thσ samσ a≤ mallocé anΣá free« ì
áááááThσ difference≤ arσ tha⌠ mallocé anΣ freeé operatσ witΦ block≤ ì
ááááátha⌠á contaiε aε overheaΣ structure¼á anΣ freeΣ block≤á mus⌠ ì
áááááhavσá beeεá previousl∙ allocated¼á wherea≤á allotteΣá block≤ ì
ááááácontaiε n∩ sucΦ overhead¼ anΣ liberateΣ block≤ ma∙ bσ freel∙ ì
áááááaddeΣá t∩á thσ availablσ store«á Block≤á arσá allotteΣá anΣ ì
áááááliberateΣ iε unit≤ oµ sizσ sizeof(HEADER)é bytes.
DIAGNOSTICS
áááááallotéá return≤ ß NULLé pointe≥ (0⌐ iµ therσ i≤á n∩á availablσ ì
memor∙á o≥á iµ thσ operatinτ systeφ ha≤ detecteΣá corruptioε ì
áááááoutside the allotted area.
SEE ALSO
ááááámalloc, free
.paè.heatoµ atof
ASCII/Numeric Conversion
NAME
astof¼á astoi¼á astol¼á atof¼ atoi¼ atol¼ ftoa¼ itoa¼ itoab¼ ì
áááááltoa, ltoab, tobase, utoa
SYNOPSIS
STRING astof(s, val)
áSTRING s;
ááááádouble *val;
STRING astoi(s, val)
STRING s;
áááááint *val;
STRING astol(s, val)
STRING s;
ááááálong *val;
double atof(s)
STRING s;
int atoi(s)
STRING s;
long atol(s)
STRING s;
áááááSTRING ftoa(s, x, pr, mode)
áááááSTRING s;
ááááádouble x;
áááááint pr;
áááááchar mode;
áááááSTRING itoa(s, n, w)
áááááSTRING s;
áááááint n, w;
áááááSTRING itoab(s, n, w, b)
áááááSTRING s;
áááááint n, w, b;
áááááSTRING ltoa(s, n, w)
áááááSTRING s;
ááááálong n;
áááááint w;
áááááSTRING ltoab(s, n, w, b)
áááááSTRING s;
ááááálong n;
áááááint w, b;
èáááááMETACHAR tobase(ch, base)
áááááchar ch;
áááááint base;
áááááSTRING utoa(s, n, w)
áááááSTRING s;
áááááunsigned n;
áááááint w;
DESCRIPTION
áááááastof¼á astoiéá anΣ astolé conver⌠ ß strinτ pointeΣ t∩ b∙ sé t∩ ì
áááááfloating¼á integer¼á anΣá lonτá intege≥á valéá representatioε ì
ááááárespectively«á Thσá firs⌠ unrecognizeΣ characte≥á end≤á thσ ì
ááááástring«á The∙á operatσá iε thσ samσ wa∙ a≤ atof¼á atoiéá anΣ ì
áááááatol¼á excep⌠ tha⌠ the∙ storσ thσ valuσ iε val¼ anΣ returε ß ì
ááááápointe≥ t∩ thσ nex⌠ unuseΣ character.
áááááatof¼á atoi¼á anΣ atolé function≤ conver⌠ ß strinτ pointeΣ t∩ ì
áááááb∙ sé t∩ floating¼á integer¼ anΣ lonτ intege≥ representation¼ ì
ááááárespectively«á Thσá firs⌠ unrecognizeΣ characte≥á end≤á thσ ì
áááááconversion.
áááááatof recognize≤ aε optiona∞ strinτ oµ tab≤ anΣ spaces¼á theε ì
áááááaεá optiona∞á sign¼á theεá ßá strinτá oµá digit≤á optionall∙ ì
ááááácontaininτá ßá decima∞ point¼á theε aε optiona∞ 'eºá o≥á 'Eº ì
áááááfolloweΣ b∙ aε optionall∙ signeΣ integer.
áááááatoiá anΣá atolá recognizσ aε optiona∞ strinτá oµá tab≤á anΣ ì
áááááspaces¼á theε aε optiona∞ sign¼ theε ß strinτ oµ digits« Iµ ì
áááááthσ strinτ begin≤ iε '0x'¼á theε thσ numbe≥ i≤ assumeΣ t∩ bσ ì
áááááhexadecimal╗á otherwise¼á iµá thσ leadinτ digi⌠ i≤ '0'¼á thσ ì
ááááástring is interpreted as an octal.
áááááftoaéá convert≤ xé t∩ aε ASCI╔ strinτ sé witΦ precisioεá préá iε ì
ááááámodeéá 'e'¼á 'f',é o≥ 'g'é format«á Thi≤ functioε return≤á thσ ì
ááááápointe≥ t∩ s«á Thσ modeé argumen⌠ ma∙ als∩ bσ 0¼á 1é o≥ 2éá t∩ ì
ááááádesignate 'e', 'f', or 'g', respectively.
áááááitoaé convert≤ aε intege≥ t∩ ASCII«á I⌠ return≤ ß pointe≥ t∩ ì
ááááás¼ whicΦ contain≤ thσ ASCI╔ valuσ oµ né t∩ minimuφ widtΦ |w|¼ ì
ááááá0-filleΣá iµ w<0¼á elsσ space-filled«á Thi≤ functioεá i≤á ß ì
ááááámodifieΣá versioεá oµ itoa(⌐ founΣ iε Kernighaε anΣá Ritchiσ ì
ááááá(seσ Referencσ 2¼á pp«á 60)¼ witΦ modification≤ a≤ suggesteΣ ì
áááááiεá exercise≤á 3-│ anΣ 3-5¼á anΣ witΦá returneΣá pointe≥á t∩ ì
áááááresul⌠ string.
áááááitoabéá convert≤á aεá intege≥ né t∩ ßá minimuφá oµá |w|éá asciΘ ì
ááááácharacters¼á basσá b«á I⌠á return≤ ß pointe≥á t∩á s¼á whicΦ ì
ááááácontain≤á thσá ASCI╔ value«á Iµ wé i≤ les≤ thaε zero¼á séá i≤ ì
ááááázero-filled╗ otherwise¼ i⌠ i≤ space-filled.
áááááltoaéá convert≤ ß lonτ né t∩ ß minimuφ oµ |w|é ASCI╔ character≤ ì
ááááá(0-filleΣ iµ wé ╝ 0¼á anΣ space-filleΣ otherwise)¼á anΣá put≤ ì
ááááátheφá iεá s¼á returninτ thσ pointe≥ t∩ s«á Thi≤ i≤á als∩á ß ì
ááááámodifieΣá versioε oµ itoa(⌐ froφ Kernigaε anΣ Ritchie¼á witΦ ìèááááámodification≤ a≤ suggesteΣ iε exercise≤ 3-│ anΣ 3-5¼ fo≥ usσ ì
áááááwitΦ thσ lonτ datß type« (seσ Referencσ 2¼ pp« 60)
áááááltoabéá convert≤ lonτ né t∩ ß minimuφ oµ wéá asciΘá characters¼ ì
ááááábasσ b¼ anΣ put≤ thσ ASCI╔ iε s¼ returninτ ß pointe≥ t∩ s.
ááááátobaseéá return≤ thσ valuσ oµ characte≥ ché t∩ basσá base¼á iµ ì
ááááávalid, or EOF if not.
áááááutoaé return≤ ß pointe≥ t∩ thσ strinτ s¼ whicΦ contain≤ ASCI╔ ì
ááááávaluσá oµ unsigneΣ n¼á basσ 10¼á witΦ minimuφ widtΦ |w|éá (0-ì
áááááfilleΣ iµ wé ╝ 0¼ anΣ space-filleΣ otherwise)« Thi≤ functioε ì
ááááái≤á anothe≥á modifieΣ versioε oµ itoa(⌐ founΣ iε ╦ ª ╥á (seσ ì
áááááReferencσ 2¼á pp«á 60)¼á witΦ modification≤ a≤ suggesteΣá iε ì
áááááexercise≤á 3-┤ anΣ 3-5¼á anΣ witΦ returneΣ pointe≥ t∩ resul⌠ ì
ááááástring.
SE┼ ALSO
áááááscanf
BUGS
áááááThere are no provisions for overflow.
.paè.hebitcount bitcount
Count Bits in Argument
NAME
ááááábitcount
SYNOPSIS
áááááint bitcount(i)
áááááBITS i;
DESCRIPTION
ááááábitcountéá i≤ ß ╦ ª ╥ functioε (Referencσ 2¼á pagσ 47⌐á whicΦ ì
ááááácount≤ anΣ return≤ thσ numbe≥ oµ 1-bit≤ iε i.
.paè.heclearerr clearerr
Stream Status Inquiries
NAME
áááááclearerr, feof, ferror, filen∩
SYNOPSIS
ááááá#includσ <stdio.h>
áááááVOID clearerr(stream)
áááááFIL┼ *stream;
áááááBOOL feof(stream)
áááááFIL┼ *stream;
áááááBOOL ferror(stream)
áááááFILE *stream;
áááááint fileno(stream)
áááááFIL┼ *stream;
DESCRIPTION
áááááclearerréá reset≤á (set≤á t∩ 0⌐ thσ erro≥ indicatioεá oεá thσ ì
ááááánameΣ stream.
áááááfeoµ return≤ non-NULL wheε enΣ oµ filσ i≤ reaΣ oε thσá nameΣ ì
áááááinpu⌠ stream¼ otherwisσ it returns NULL.
áááááferroréá return≤á non-NULLé iµ aε erro≥ ha≤ occurreΣá oεá FIL┼ ì
ááááástream; otherwise, it returns NULL.
áááááfilen∩á return≤ thσ intege≥ filσ descripto≥ associateΣá witΦ ì
áááááthσ stream; seσ open.
áááááIεá UNIX¼á thesσ function≤ arσ implementeΣ a≤á macros╗á the∙ ì
ááááácanno⌠á bσá redeclared«á Here¼á however¼á the∙á arσá norma∞ ì
áááááfunction≤á anΣá d∩á no⌠ havσ thσ possiblσá sidσá effect≤á oµ ì
ááááámacros«
áááááThe∙á d∩á havσá correspondinτá macros¼áá founΣá iεá stdio.h: ì
áááááCLEARERR¼ FEOF¼ FERROR¼ anΣ FILENO.
SEE ALSO
áááááfopen¼ open
.paè.heerf erf
Gaussian Error Functions and Inverses
NAME
áááááerf, erfc, inverf, inverfc
SYNOPSIS
ááááádouble erf(x)
ááááádouble x;
ááááádouble erfc(x)
ááááádouble x;
ááááádouble inverf(x)
ááááádouble x;
ááááádouble inverfc(x)
ááááádouble x;
DESCRIPTION
áááááerfé return≤ thσ erro≥ functioε oµ x¼á a≤ defineΣ iε Handbooδ ì
áááááoµ Mathematica∞ Functionsô (Seσ Referencσ 3¼ pp« 297).
áááááerfcéáá return≤á thσá complimentar∙á erro≥á functioεá oµáá x¼ ì
ááááá1-erf(x).
áááááCoefficient≤á fo≥ thσ abovσ function≤ arσá froφá Schonfelde≥ ì
ááááá(see Reference 7).
áááááinverfé return≤ thσ inversσ oµ thσ erro≥ function¼ erf« Thi≤ ì
ááááároutinσ use≤ thσ approximation≤ giveε iε "Rationa∞ Chebyshe÷ ì
áááááApproximation≤áá fo≥á thσá Inversσá Erro≥á Function"¼áá (seσ ì
áááááReference 8, pp. 827-830)
áááááinverfcá return≤á thσá inversσ oµá thσá complementar∙á erro≥ ì
áááááfunction, erfc.
DIAGNOSTICS
áááááIε inverf¼á iµ |x|é ╛ 1.0¼ errnoé i≤ se⌠ t∩ EDOM« Iε inverfc¼ ì
áááááiµ |x|é ╝ ░ o≥ ╛ 2¼á errnoé i≤ se⌠ t∩ EDOM¼á anΣ iµ xé i≤ zero¼ ì
ááááái⌠ i≤ se⌠ t∩ ERANGE« Iε eacΦ oµ thesσ cases¼ INFINITYé o≥ ì
ááááá-INFINITYéáá i≤áá returneΣá fo≥á positivσá o≥áá negativσáá x¼ ì
ááááárespectively;
.paè.heexp exp
Mathematical Functions
NAME
áááááexp¼á log¼á log10¼á log2¼á pow¼á sqrt¼á cbr⌠ ì
SYNOPSIS
ááááádouble exp(x)
ááááádouble x;
ááááádouble log(x)
ááááádouble x;
ááááádouble log10(x)
ááááádouble x;
ááááádouble log2(x)
ááááádouble x;
ááááádouble pow(x,y)
ááááádouble x, y;
ááááádouble sqrt(x)
ááááádouble x;
ááááádouble cbrt(x)
ááááádouble x;
DESCRIPTION
áááááAl∞á function≤ abovσ excep⌠ cbrté werσ programmeΣá usinτá thσ ì
áááááalgorithms in Coty and Waite (Reference 5).
áááááexpéá return≤á thσá exponentia∞á functioεá oµá x¼áá ex¼á (seσ ì
áááááReferencσ 5¼ pp« 60-83).
ááááálogé return≤ thσ natura∞ logarithφ oµ xé (seσ Referencσ 5¼ pp« ì
ááááá35-59).
ááááálog10éá return≤á thσá commoε (basσ 10⌐á logarithm¼á anΣá log2é ì
áááááreturn≤ thσ binar∙ logarithφ (basσ 2⌐ oµ x.
ááááápowé return≤ xé raiseΣ t∩ thσ powe≥ oµ y¼ wherσ xé ╛ 0¼ xyé (seσ ì
áááááReferencσ 5¼ pp« 84-124).
ááááásqrté return≤ thσ squarσ roo⌠ oµ x¼ fo≥ x > ░ (seσ Referencσ 5¼ ì
ááááápp« 17-34).
ááááácbrté return≤ thσ cubσ roo⌠ oµ xé (seσ Referencσ 6).
SE┼ ALSO
áááááhypot, sinh
DIAGNOSTICS
áááááexpéá anΣá powé returε INFINIT┘ wheε thσ correc⌠á valuσá woulΣ ì
áááááoverflow╗á errnoéá i≤ se⌠ t∩ ERANGE«á powé return≤ zer∩á anΣ ìèáááááset≤á errnoé t∩ EDOMé wheε thσ seconΣ argumen⌠ i≤ negativσ anΣ ì
ááááánon-integral¼ anΣ als∩ wheε botΦ argument≤ arσ zero.
ááááá
ááááálogé return≤ zer∩ wheε xé i≤ zer∩ o≥ negative╗á errnoé i≤á se⌠ ì
ááááát∩ EDOM.
ááááásqrté return≤ zer∩ wheε xé i≤ negative╗ errnoé i≤ se⌠ t∩ EDOM.
.paè.hefclose fclose
Close or Flush a Stream
NAME
áááááfclose, fflush, flush
SYNOPSIS
ááááá#include <stdio.h>
áááááint fclose(stream)
áááááFILE *stream;
áááááint fflush(stream)
áááááFILE *stream;
áááááint flush(stream, c)
áááááFILE *stream;
áááááint c;
DESCRIPTION
áááááfcloseá cause≤á an∙á buffer≤á fo≥ thσá nameΣá streamá t∩á bσ ì
áááááemptied¼á anΣá thσ filσ t∩ bσ closed«á Buffer≤ allocateΣ b∙ ì
áááááthe standard input/output system are freed.
áááááfcloseé i≤ performeΣ automaticall∙ upoε callinτ exit¼á oε al∞ ì
áááááopen files.
áááááfflush cause≤ an∙ buffereΣ datß fo≥ thσ nameΣ outpu⌠á stream ì
áááááto be written to that file. The stream remains open.
áááááflushé write≤ an∙ buffereΣ character≤ ont∩ FIL┼ stream╗á theε ì
áááááiµ cé isn'⌠ EOF¼á i⌠ put≤ i⌠ iε thσ buffer«
SE┼ ALSO
áááááclose, fopen
DIAGNOSTICS
áááááThesσá routine≤ returε EOFé iµ stream i≤ no⌠ associateΣá witΦ ì
áááááaε outpu⌠ file¼ o≥ iµ buffereΣ datß canno⌠ bσ transferreΣ t∩ ì
áááááthat file. NULL is returned on success.
.paè.hefint fint
Absolute Value, Rounding, Integer and Fractional Part Functions
NAME
áááááfint¼ fraπ, chrstc, floor, ceil, roundì
SYNOPSIS
ááááádouble fint(x)
ááááádouble x;
ááááádouble frac(x)
ááááádouble x;
áááááint chrstc(x)
ááááádouble x;
ááááádouble floor(x)
ááááádouble x;
ááááádouble ceil(x)
ááááádouble x;
ááááádouble round(x)
ááááádouble x;
DESCRIPTION
áááááfinté return≤ thσ intege≥ par⌠ oµ xé a≤ ß double.
áááááfracé return≤ thσ fractiona∞ par⌠ oµ x¼ i.e« ° - fint(x).
áááááchrstπá return≤ thσ characteristiπ (2'≤ exponent⌐ oµá doublσ ì
áááááx. The mantissa is in [.5,1).
áááááfloor returns the largest integer not greater than x.
áááááceil returns the smallest integer not less than x.
áááááround return≤ x roundeΣ t∩ thσ neares⌠ intege≥ iε magnitude.
.paè.hefopen fopen
Open a Stream
NAME
áááááfopeε
SYNOPSIS
ááááá#includσ <stdio.h>
áááááFIL┼ *fopen(filename¼ type)
áááááSTRING filename¼ type;
DESCRIPTION
áááááfopená open≤á thσá filσ nameΣ b∙ filename anΣá associate≤á ß ì
ááááástreaφá witΦá it«á fopen return≤ ß pointe≥ t∩á bσá useΣá t∩ ì
áááááidentif∙ thσ streaφ iε subsequen⌠ operations.
ááááátypeá i≤á ßá characte≥ strinτ havinτ onσá oµá thσá followinτ ì
ááááávalues:
ááááá"ró opeε fo≥ reading
ááááá"wó creatσ fo≥ writing
ááááá"aó append║ opeε fo≥ writinτ a⌠ enΣ oµ file¼ o≥ creatσ fo≥ ì
ááááá áááááwriting
ááááá"r+óá opeεá fo≥ readinτ anΣ writing«á samσ ß "róá bu⌠á thσ ì
ááááá device or file may also be written to.
ááááá"w+óá opeε fo≥ readinτ anΣ writing«á samσ a≤ "wóá bu⌠á thσ ì
ááááá device or file may also be read.
ááááá"a+ó opeε fo≥ appenΣ anΣ read«á samσ a≤ "aó bu⌠ thσ devicσ ì
ááááá or file may also be read.
SEE ALSO
áááááopen¼ fclose
DIAGNOSTICS
áááááfopená return≤á thσá pointe≥á NULLá iµá filenameá canno⌠á bσ ì
áááááaccessed.
.paè.hefread fread
Buffered Input/Output
NAME
áááááfread, fwrite
SYNOPSIS
ááááá#include <stdio.h>
áááááint fread(ptr, ptrsize, nitems, stream)
áááááBUFFER ptr;
áááááint ptrsize, nitems;
áááááFILE *stream;
áááááint fwrite(ptr, ptrsize, nitems, stream)
áááááBUFFER ptr;
áááááint ptrsize, nitems;
áááááFILE *stream;
DESCRIPTION
áááááfreadé reads¼á int∩ ß blocδ beginninτ a⌠ ptr¼ nitemsé item≤ oµ ì
áááááptrsizeé byte≤ froφ thσ nameΣ inpu⌠ stream«á I⌠ return≤á thσ ì
ááááánumbe≥ oµ item≤ actuall∙ read.
áááááfwriteé append≤ a⌠ mos⌠ nitemsé item≤ oµ ptrsizeé byte≤ oµ typσ ì
ááááá*ptréá t∩á thσ FIL┼ stream«á I⌠ return≤ thσ numbe≥ oµá item≤ ì
áááááactuall∙ written.
ááááá
SE┼ ALSO
áááááread¼ write¼ fopen¼ getc¼ putc¼ gets¼ puts¼ printf¼ scanf
DIAGNOSTICS
áááááfreadé anΣ fwriteé returε NULLé upoε enΣ oµ filσ o≥ error.
.paè.hefrexp frexp
Mantissa and Exponent Functions
NAME
áááááfrexp, ldexp, modf
SYNOPSIS
ááááádouble frexp(value, eptr)
ááááádouble value;
áááááint *eptr;
ááááádouble ldexp(value, exp)
ááááádouble value;
áááááint exp;
ááááádouble modf(value, iptr)
ááááádouble value, *iptr;
DESCRIPTION
áááááfrexpéá return≤á thσ mantissß oµ ß doublσ valueé a≤á ßá doublσ ì
áááááquantity¼á x¼á oµá magnitudσ iε thσ interva∞ [0.5¼á 1)¼á anΣ ì
ááááástore≤á aεá intege≥ né sucΦ tha⌠ valuσ ╜ °á ¬á 2néá indirectl∙ ì
áááááthrougΦ eptr.
áááááldexp returns the quantity value*2exp.
ááááámodféáá return≤áá thσá fractiona∞á par⌠áá oµáá value¼áá i.e.¼ ì
áááááfrac(value)¼á anΣ store≤ thσ intege≥ par⌠ indirectl∙ througΦ ì
áááááiptr¼ i.e.¼ *ipt≥ ╜ fint(value).
BUGS
áááááThσ definitioε oµ modfé appear≤ t∩ bσ somewha⌠ differen⌠ thaε ì
áááááthat given in Ref. 1 for negative value arguments.
SEE ALSO
áááááfrac, fint
.paè.hefseek fseek
Reposition a Stream
NAME
áááááfseek¼ ftell¼ rewinΣ
SYNOPSIS
ááááá#includσ <stdio.h>
áááááint fseek(stream¼ offset¼ whence)
áááááFIL┼ *stream;
ááááálonτ offset;
áááááint whence;
ááááálonτ ftell(stream)
áááááFIL┼ *stream;
áááááint rewind(stream)
áááááFILE *stream;
DESCRIPTION
áááááfseekéá set≤á thσá positioεá oµá thσá nex⌠á inpu⌠á o≥á outpu⌠ ì
áááááoperatioε oε thσ stream«á Thσ ne≈ positioε i≤ a⌠ thσ signeΣ ì
ááááádistancσá offsetéá byte≤á froφá thσá beginning¼á thσá curren⌠ ì
áááááposition¼á o≥á thσ enΣ oµ thσ file¼á accordinτ a≤ whenceé ha≤ ì
áááááthσ valuσ ORIGI╬ (0)¼ CURPO╙ (1)¼ o≥ FILEN─ (2).
áááááfseeδ undoe≤ an∙ effect≤ oµ ungetc.
áááááftelléá return≤á thσá curren⌠ valuσ oµ thσá offse⌠á iεá byte≤ ì
ááááárelativσá t∩á thσá ORIGINé oµ thσ FIL┼á stream¼á measureΣá iε ì
ááááábytes.
áááááOεá somσá systems¼á ftellé ma∙ bσ thσ onl∙ foolprooµá wa∙á t∩ ì
áááááobtain an offset for fseek.
ááááárewind(stream)é i≤ equivalen⌠ t∩ fseek(stream¼á OL¼á ORIGIN)« ì
áááááIt sets the FILE fp to the ORIGIN.
SEE ALSO
ááááálseek¼ fopen
ááááá
DIAGNOSTICS
áááááfseeδ and rewind return EOF fo≥ imprope≥ seeks.
.paè.hegetbuf getbuf
Get a Buffer
NAME
ááááágetbuf
SYNOPSIS
áááááVOID getbuf(fp)
áááááFAST FILE *fp;
DESCRIPTION
ááááágetbuféá get≤ ß buffe≥ eithe≥ froφ alloté o≥ elsσ i⌠ use≤á thσ ì
ááááábytbuf, attaching to the FILE fp.
.paè.hegetc getc
Get Character or Word from Stream
NAME
ááááágetc, getca, getchar, getf, geti, getl
SYNOPSIS
ááááá#includσ <stdio.h>
áááááin⌠ getc(stream)
áááááFIL┼ *stream;
áááááint getca(stream)
áááááFILE *stream;
áááááin⌠ getchar()
ááááádouble getf(prompt, check, low, high)
áááááSTRING prompt;
áááááBOOL check;
ááááádouble low, high;
áááááint geti(prompt, check, low, high)
áááááSTRING prompt;
áááááBOOL check;
áááááint low, high;
ááááálong getl(prompt, check, low, high)
áááááSTRING prompt;
áááááBOOL check;
ááááálong low, high;
DESCRIPTION
ááááágetc return≤ thσ nex⌠ characte≥ froφ thσ nameΣ inpu⌠ stream.
ááááágetcaé i≤ thσ samσ a≤ getc¼ excep⌠ tha⌠ '\rº character≤ inpu⌠ ì
áááááfroφá thσá streaφá arσ suppresseΣ (wheεá compileΣá witΦá thσ ì
áááááCRINSUP switch in stdio.h TRUE).
ááááágetchar()éá i≤ identica∞ t∩ getca(stdin)«á stdio.héá contain≤ ì
áááááthσ macro¼ GETCHARé whicΦ i≤ thσ samσ a≤ thi≤ function.
ááááágetféá print≤á promptéá oε stdout¼á theε read≤á froφá stdiεá ß ì
ááááádouble¼ whicΦ i⌠ returns« Iµ checδ i≤ TRUE¼ double≤ outsidσ ì
áááááof the low - high bounds will not be accepted.
ááááágetié anΣ getlé worδ thσ samσ a≤ getf¼ excep⌠ tha⌠ the∙ returε ì
áááááan integer and a long, respectively.
áááááThσ standarΣ inpu⌠ streaφ stdiné i≤ normall∙ buffereΣ iµá anΣ ì
áááááonl∙á iµ thσ inpu⌠ refer≤ t∩ ß devicσ othe≥ thaε ß terminal« ì
áááááWheε aε inpu⌠ streaφ i≤ unbuffered¼á informatioε i≤ returneΣ ì
áááááfroφá getcé a≤ sooε a≤ i⌠ i≤ written╗á wheε i⌠ i≤á buffered¼ ì
áááááman∙ character≤ arσ saveΣ u≡ anΣ returneΣ b∙ getcé onl∙ afte≥ ì
áááááßá newlinσá i≤á encountered«áá T∩á ensurσá portabilit∙áá oµ ìèáááááprograms¼ alway≤ usσ setbufé t∩ se⌠ thσ prope≥ bufferinτ modσ ì
áááááat the beginning.
SEE ALSO
áááááfopen¼ putc¼ gets¼ scanf¼ fread¼ ungetc, setbuf
DIAGNOSTICS
áááááThesσá function≤á returε thσ intege≥ constan⌠ EOFé a⌠ enΣá oµ ì
áááááfilσ o≥ upoε reaΣ error.
BUGS
áááááSomσá system≤ ma∙ contaiε interna∞ bufferinτ t∩ makσ usσá oµ ì
ááááátermina∞á linσá editinτ feature≤ oµ somσ operatinτá systems¼ ì
áááááeveεá wheε unbuffereΣ inpu⌠ i≤ desired«á Thereforσá getcharé ì
ááááámay not respond properly for character-by-character inputs.
.paè.hegets gets
Get a String from a Stream
NAME
ááááágets, getns, fgets
SYNOPSIS
ááááá#include <stdio.h>
áááááSTRING gets(s)
áááááSTRING s;
áááááSTRING getns(p, s, n)
áááááSTRING p, s;
áááááint n;
áááááSTRING fgets(s, n, stream)
áááááSTRING s;
áááááFILE *stream;
áááááint n;
DESCRIPTION
ááááágetséá read≤á ßá tex⌠ strinτ int∩ sé froφ thσá standarΣá inpu⌠ ì
ááááástreaφ stdin«á Thσ strinτ inpu⌠ i≤ terminateΣ b∙ ßá newlinσ ì
ááááácharacter¼ whicΦ i≤ replaceΣ iε sé b∙ ß NULLé character« getsé ì
áááááreturn≤ it≤ argument.
ááááágetnséá prompt≤á stdou⌠ witΦ thσ strinτ p¼á theε read≤ néá - ▒ ì
ááááácharacters¼á o≥ u≡ t∩ ß newlinσ character¼á whicheve≥á come≤ ì
áááááfirst¼á froφá stdin«á Thσá las⌠á caracte≥ reaΣá int∩á séá i≤ ì
áááááfolloweΣá b∙á NULL«á getnsé return≤ s«á Character≤á entereΣ ì
áááááafte≥á thσá (néá - 1)th¼áá u≡á t∩á anΣá includinτá ßá newlinσ ì
ááááácharacter¼ arσ discarded.
áááááfgetséá read≤á n-▒á tex⌠á characters¼á o≥á u≡á t∩á ßá newlinσ ì
ááááácharacter¼á whicheve≥ come≤ first¼á froφ thσ streamé int∩ thσ ì
ááááástrinτá s«á Thσ las⌠ characte≥ reaΣ int∩ sé i≤ followeΣ b∙ ß ì
áááááNULLé character« fgetsé return≤ s.
SE┼ ALSO
áááááputs, getc, scanf, fread
DIAGNOSTICS
ááááágets anΣ fgets returε thσ constan⌠ pointe≥ NULL upoε enΣá oµ ì
áááááfile, empty s or error.
BUGS
ááááágets delete≤ ß newline¼á fgets keep≤ it¼á al∞ iε thσ namσ oµ ì
ááááábackward compatibility.
.paè.hehypot hypot
Euclidian Distance Function
NAME
áááááhypo⌠
SYNOPSIS
ááááádouble hypot(x, y)
ááááádouble x, y;
DESCRIPTION
áááááhypot returns
ááááááááááásqrt(x*° ½ y*y),
ááááátaking precautions against unwarranted overflows.
SE┼ ALSO
ááááásqrt
DIAGNOSTICS
áááááThσ INFINITYé valuσ i≤ returneΣ oε overflow¼ anΣ errnoé i≤ se⌠ ì
áááááto ERANGE.
.paè.heindex index
String Operation Functions
NAME
áááááindex¼á rindex¼á stradd¼á strcat¼á strncat¼ strcmp¼ strncmp¼ ì
ááááástrcpy¼ strncpy¼ streql¼ strindex¼ strlen¼ strsave
SYNOPSIS
áááááSTRING index(s¼ c)
áááááSTRING s;
áááááchar c;
áááááSTRING rindex(s¼ c)
áááááSTRING s;
ááááácha≥ c;
áááááSTRING stradd(n, s, arg[, ...])
áááááSTRING s, arg, ...;
áááááSTRING strcat(s1¼ s2)
áááááSTRING s1¼ s2;
áááááSTRING strncat(s1¼ s2¼ n)
áááááSTRING s1¼ s2;
áááááint n;
áááááint strcmp(s1¼ s2)
áááááSTRING s1¼ s2;
áááááint strncmp(s1¼ s2¼ n)
áááááSTRING s1¼ s2;
áááááint n;
áááááSTRING strcpy(s1¼ s2)
áááááSTRING s1¼ s2;
áááááSTRING strncpy(s1¼ s2¼ n)
áááááSTRING s1¼ s2;
áááááint n;
áááááBOOL streql(s, t)
áááááSTRING s, t;
áááááint strindex(s, t)
áááááSTRING s, t;
ááááá
áááááint strlen(s)
áááááSTRING s;
áááááSTRING strsave(s)
áááááSTRING s;
DESCRIPTION
áááááThesσ function≤ operatσ oε null-terminateΣ strings« The∙ d∩ ì
áááááno⌠ checδ fo≥ overflo≈ oµ an∙ receivinτ string.è
áááááinde°á (rindex)á return≤á ßá pointe≥á t∩á thσá firs⌠á (last⌐ ì
áááááoccurancσ oµ characte≥ c iε strinτ s¼á o≥ NULL iµ c doe≤ no⌠ ì
áááááoccu≥ iε thσ string.
ááááástrcatá append≤ ß cop∙ oµ strinτ s2 t∩ thσ enΣ oµ strinτ s1« ì
ááááástrncat copie≤ a⌠ mos⌠ n characters«á BotΦ returε ß pointe≥ ì
ááááát∩á thσá null-terminateΣá result«áá straddéá concatenate≤á né ì
ááááástrings, s and arg[, ...].
ááááástrcmp compare≤ it≤ argument≤ anΣ return≤ aε intege≥ greate≥ ì
áááááthan¼á equa∞á to¼á o≥á les≤ thaε zero¼á accordinτ a≤á s1éá i≤ ì
ááááálexicographicall∙ greate≥ than¼á equa∞ to¼á o≥ les≤ thaε s2« ì
ááááástrncmpéá make≤ thσ samσ comparison¼á bu⌠ look≤ a⌠ a⌠ mos⌠á né ì
ááááácharacters.
ááááástrcpyé copie≤ strinτ s2é t∩ s1«á strncpyé copie≤ né character≤ ì
áááááoµ s2¼ o≥ al∞ oµ s2¼ whicheve≥ i≤ less« BotΦ returε s1.
ááááástreqlé return≤ TRUE iµ string≤ sé anΣ té arσ thσ same.
ááááástrindexé locate≤ onσ strinτ iε another¼ return≤ thσ inde° oµ ì
ááááátéá iεá s¼á o≥ EOFé iµ i⌠ doe≤ no⌠ exist«á Thi≤ i≤ thσá indexé ì
áááááfunctioεá giveεá iεá Kernighaε anΣá Ritchie¼á pagσá 6╖á (seσ ì
áááááReference 2).
ááááástrlen return≤ thσ numbe≥ oµ non-NULL character≤ iε s.
ááááástrsaveéá get≤á enougΦá stroragσ fo≥ séá anΣá put≤á i⌠á there¼ ì
áááááreturn≤á thσá pointe≥á t∩ thσ string¼á o≥ NULLé iµá therσá i≤ ì
áááááinsufficien⌠á strinτá space«á Thi≤ i≤á froφá Kernighaεá anΣ ì
áááááRitchie (see Reference 2, pp. 103).
.paè.heisalpha isalpha
Character Classification Functions
NAME
áááááisalnum¼ isalpha¼ isascii¼ iscntrl¼ isdigit¼ ishex¼ islower¼ ì
áááááisoctal¼ isprint¼ ispunct¼ isspace¼ isupper
SYNOPSIS
áááááBOOL isalpha(c)
áááááint c;
ááááá« « .
DESCRIPTION
áááááThesσ function≤ classif∙ ASCII-codeΣ intege≥ value≤ b∙ tablσ ì
ááááálookup«á EacΦá i≤á ß predicatσ returninτ nonzer∩ fo≥á TRUE¼ ì
ááááázer∩ fo≥ FALSE«á isasciié i≤ defineΣ oε al∞ intege≥á values╗ ì
áááááthσá res⌠ arσ defineΣ onl∙ wherσ isasciié i≤ TRUE anΣ oεá thσ ì
ááááásinglσ non-ASCI╔ valuσ EOFé (seσ stdio)«á Thσ condition≤ fo≥ ì
áááááa return of TRUE are
.uj0
áááááisalnuφ c i≤ aε alphanumeriπ character.
áááááisalphß c i≤ ß letter.
áááááisasciΘ c i≤ aε ASCI╔ character¼ codσ les≤ thaε 0x80.
áááááiscntr∞á c i≤ ß deletσ characte≥ (0x7f⌐á o≥á ordinar∙ ì
ááááá áááácontro∞ characte≥ (les≤ thaε 0x20).
áááááisdigi⌠ c i≤ ß digit.
áááááishex c is a hex number, 0 - 9, a - f.
áááááislowe≥ c i≤ ß lowe≥-casσ letter.
áááááisoctal c is an octal digit, 0 - 7.
áááááisprin⌠á cá i≤á ßá printinτá character¼á codσá 0x20 ì
ááááá áááá(space⌐ througΦ 0x7e (tilde).
áááááispunc⌠ c i≤ ß punctuatioε characte≥ (neithe≥ contro∞ ì
ááááá áááááno≥ alphanumeric).
áááááisspacσ c i≤ ß space¼á tab¼ carriagσ return¼ newline¼ ì
ááááá áááááo≥ formfeed.
áááááisuppe≥ c i≤ aε uppe≥-casσ letter.
.uj1
SEE ALSO
áááááMacro≤áá correspondinτá t∩á eacΦá oµá thesσá function≤áá arσ ì
áááááavailablσ iε ctype.h.
.paè.heisok isok
Quesion User
NAME
áááááisok
SYNOPSIS
áááááBOOL isok(prompt)
áááááSTRING prompt;
DESCRIPTION
ááááápromptéá output≤á t∩á stdou⌠ anΣ accept≤ ßá y/εá answer«á I⌠ ì
áááááreturns TRUE for y, and FALSE for n.
.paè.hemalloc malloc
Main Memory Allocator
NAME
ááááámalloc¼ free¼ realloc¼ calloπ
SYNOPSIS
áááááSTRING malloc(nbytes)
áááááunsigned nbytes;
áááááVOID free(ptr)
áááááSTRING ptr;
áááááSTRING realloc(ptr,size)
áááááSTRING ptr;
áááááunsigned size;
áááááSTRING calloc(nelem, elsize)
áááááunsigned nelem, elsize;
DESCRIPTION
ááááámallocéá anΣá freeé providσ ßá simplσá general-purposσá memor∙ ì
áááááallocatioε package«á mallocé return≤ ß pointe≥ t∩ ß blocδ oµ ì
áááááa⌠ leas⌠ nbytesé byte≤ beginninτ oε ß worΣ boundary.
áááááThσá argumen⌠á t∩á freeé i≤ ß pointe≥ t∩ ßá blocδá previousl∙ ì
áááááallocateΣá b∙á malloc╗á thi≤á spacσ i≤á madσá availablσá fo≥ ì
áááááfurthe≥ allocation¼ bu⌠ it≤ content≤ arσ lef⌠ undisturbed.
áááááNeedles≤á t∩á say¼á gravσ disorde≥ wil∞ resul⌠ iµ thσá spacσ ì
áááááassigneΣá b∙ mallocé i≤ overruε o≥ iµ somσ randoφá numbe≥á i≤ ì
áááááhandeΣ t∩ free.
ááááámallocéá allocate≤á thσ firs⌠ big-enougΦ contiguou≤ reacΦá oµ ì
áááááfreσá spacσ founΣ iε ß circula≥ searcΦ froφ thσá las⌠á blocδ ì
áááááallocateΣá o≥ freed¼á coalescinτ adjacen⌠ freσ block≤ a≤á i⌠ ì
ááááásearches«á I⌠ call≤ sbrké t∩ ge⌠ morσ memor∙ froφ thσ systeφ ì
áááááwheε therσ i≤ n∩ suitablσ spacσ alread∙ free.
áááááreallocéá change≤ thσ sizσ oµ thσ blocδ pointeΣ t∩ b∙ ptréá t∩ ì
ááááásizσá byte≤á anΣ return≤ ß pointe≥ t∩ thσá (possiblyá moved⌐ ì
áááááblock«á Thσ content≤ wil∞ bσ unchangeΣ u≡ t∩ thσ lesse≥á oµ ì
áááááthσ ne≈ anΣ olΣ sizes.
áááááreallocé als∩ work≤ iµ ptré point≤ t∩ ß blocδ freeΣ sincσá thσ ì
ááááálas⌠ cal∞ oµ malloc¼á reallocé o≥ calloc╗á thus¼ sequence≤ oµ ì
áááááfree¼á mallocé anΣ reallocé caε exploi⌠ thσ searcΦ strateg∙ oµ ì
ááááámallocé t∩ d∩ storagσ compaction«
ááááácallocéá allocate≤á spacσ fo≥ aε arra∙ oµ neleméá element≤á oµ ì
ááááásizσ elsize« Thσ spacσ i≤ initializeΣ t∩ zeros.
áááááEacΦá oµ thσ allocatioε routine≤ return≤ ß pointe≥ t∩á spacσ ì
ááááásuitabl∙á aligneΣá (afte≥á possiblσá pointe≥á coercion⌐á fo≥ ì
ááááástorage of any type of object.è
DIAGNOSTICS
ááááámalloc¼á reallocéá anΣá callocé returε ß NULLé pointe≥á (0⌐á iµ ì
ááááátherσá i≤ n∩ availablσ memor∙ o≥ iµ thσ operatinτ systeφ ha≤ ì
ááááádetecteΣ storagσ corruptioε outsidσ thσ allocateΣ areas.
SEE ALSO
áááááallot, liberate
BUGS
áááááWheε reallocé return≤ zero¼á thσ blocδ pointeΣ t∩ b∙ ptréá ma∙ ì
ááááábσ destroyed.
.paè.hemax max
Maximum and Mimimum Function for Integers, Doubles and Longs
NAME
ááááámax¼á min¼á fmax, fmin, lmax¼á lmiεá ì
SYNOPSIS
áááááint max(a, b)
áááááint a, b;
áááááint min(a, b)
áááááint a, b;
ááááádouble fmax(x, y);
ááááádouble x, y;
ááááádouble fmin(x, y);
ááááádouble x, y;
ááááálong lmax(x, y)
ááááálong x, y;
ááááálong lmin(x, y)
ááááálong x, y;
DESCRIPTION
ááááámaxéá anΣ miné finΣ thσ maximuφ anΣ thσ minimuφ oµ integer≤á aé ì
áááááanΣá b«á fmaxé anΣ fminé d∩ thσ samσ fo≥ doubles╗á lmaxéá anΣ ì
ááááálminé d∩ thσ samσ fo≥ longs.
áááááMAXá anΣ MIN arσ macro≤ iε defs.Φ whicΦ takσ thσ maximuφ anΣ ì
áááááminimum values of any numeric type.
SEE ALSO
ááááádefs.h
.paè.henprob nprob
Normal Probability Functions
NAME
ááááánprob, nprobc
SYNOPSIS
ááááádouble nprob(x)
ááááádouble x;
ááááádouble nprobc(x)
ááááádouble x;
DESCRIPTION
ááááánprobéá i≤á thσ norma∞ cumulativσ probabilit∙ functioεá oµá ß ì
ááááárandoφá variablσ havinτ uni⌠ variancσ anΣá zer∩á mean¼á i.e« ì
áááááPr{· <╜ x}.
ááááánprobcéá i≤á thσ complementar∙ cumulativσ norma∞á probabilit∙ ì
áááááfunction, i.e., nprobc(x) = 1 - nprob(x).
SEE ALSO
áááááerf, erfc
.paè.heprintf printf
Formatted Output Conversion
NAME
áááááprintf¼ fprintf¼ eprintf, sprintµ, format
SYNOPSIS
ááááá#include <stdio.h>
áááááVOID printf(fmt [, arg ] ... )
áááááSTRING fmt;
áááááunsigned arg;
áááááVOID fprintf(stream, fmt [, arg ] ... )
áááááFILE *stream;
áááááSTRING fmt;
áááááunsigned arg;
áááááVOID eprintf(fmt [, arg ] ... )
áááááSTRING fmt;
áááááunsigned arg;
áááááVOID sprintf(s, fmt [, arg ] ... )
áááááSTRING s, fmt;
áááááunsigned arg;
áááááVOID format(putsub, fmt, args)
áááááint (*putsub)();
áááááSTRING fmt;
áááááunsigned args;
DESCRIPTION
áááááprintféá place≤ outpu⌠ oε thσ standarΣ outpu⌠ streaφá stdout.é ì
áááááfprintféáá place≤áá outpu⌠á oεá thσá nameΣáá outpu⌠áá stream« ì
áááááeprintf(fm⌠ [¼á arτ ▌ ..« )é place≤ outpu⌠ oε stderr« sprintfé ì
áááááplace≤á outpu⌠á iεá thσá strinτá s¼á followeΣá b∙á thσá NULLé ì
ááááácharacter«á formaté place≤ outpu⌠ usinτ thσ putsubé oµ ß lis⌠ ì
áááááoµ item≤ pointeΣ t∩ b∙ args.
áááááEacΦ oµ thesσ function≤ converts¼á formats¼á anΣ print≤á it≤ ì
áááááargé argument≤ unde≥ contro∞ oµ thσ fmté argument« Thσ fmté i≤ ì
áááááßá characte≥á strinτá whicΦ contain≤ tw∩ type≤á oµá objects║ ì
áááááplaiεá characters¼á whicΦá arσ simpl∙ copieΣ t∩á thσá outpu⌠ ì
ááááástream¼á anΣ conversioε specifications¼ eacΦ oµ whicΦ cause≤ ì
áááááconversioεá anΣ printinτ oµ thσ nex⌠ successivσ argéá oµá thσ ì
ááááálist.
áááááEacΦ conversioε specificatioε i≤ introduceΣ b∙ thσ characte≥ ì
ááááá%« Followinτ thσ %¼ therσ ma∙ be
ááááá-áááááaεáá optiona∞áá minu≤á sigεá whicΦáá specifie≤áá lef⌠ ì
áááááááááááadjustmen⌠á oµá thσ converteΣ valuσ iεá thσá indicateΣ ì
áááááááááááfield;
ááááá-áááááaε optiona∞ digi⌠ strinτ specifyinτ ß fielΣ width╗á iµ ìèáááááááááááthσá converteΣá valuσ ha≤ fewe≥á character≤á thaεá thσ ì
áááááááááááfielΣá widtΦá i⌠ wil∞ bσ blank-paddeΣ oε thσ lef⌠á (o≥ ì
áááááááááááright¼á iµá thσá left-adjustmen⌠á indicato≥á ha≤á beeε ì
ááááááááááágiven⌐ t∩ makσ u≡ thσ fielΣ width╗á iµ thσ fielΣ widtΦ ì
ááááááááááábegin≤ witΦ ß zero¼á zero-paddinτ wil∞ bσ donσ insteaΣ ì
áááááááááááoµ blank-padding;
ááááá-áááááaε optiona∞ perioΣ whicΦ serve≤ t∩ separatσ thσá fielΣ ì
áááááááááááwidtΦ froφ thσ nex⌠ digi⌠ string;
ááááá-áááááaεá optiona∞ digi⌠ strinτ specifyinτ ß precisioε whicΦ ì
áááááááááááspecifie≤á thσá numbe≥ oµ digit≤ t∩ appea≥á afte≥á thσ ì
ááááááááááádecima∞ point¼ fo≥ e- anΣ f-conversion¼ o≥ thσ maximuφ ì
ááááááááááánumbe≥ oµ character≤ t∩ bσ printeΣ froφ ß string;
-áááááthσ characte≥ ∞ specifyinτ tha⌠ ß followinτ d¼á o¼á x¼ ì
áááááááááááo≥áá ⌡á correspond≤á t∩á ßá lonτá intege≥áá arg«áá (┴ ì
ááááááááááácapitalizeΣá conversioεá codσá accomplishe≤á thσá samσ ì
áááááááááááthing.)
-áááááß characte≥ whicΦ indicate≤ thσ typσ oµ conversioεá t∩ ì
ááááááááááábσ applied.
ááááá┴á fielΣá widtΦ o≥ precisioε ma∙ bσ '*º insteaΣ oµá ßá digi⌠ ì
ááááástring«á Iεá thi≤á casσ aε intege≥ arg supplie≤á thσá fielΣ ì
áááááwidtΦ o≥ precision.
áááááThe conversion characters and their meanings are
d,o,x Thσá intege≥ arτ i≤ converteΣ t∩á decimal¼á octal¼á o≥ ì
áááááááááááhexadecima∞ notatioε respectively.
áááááfáááááThσá floa⌠á o≥á doublσ argéá i≤á converteΣá t∩á decima∞ ì
ááááááááááánotatioε iε thσ stylσ '[-]ddd.dddº wherσ thσ numbe≥ oµ ì
ááááááááááád'≤á afte≥ thσ decima∞ poin⌠ i≤ equa∞ t∩ thσ precisioε ì
áááááááááááspecificatioεá fo≥ thσ argument«á Iµ thσ precisoεá i≤ ì
ááááááááááámissing¼á ╢á digit≤á arσ given╗á iµ thσá precisioεá i≤ ì
áááááááááááexplicitl∙á zero¼á n∩ digit≤ anΣ n∩ decima∞ poin⌠á arσ ì
áááááááááááprinted.
áááááeáááááThσá floa⌠á o≥ doublσ arτ i≤ converteΣ iεá thσá stylσ ì
ááááááááááá'[-]d.ddde+ddºá wherσá therσ i≤ onσ digi⌠á beforσá thσ ì
ááááááááááádecima∞á poin⌠á anΣ thσ numbe≥ afte≥ i≤ equa∞á t∩á thσ ì
áááááááááááprecisioεá specificatioεá fo≥ thσ argument╗á wheεá thσ ì
áááááááááááprecisioε i≤ missing¼ ╢ digit≤ arσ produced.
ááááágáááááThσá floa⌠á o≥ doublσ arτ i≤ printeΣ iεá stylσá d¼á iε ì
ááááááááááástylσ f¼ o≥ iε stylσ e¼ whicheve≥ give≤ ful∞ precisioε ì
áááááááááááiε minimuφ space.
ááááácáááááThσá characte≥ arτ i≤ printed«á NULLá character≤á arσ ì
áááááááááááignored.
ááááásáááááarτá i≤á takeε t∩ bσ ß strinτ (characte≥ pointer⌐á anΣ ì
ááááááááááácharacter≤á froφ thσ strinτ arσ printeΣ unti∞á ßá NULL ìèááááááááááácharacte≥á o≥ unti∞ thσ numbe≥ oµ character≤ indicateΣ ì
áááááááááááb∙ thσ precisioε specificatioε i≤ reached╗á howeve≥ iµ ì
áááááááááááthσá precisioε i≤ zer∩ o≥ missinτ al∞ character≤ u≡ t∩ ì
áááááááááááß NULLé arσ printed.
áááááuáááááThσá unsigneΣ intege≥ arτ i≤ converteΣ t∩ decima∞á anΣ ì
áááááááááááprinteΣá (thσá resul⌠á wil∞ bσ iε thσá rangσá zer∩á t∩ ì
ááááááááááá65535).
ááááá%áááááPrin⌠ ß '%'╗ n∩ argumen⌠ i≤ converted.
áááááIεá n∩ casσ doe≤ ß non-existen⌠ o≥ smal∞ fielΣá widtΦá causσ ì
ááááátruncatioεá oµá ßá field╗á paddinτ take≤ placσ onl∙á iµá thσ ì
áááááspecifieΣ fielΣ widtΦ exceed≤ thσ actua∞ width«á Character≤ ì
ááááágenerated by printf are printed by putchar.
áááááExamples:
áááááT∩ prin⌠ ß datσ anΣ timσ iε thσ forφ
ááááá áááááSunday¼ Jul∙ 3¼ 10:02
áááá wherσá weekdayéá anΣ monthé arσ pointer≤á t∩á null-terminateΣ ì
ááááástrings:
áááááááááááprintf("%s¼á %≤ %d¼á %02d:%02d"¼á weekday¼ month¼ day¼ ì
áááááááááááhour¼ min);
áááááTo print pi to 5 decimals:
áááááááááááprintf("pΘ ╜ %.5f"¼ 4*atan(1.0));
SE┼ ALSO
áááááputc, scanf
BUGSá
áááááVery wide fields (>MAXLINE characters) fail.
.paè.heputc putc
Put Character or Word on a Stream
NAME
áááááputc, putca, putchar, eputc
SYNOPSIS
ááááá#include <stdio.h>
áááááint putc(c, stream)
áááááint c;
áááááFILE *stream;
áááááint putca(c, stream)
áááááint c;
áááááFILE *stream;
áááááint putchar(c)
áááááint c;
áááááint eputc(c)
áááááchar c;
DESCRIPTION
áááááputcé append≤ thσ characte≥ cé t∩ thσ nameΣ outpu⌠ stream« I⌠ ì
áááááreturn≤á thσ characte≥ written«á putcaé i≤ thσ samσ a≤á putcé ì
áááááexcep⌠á tha⌠á '\nº i≤ accompanieΣ b∙ '\rº wheεá CROUTADDéá iε ì
ááááástdio.hé i≤ TRUE.
áááááputchar(c)éá i≤á defineΣá a≤á thσá macr∩á putca(c¼áá stdout)¼ ì
áááááreturninτ c¼ iε stdio.h.
áááááeputcé output≤ cé t∩ thσ standarΣ erro≥ device¼ stderr« eputcé ì
ááááái≤ defineΣ a≤ thσ macr∩ putca(c¼ stderr).
áááááThσ standarΣ streaφ stdouté i≤ normall∙ buffereΣ iµ anΣá onl∙ ì
áááááiµá thσ outpu⌠ doe≤ no⌠ refe≥ t∩ ß terminal«á Thσá standarΣ ì
ááááástreaφá stderré i≤ b∙ defaul⌠ unbuffereΣ unconditionall∙ (seσ ì
áááááfopen)«á Wheεá aεá outpu⌠ streaφ i≤á unbuffereΣá informatioε ì
áááááappear≤á oεá thσá destinatioε filσ o≥ termina∞á a≤á sooεá a≤ ì
áááááwritten╗á wheε i⌠ i≤ buffered¼á man∙ character≤ arσ saveΣ u≡ ì
áááááanΣ writteε a≤ ß block«á fflushé (seσ fclose⌐ ma∙ bσ useΣ t∩ ì
áááááforcσ thσ blocδ ou⌠ early.
áááááputc updates the outrow[] and outcol[] of its stream->_unit.
SE┼ ALSO
áááááfopen, fclose, getc, puts, printf, fread, stdio.h
DIAGNOSTICS
áááááThesσ function≤ returε thσ constan⌠ EO╞ upoεá error«á
.paè.heputs puts
Put a String on a Stream
NAME
áááááputs, fputs, eputs
SYNOPSIS
ááááá#include <stdio.h>
áááááint puts(s)
áááááSTRING s;
áááááint fputs(s, stream)
áááááSTRING s;
áááááFILE *stream;
áááááint eputs(s)
áááááSTRING s;
DESCRIPION
áááááputsé copie≤ thσ tex⌠ strinτ s¼á followeΣ b∙ newline¼á t∩ thσ ì
ááááástdioé device¼ anΣ return≤ ß newlinσ characte≥ iµ successful¼ ì
áááááEOFé iµ not.
ááááá
áááááfputséá copie≤ thσ tex⌠ strinτ sé t∩ thσ nameΣ outpu⌠á stream« ì
áááááI⌠ return≤ NULLé iµ successful¼ EOFé iµ not.
áááááeputséá put≤ thσ strinτ ou⌠ t∩ thσ standarΣ erro≥ device«á I⌠ ì
áááááreturns newline if successful, EOL if not.
áááááNonσ oµ thσ routine≤ copie≤ thσ terminatinτ NULLé character.
SE┼ ALSO
áááááfopen¼ gets¼ putc¼ printf¼ ferror¼ fwrite
BUGS
áááááputsé append≤ ß newline¼á fputsé doe≤ not¼á al∞ iε thσ namσ oµ ì
ááááábackwarΣ compatibility.
.paè.herandom random
Random Number Generator Functions
NAME
ááááárandize, random, randnorm, randexp, urandom
SYNOPSIS
áááááVOID randize(seed)
áááááint seed;
ááááádouble random()
ááááádouble randnorm()
ááááádouble randexp()
áááááunsigned urandom()
DESCRIPTION
ááááárandizeé initialize≤ thσ randoφ numbe≥ generato≥ accordinτ t∩ ì
áááááseed«á Iµ seedé i≤ zero¼á aε interna∞ valuσ i≤ useΣ t∩ star⌠ ì
áááááthσ generator╗á iµ ß positivσ valuσ i≤ used¼á tha⌠ valuσá i≤ ì
áááááconverteΣá t∩á ß pseudorandoφ startinτ value╗á anΣ iµ -▒á i≤ ì
áááááused¼ aε unknowε valuσ i≤ useΣ a≤ thσ starter.
ááááárandom returns a uniform random value in [0, 1].
ááááárandnorméá return≤á ß normall∙ distributeΣ randoφ valuσá witΦ ì
ááááázero mean and unit standard deviation.
ááááárandexpéáá use≤áá thσáá functioεá random()éáá t∩áá returεáá aε ì
áááááexponentiall∙ distributeΣ randoφ valuσ characterizeΣ b∙ uni⌠ ì
ááááámean¼ i.e. -log(random()).
áááááurandoméá return≤ ß uniforφ randoφ unsigneΣ intege≥ valuσá iε ì
ááááá[0, 65535].
áááááNumber≤á generateΣá havσ n∩á seria∞á correlation«á Adjacen⌠ ì
ááááásample≤áá oµá randoméá anΣá urandoméá number≤á arσáá uniforml∙ ì
ááááádistributeΣá ove≥á thσ 32-cube¼á anΣ runs-u≡á anΣá runs-dowε ì
ááááátest≤á u≡ t∩ lengtΦ 1│ woulΣ requirσ morσ thaε 1011öá sample≤ ì
ááááát∩á sho≈á deviatioεá froφ theoretical«á Thσ perioΣá oµá thσ ì
ááááágenerato≥á i≤á abou⌠á 1.│á ¬ 10154«á Thσá number≤á forφá aε ì
áááááasymptoticall∙á randoφ Tausworthσ linea≥ recurrancσá (modul∩ ì
ááááá2⌐á sequence¼á describeΣ iε Ref«á 12¼á usinτá thσá primitivσ ì
ááááátrinomial x521 + x32 + 1.
.paè.heratfun ratfun
Rational Function Evaluation
NAME
áááááratfun
SYNOPSIS
ááááádouble ratfun(x, P, Q, n, m)
ááááádouble x, P[], Q[];
áááááint n, m;
DESCRIPTION
áááááratfun return≤ thσ valuσ oµ thσ rationa∞ functioεá P(x)/Q(x) ì
áááááwherσ ε ╜ deg(P)¼ φ ╜ deg(Q).
DIAGNOSTICS
áááááIµá thσ denominato≥ i≤ zero¼á errnoé i≤ se⌠ t∩á ERANGE╗á theε ì
ááááápositivσá INFINITYéá i≤á returneΣ iµ thσá numerato≥á i≤á non-ì
ááááánegative╗á otherwise¼á negativσá INFINITYé i≤á returned«á Oε ì
áááááunderflow¼ errnoé i≤ se⌠ t∩ ERANGE¼ anΣ zer∩ i≤ returned« Oε ì
áááááoverflow¼á errnoé i≤ se⌠ t∩ ERANGEé anΣ INFINITYé oµ thσ prope≥ ì
ááááásigε i≤ returned.
.paè.herkstep rkstep
Fourth Order Runga-Kutta
NAME
ááááárkstep, rknstep
SYNOPSIS
áááááVOID rkstep(f, h, t, yp)
ááááádouble (*d)(), h, t, *yp;
áááááVOID rknstep(N, f, h, t, y1, y2, dy, k, ys)
ááááádouble (*f)(), h, t, y1[], y2[], dy[], k[], ys[];
DESCRIPTION
ááááárkstepé perform≤ aε integratioε ste≡ fo≥ ß first-orde≥á diffì
áááááerentia∞áá equatioεá usinτá thσá fourtΦá orde≥áá Runga-Kuttß ì
áááááformulas«á Thσ forφ oµ thσ equatioε i≤ yº ╜ f(t¼ y)¼ ì
áááááwherσá ∙á ╜ *ypé anΣ differenticatioε i≤ witΦ respec⌠ t∩á thσ ì
áááááfirs⌠ variablσ oµ f«á (Seσ Referencσ 3¼á pg«á 896¼á formulß ì
ááááá25.5.10)
ááááárknstepéá perform≤á aεá integratioε ste≡ fo≥á aεá N-tuplσá oµ ì
áááááfirst-orde≥ ordinar∙ differentia∞ equation≤ usinτ thσ fourtΦ ì
áááááorde≥á Runga-Kuttßá formula≤á referenceΣ above«á Néá i≤á thσ ì
ááááádimensioεá oµ thσ tuple¼á y1é i≤ thσ curren⌠ vecto≥ statσá a⌠ ì
ááááá(time⌐ t¼ y2é i≤ thσ calculateΣ N-tuplσ statσ valuσ a⌠ (time⌐ ì
ááááá⌠ ½ hé returneΣ b∙ rknstep¼á dyé i≤ ß scratcΦ arra∙ needeΣá t∩ ì
áááááholΣ intermediatσ calculation≤ accumulatinτ thσ dyé value¼á ké ì
áááááhold≤á coefficient≤á k1¼á k2¼á k3,é anΣ k4¼á anΣ ysé i≤ fo≥á yé ì
áááááapproximant≤á fo≥ eacΦ equation«á Al∞ oµ thσ scratcΦá arra∙ ì
ááááámust have dimension not less than N.
áááááThσ functioε fé ha≤ │ arguments╗á f(i¼á t¼ y)¼ wherσ ié i≤ thσ ì
ááááávecto≥ componen⌠ index¼á té i≤ thσ differenticatioε variable¼ ì
áááááanΣ yé i≤ thσ curren⌠ statσ valuσ vector«á Tha⌠ is¼ ì
áááááyiö ╜ f(i¼ t¼ y)é fo≥ Θ ╜ 1¼ 2,...,N.é Iε botΦ functions¼ hé i≤ ì
áááááthσ ste≡ size.
.paè.hescanf scanf
Formatted Input Conversion
NAME
áááááscanf¼ fscanf¼ sscanµ, unformat
SYNOPSIS
ááááá#includσ <stdio.h>
áááááint scanf(forma⌠ █ ¼ pointer ▌ ... )
áááááSTRING format;
áááááunsigned *pointer;
áááááint fscanf(stream¼ forma⌠ █ ¼ pointer ▌ ... )
áááááFIL┼ *stream;
áááááSTRING format;
áááááunsigned *pointer;
áááááint sscanf(s¼ forma⌠ █ ¼ pointer ▌ ... )
áááááSTRING s¼ format;
áááááint *pointer;
áááááint unformat(get, format [ , pointer ] ... )
áááááint (*get)();
áááááSTRING format;
áááááint *pointer;
DESCRIPTION
áááááscanféá read≤ froφ thσ standarΣ inpu⌠ streaφá stdin«á fscanfé ì
áááááread≤á froφ thσ nameΣ inpu⌠ stream«á sscanfé read≤ froφá thσ ì
ááááácharacte≥á strinτá s«á unformaté utilize≤ thσá getéá functioε ì
áááááargumen⌠áá t∩á fetcΦá characters«áá EacΦáá functioεáá read≤ ì
ááááácharacters¼á interpret≤ theφ accordinτ t∩ format¼ anΣ store≤ ì
áááááthσá result≤á iεá it≤ remaininτá arguments«á EacΦá functioε ì
áááááexpect≤á a≤á argument≤ ß contro∞á strinτá format¼á describeΣ ì
ááááábelow¼á anΣ ß se⌠ oµ pointeré argument≤ indicatinτ wherσá thσ ì
áááááconverteΣ inpu⌠ shoulΣ bσ stored.
áááááThσááá contro∞ááá strinτáá usuall∙ááá contain≤ááá conversioε ì
áááááspecifications¼á whicΦá arσ useΣ t∩ direc⌠ interpretatioε oµ ì
áááááinpu⌠ sequences« Thσ contro∞ strinτ ma∙ contain:
ááááá1.ááááBlanks¼á tab≤ o≥ newlines¼á whicΦ matcΦ optiona∞ whitσ ì
áááááááááááspacσ iε thσ input.
ááááá2.ááááAεá ordinar∙á characte≥ (no⌠ %⌐ whicΦ mus⌠á matcΦá thσ ì
ááááááááááánex⌠ characte≥ oµ thσ inpu⌠ stream.
ááááá3.ááááConversioε specifications¼ consistinτ oµ thσ characte≥ ì
ááááááááááá%¼á aε optiona∞ assignmen⌠ suppressinτ characte≥ *¼ aε ì
áááááááááááoptiona∞áá numerica∞á maximuφá fielΣá width¼áá anΣáá ß ì
áááááááááááconversioε character.
ááááá┴á conversioεá specificatioε direct≤ thσ conversioεá oµá thσ ì
ááááánex⌠á inpu⌠á field╗á thσ resul⌠ i≤ placeΣá iεá thσá variablσ ìèááááápointeΣ t∩ b∙ thσ correspondinτ argument¼á unles≤ assignmen⌠ ì
ááááásuppressioεá wa≤ indicateΣ b∙ *«á Aε inpu⌠ fielΣ i≤ defineΣ ì
áááááa≤ ß strinτ oµ non-spacσ characters╗á i⌠ extend≤ t∩ thσ nex⌠ ì
áááááinappropriatσá characte≥á o≥á unti∞á thσá fielΣá width¼áá iµ ì
áááááspecified¼ i≤ exhausted.
áááááThσ conversioε characte≥ indicate≤ thσ interpretatioε oµ thσ ì
áááááinpu⌠ field╗ thσ correspondinτ pointe≥ argumen⌠ mus⌠ usuall∙ ì
ááááábσáá oµá ßá restricteΣá type«áá Thσá followinτáá conversioε ì
ááááácharacter≤ arσ legal:
ááááá%áááááßá singlσ '%º i≤ expecteΣ iε thσ inpu⌠ a⌠ thi≤á point╗ ì
ááááááááááán∩ assignmen⌠ i≤ done.
ááááádáááááßá decima∞á intege≥á i≤á expected╗á thσá correspondinτ ì
áááááááááááargumen⌠ shoulΣ bσ aε intege≥ pointer.
áááááoáááááaεá octa∞á intege≥á i≤á expected╗áá thσá correspondinτ ì
áááááááááááargumen⌠ shoulΣ bσ aε intege≥ pointer.
áááááxáááááß hexadecima∞ intege≥ i≤ expected╗á thσá correspondinτ ì
áááááááááááargumen⌠ shoulΣ bσ aε intege≥ pointer.
ááááásáááááßá characte≥á strinτ i≤á expected╗á thσá correspondinτ ì
áááááááááááargumen⌠ shoulΣ bσ ß characte≥ pointe≥ pointinτ t∩á aε ì
áááááááááááarra∙á oµ character≤ largσ enougΦ t∩ accep⌠ thσ strinτ ì
áááááááááááanΣá ß terminatinτ NULL¼á whicΦ wil∞á bσá added«á Thσ ì
áááááááááááinpu⌠á fielΣá i≤ terminateΣ b∙ ß spacσ characte≥ o≥á ß ì
ááááááááááánewline.
ááááácáááááßá characte≥ i≤ expected╗á thσ correspondinτá argumen⌠ ì
áááááááááááshoulΣá bσ ß characte≥ pointer«á Thσ norma∞ ski≡ ove≥ ì
áááááááááááspacσ character≤ i≤ suppresseΣ iε thi≤ case╗á t∩á reaΣ ì
áááááááááááthσ nex⌠ non-spacσ character¼á tr∙ '%1s'«á Iµ ß fielΣ ì
áááááááááááwidtΦá i≤á given¼á thσ correspondinτá argumen⌠á shoulΣ ì
ááááááááááárefe≥ t∩ ß characte≥ array¼á anΣ thσ indicateΣá numbe≥ ì
áááááááááááoµ character≤ i≤ read.
áááááeáááááß floatinτ poin⌠ numbe≥ i≤ expected╗ thσ nex⌠ fielΣ i≤ ì
áááááfáááááconverteΣáá accordingl∙áá anΣáá storeΣáá througΦáá thσ ì
ááááááááááácorrespondinτ argument¼ whicΦ shoulΣ bσ ß pointe≥ t∩ ß ì
áááááááááááfloat« Thσ inpu⌠ forma⌠ fo≥ floatinτ poin⌠ number≤ i≤ ì
áááááááááááaεáá optionall∙á signeΣá strinτá oµá digit≤áá possibl∙ ì
ááááááááááácontaininτá ß decima∞ point¼á followeΣ b∙ aεá optiona∞ ì
áááááááááááexponen⌠á fielΣ consistinτ oµ aε ┼ o≥ σ followeΣ b∙ aε ì
áááááááááááoptionall∙ signeΣ integer.
ááááá[áááááindicate≤á ßá strinτá no⌠ t∩á bσá delimiteΣá b∙á spacσ ì
ááááááááááácharacters«á Thσ lef⌠ bracke⌠ i≤ followeΣ b∙ ß se⌠ oµ ì
ááááááááááácharacter≤ anΣ ß righ⌠ bracket╗ thσ character≤ betweeε ì
áááááááááááthσ bracket≤ definσ ß se⌠ oµ character≤ makinτ u≡á thσ ì
ááááááááááástring« Iµ thσ firs⌠ characte≥ i≤ no⌠ circumfle° (^)¼ ì
áááááááááááo≥ tildσ (~)¼á thσ inpu⌠ fielΣ i≤ al∞ character≤ unti∞ ì
áááááááááááthσá firs⌠á characte≥á no⌠á iεá thσá se⌠á betweeεá thσ ì
ááááááááááábrackets╗á iµá thσá firs⌠á characte≥á afte≥á thσá lef⌠ ìèááááááááááábracke⌠ i≤ ▐ (o≥ ~)¼ thσ inpu⌠ fielΣ i≤ al∞ character≤ ì
áááááááááááunti∞á thσá firs⌠ characte≥ whicΦ i≤ iε thσá remaininτ ì
áááááááááááse⌠áá oµáá characer≤á betweeεáá thσáá brackets«áá Thσ ì
ááááááááááácorrespondinτá argumen⌠á mus⌠á poin⌠á t∩á ßá characte≥ ì
áááááááááááarray.
áááááThσ conversioε character≤ d¼á ∩ anΣ ° ma∙ bσ capitalizeΣá o≥ ì
ááááápreceedeΣá b∙á lé t∩ indicatσ tha⌠ ß pointe≥ t∩á longéá rathe≥ ì
áááááthaεá t∩á intéá i≤ iεá thσá argumen⌠á list«á Similarly¼á thσ ì
áááááconversioεá character≤ eé o≥ fé ma∙ bσ capitalizeΣ o≥ precedeΣ ì
áááááb∙á Lé t∩ indicatσ ß pointe≥ t∩ double rathe≥ thaε t∩ float« ì
áááááThσ conversioε character≤ d¼á oé anΣ xé ma∙ bσ preceedeΣ b∙á hé ì
ááááát∩á indicatσá ß pointe≥ t∩ shorté rathe≥ thaεá t∩á int«á Thσ ì
áááááconversioεá hdéá ma∙á bσ shorteneΣ t∩ onl∙ héá t∩á conforφá t∩ ì
áááááKernighan and Ritchie (Reference 2).
áááááThσá scanµá function≤á returεá thσá numbe≥á oµá successfull∙ ì
ááááámatcheΣá anΣá assigneΣá inpu⌠ items«á Thi≤ caε bσá useΣá t∩ ì
ááááádecidσ ho≈ man∙ inpu⌠ item≤ werσ found« Thσ constan⌠ EO╞ i≤ ì
áááááreturneΣ upoε enΣ oµ input╗ notσ tha⌠ thi≤ i≤ differen⌠ froφ ì
ááááázero¼ whicΦ mean≤ tha⌠ n∩ conversioε wa≤ done╗ iµ conversioε ì
áááááwa≤á intended¼áá i⌠á wa≤á frustrateΣá b∙á aεáá inappropriatσ ì
ááááácharacte≥ iε thσ input.
áááááFo≥ example¼ thσ call
áááááááááááin⌠ i╗
ááááá floa⌠ x╗
ááááá cha≥ name[50];
ááááá scanf¿ "%d%f%s"¼ &i¼ &x¼ name);
áááááwitΦ thσ inpu⌠ line
ááááááááááá2╡ 54.32E-▒ synott
áááááwil∞ assigε t∩ Θ thσ valuσ 25¼á ° thσ valuσ 5.432¼á anΣ namσ ì
áááááwil∞ contaiε 'synott'« Or,
áááááááááááin⌠ i╗
ááááá floa⌠ x╗
ááááá cha≥ name[50];
ááááá scanf("%2d%f%*d%[1234567890]"¼ &i¼ &x¼ name);
áááááwitΦ input
ááááááááááá5678╣ 012│ 56a72
áááááwil∞ assigε 5╢ t∩ i¼á 789.░ t∩ x¼ ski≡ '0123'¼ anΣ placσ thσ ì
ááááástrinτá '56º iε name«á Thσ nex⌠ cal∞ t∩ getcharé wil∞ returε ì
ááááá'a'.
áááááThσ geté argumen⌠ oµ thσ unformaté functioε itselµ use≤ ß modσ ì
áááááargument║ get(TRUE⌐ i≤ assumeΣ t∩ perforφ ß characte≥ input¼ ì
áááááand get(FALSE) does an unget on the last character fetched.
è
SEE ALSO
áááááatof¼ getc¼ printf
DIAGNOSTICS
áááááThσ scanµ function≤ returε EO╞ oε enΣ oµ input¼á anΣ ß shor⌠ ì
ááááácoun⌠ fo≥ missinτ o≥ illega∞ datß items.
BUGS
áááááThσáá succes≤áá oµá incompatiblσá type≤á i≤áá no⌠áá directl∙ ì
ááááádeterminable.
.paè.hescreeε i/∩ screeε i/o
Screen Input/Output
NAME
áááááaltscrn¼á clrscrn¼á cursor¼á eraeol¼á eraeop¼ home¼ iniscrn¼ ì
ááááánormscrn, putscrn, uniscrn
SYNOPSIS
ááááá#include <scrnio.h>
áááááBOOL altscrn()
áááááVOID clrscrn()
áááááBOOL cursor(r, c)
áááááint r, c;
áááááBOOL eraeol(r, c)
áááááint r, c;
áááááBOOL eraeop(r, c)
áááááint r, c;
áááááVOID home()
áááááVOID iniscrn()
áááááBOOL normscrn()
áááááMETACHAR putscrn(c)
áááááint c;
áááááVOID uniscrn()
DESCRIPTION
áááááaltscrnéá begin≤ thσ alternate-intensit∙ mode«á Iµ thi≤ i≤ ß ì
ááááásysteφ supporteΣ function¼á altscrné return≤ TRUE╗ iµ not¼ i⌠ ì
áááááreturn≤ FALSE.
áááááclrscrnéá clear≤ anΣ erase≤ thσ termina∞ screeεá anΣá return≤ ì
áááááthe cursor to the home position.
ááááácursoréá position≤á thσá curso≥á a⌠á ro≈á r¼á columεá c«á Iµ ì
ááááásuccessful¼á thi≤á functioε return≤ TRUE«á Iµ ßá coordinatσ ì
áááááaddreessinτ erro≥ i≤ sensed¼ i⌠ wil∞ returε FALSE.
áááááeraeoléá erase≤ ro≈ ré froφ columε cé t∩ thσ enΣ oµá thσá line« ì
áááááI⌠ wil∞ returε TRUEé iµ successful¼ o≥ FALSEé oε imprope≥ ré o≥ ì
ááááác. The cursor is positioned at row r, column c afterward.
áááááeraeopéá erase≤ froφ ro≈ r¼á columε cé t∩ thσ enΣ oµ thσ page« ì
áááááTRUEéá i≤á normall∙ returned╗á imprope≥ ré o≥á céá wil∞á causσ ì
áááááeraeopé t∩ returε FALSE«á Thσ curso≥ i≤ positioneΣ a⌠ ro≈ r¼ ì
ááááácolumn c afterward.
èáááááhomeéá move≤á thσá curso≥ t∩ ro≈ zero¼á columεá zer∩á oµá thσ ì
áááááterminal.
áááááiniscrnéá send≤ thσ initializatioε sequencσ t∩ thσá terminal¼ ì
áááááif it exists.
ááááánormscrné begin≤ thσ normal-intensit∙ mode«á I⌠ return≤ TRUEé ì
áááááiµ thi≤ functioε i≤ supported¼ o≥ FALSEé iµ not.
áááááputscrné send≤ thσ characte≥ cé t∩ thσ termina∞ iεá unbuffereΣ ì
ááááámode«áá outcol[STDOUT]éá anΣá outrow[STDOUT]éá arσá correctl∙ ì
áááááupdated¼ ie.¼ putscrné wil∞ bσ ignoreΣ iµ thσ screeε sizσ ha≤ ì
ááááábeen exceeded.
áááááuniscrnéáá send≤áá thσá un-initializatioεá sequencσá t∩áá thσ ì
áááááterminal, if it exits.
áááááGloba∞á variable≤ outrow[STDOUT]é anΣ outcol[STDOUT]é holΣ thσ ì
ááááácurrent position of the cursor at all times.
áááááscrnio.héá i≤á thσ datß filσ whicΦ declare≤ al∞á globa∞á datß ì
ááááánecessar∙á fo≥ thσ usσ oµ thesσ termina∞ displa∙á functions« ì
áááááscrnio.hé shoulΣ bσ includeΣ beforσ stdio.hé iε ever∙á prograφ ì
áááááusing screen i/o functions.
áááááRo≈á ░á i≤á thσ topmos⌠ row¼á anΣ columε ░ i≤á thσá leftmos⌠ ì
ááááácolumn.
BUGS
áááááThesσ function≤ ma∙ no⌠ operatσ oε system≤ iε whicΦ termina∞ ì
áááááoutput cannot be direct.
.paè.hesetbuf setbuf
Assign Buffer
NAME
ááááásetbuf
SYNOPSIS
áááááVOI─ setbuf(fp¼ buffer)
áááááFAS╘ FIL┼ *fp;
áááááBUFFE╥ buffer;
DESCRIPTION
ááááásetbufé i≤ useΣ afte≥ ß streaφ ha≤ beeε openeΣ bu⌠ beforσá i⌠ ì
ááááái≤ reaΣ o≥ written«á Iµ fpé alread∙ ha≤ ß buffe≥ assigneΣ t∩ ì
áááááit¼á i⌠ cause≤ thσ characte≥ arra∙ bufferé t∩ bσ useΣ insteaΣ ì
áááááoµá aεá automaticall∙á allocateΣ buffer«á An∙ datßá iεá thσ ì
áááááexistinτ buffe≥ i≤ lost«á Iµ bufferé i≤ thσ constan⌠ pointe≥ ì
áááááNULL, input/output will be completely unbuffered.
áááááUsσá oµ setbuf(stdin¼á NULL)é a⌠ thσ beginninτ oµá ßá prograφ ì
áááááassures that terminal input will be unbuffered.
BUGS
áááááUnbuffereΣáááá termina∞ááá inpu⌠ááá depend≤ááá oεááá whethe≥ ì
áááááread(0, buffer, 1)éáá return≤á ßá bytσá immediatel∙áá o≥áá i≤ ì
áááááinternall∙ buffereΣ fo≥ linσ editinτ purposes.
.paè.hesgn sgn
Sign Function
NAME
ááááásgn
SYNOPSIS
ááááádouble sgn(x)
ááááádouble x;
DESCRIPTION
ááááásgné wil∞ returε thσ doublσ sgε functioε oµ x¼á i.e.¼ +1¼ -1¼ ì
áááááo≥á 0¼á accordingl∙ a≤ xé i≤á positive¼á negative¼á o≥á zero¼ ì
ááááárespectively.
áááááSGNá i≤á thσ macr∩ iε heade≥ filσ defs.Φ whicΦ perform≤á thσ ì
ááááásamσá function¼á excep⌠ fo≥ sidσ effects¼á anΣ oε al∞ signeΣ ì
ááááánumeric types.
.paè.hesimpson simpson
Integration by Simpson's Modified Rule
NAME
ááááásimpson
SYNOPSIS
ááááádouble simpson(func, lowlim, uplim, n)
ááááádouble (*func)(), lowlim, uplim;
áááááint n;
DESCRIPTION
ááááásimpsonéá integrate≤á thσ functioε funcé froφ lowlimé t∩á uplimé ì
áááááusinτ 2né points¼á accordinτ t∩ thσ Simpsoε integratioε rule« ì
áááááThe error value is given by
ááááá e = -(n * h5/90) * funciv(x)
áááááwherσá héá ╜á (uplimé - lowlim)/(2n⌐ anΣ lowlimé <ô xéá <ôá uplim« ì
ááááá(see Reference 3, formula 25.4.6)
.paè.hesin sin
Trigonometric Functions
NAME
ááááásin¼ cos¼ tan¼ asin¼ acos¼ atan¼ atan2¼ cotaε
SYNOPSIS
ááááá#include <mathcons.h>
ááááádouble sin(x)
ááááádouble x;
ááááádouble cos(x)
ááááádouble x;
ááááádouble tan(x)
ááááádouble x;
ááááádouble asin(x)
ááááádouble x;
ááááádouble acos(x)
ááááádouble x;
ááááádouble atan(x)
ááááádouble x;
ááááádouble atan2(x, y)
ááááádouble x, y;
ááááádouble cotan(x)
ááááádouble x;
DESCRIPTION
áááááAl∞á oµ thesσ function≤ werσ programmeΣ usinτ thσ algorithm≤ ì
ááááágiveεá iε Softwarσ Manua∞ fo≥ thσ Elementar∙ Functionsôá (seσ ì
áááááReference 5).
ááááásin¼á co≤á anΣ taε returε trigonometriπ function≤ oµá radiaε ì
áááááarguments«á Thσ magnitudσ oµ thσ argumen⌠ shoulΣ bσ checkeΣ ì
áááááb∙ thσ calle≥ t∩ makσ surσ thσ resul⌠ i≤á meaningful«á (seσ ì
áááááReference 5, pp. 125-149 and 150-173)
áááááasin returns the arc sin in the range -pi/2 to +pi/2.
áááááacosé return≤ thσ arπ cosinσ iε thσ rangσ zer∩ t∩ pi.
ááááá
áááááataεá return≤á thσá arπ tangen⌠ oµ ° iε thσ rangσá -pi/▓á t∩ ì
ááááá+pi/2. (see Reference 5, pp. 194-216)
áááááatan2 returns the arc tangent of x/y in the range -pi to +pi.
ááááácotan returns the cotangent of x.
DIAGNOSTICSèáááááArgument≤á oµá magnitudσ greate≥ thaε unit∙ causσá asinéá anΣ ì
áááááacosé t∩ returε valuσ 0╗á errnoé i≤ se⌠ t∩ EDOM« Thσ valuσ oµ ì
ááááátané a⌠ it≤ singula≥ point≤ i≤ INFINITY¼á anΣ errnoé i≤ se⌠ t∩ ì
áááááERANGE.
BUGS
áááááThσá valuσá oµ tané fo≥ argument≤ greate≥á thaεá MAXANGL┼á i≤ ì
ááááágarbage.
.paè.hesinh sinh
Hyperbolic Functions
NAME
ááááásinh¼ cosh¼ tanΦ
SYNOPSIS
ááááá#include <mathtyp.h>
ááááádouble sinh(x)
ááááádouble x;
ááááádouble cosh(x)
ááááádouble x;
ááááádouble tanh(x)
ááááádouble x;
DESCRIPTION
áááááThesσá function≤ computσ thσ designateΣ hyperboliπ function≤ ì
áááááfor real arguments.
áááááAl∞á werσ programmeΣ usinτ thσ algorithm≤ giveε iεá Softwarσ ì
áááááManua∞á fo≥ thσ Elementar∙ Functionsô (seσ Referencσá 5¼á pp« ì
ááááá217-238 and 239-255).
DIAGNOSTICS
ááááásinhéá anΣ coshé returε INFINITY oµ appropriatσ sigε wheεá thσ ì
ááááácorrec⌠ valuσ woulΣ overflow.
.paè.hesortH sortH
Sort Functions
NAME
ááááásortH¼ sortS¼ sortQ¼ sort┬, qsort
SYNOPSIS
áááááVOID sortH(n, comp, exch)
áááááint n, (*comp)();
áááááVOID (*exch)();
ááááá
áááááVOID sortS(n, comp, exch)
áááááint n, (*comp)();
áááááVOID (*exch)();
áááááVOID sortQ(n¼ comp, exch)
áááááint n, (*comp)();
áááááVOID (*exch)();
áááááVOID sortB(n, comp, exch)
áááááint n, (*comp)();
áááááVOID (*exch)();
áááááVOI─ qsort(base¼ n¼ width¼ compar)
áááááSTRIN╟ base;
áááááin⌠ n, width, (*compar)();
DESCRIPTION
áááááEacΦá oµá thesσ function≤ wil∞ sor⌠ aε arra∙ oµ sizσ néá witΦ ì
ááááárespec⌠á t∩á ßá comparisoε functioεá comp(i¼á j)¼á whicΦá i≤ ì
ááááápositive¼á iµ anΣ onl∙ iµ element≤ ié anΣ jé oµ thσ arra∙á arσ ì
áááááou⌠á oµ order«á Thσ exch(i¼á j)é functioε exchange≤ thσ ithô ì
áááááanΣ jthô element≤ oµ thσ array«á Thσ namσ anΣ typσ oµá arra∙ ì
áááááarσ unknowε t∩ thσ sor⌠ routines¼á bu⌠ must¼á oµ course¼á bσ ì
áááááknowε t∩ exché anΣ comp.
ááááásortHéá use≤ thσ heapsor⌠ algorithm¼á witΦ timσá complexit∙ ì
áááááO(ε ¬ log(n))« (Seσ Referencσ 10¼ pp« 87-92.)
ááááásortSé use≤ thσ Shel∞ sor⌠ algorithm¼ witΦ timσ complexit∙ oµ ì
áááááabou⌠ O(n1.5)« (Seσ Reference≤ ▓ anΣ 9.)
ááááásortQéá use≤ thσ quicksor⌠ algorithm¼á oµ timσá complexit∙ ì
áááááO(ε ¬ log(n)⌐ t∩ O(n2)« (Seσ Referencσ 11.)
ááááásortBé perform≤ ß bubble-sor⌠ iε whicΦ largσ value≤ bubblσ u≡ ì
áááááand low values shuttle down in the array, O(n) to O(n2).
áááááqsortéá i≤ anothe≥ implementatioε oµ thσ quicksor⌠ algorithm« ì
áááááThσ baseé i≤ ß pointe≥ t∩ thσ beginninτ oµ thσ data╗ né i≤ thσ ì
ááááánumbe≥á oµá elements╗á thirΣ i≤ thσ widthé oµ aεá elemen⌠á iε ì
ááááábytes╗á las⌠á i≤á thσ namσ oµ thσ comparisoε routinσá t∩á bσ ì
ááááácalleΣá witΦ tw∩ arguments¼á pointer≤ t∩ thσ element≤á beinτ ì
ááááácompared«á Thσá comparisoε mus⌠ returε aεá intege≥á greate≥ ì
áááááthaε zer∩ iµ anΣ onl∙ iµ thσ element≤ beinτ compareΣ arσ ou⌠ ìèáááááoµ sort.
.paè.hetolower tolower
Conversion to Lower and Upper Case
NAME
ááááátolower, toupper
SYNOPSIS
áááááchar tolower(c)
áááááint c;
áááááchar toupper(c)
áááááint c;
DESCRIPTION
ááááátolower return≤ thσ lowe≥ casσ oµ c¼á iµ c i≤ aεá upper-casσ ì
áááááletter.
ááááátoupperá return≤ thσ uppe≥ casσ oµ c¼á iµ c i≤ ßá lower-casσ ì
áááááletter.
áááááTOLOWERá anΣá TOUPPER arσ thσ macro≤ founΣá iεá heade≥á filσ ì
áááááctype.Φá whicΦ arσ identica∞ t∩ thσ function≤ above¼á excep⌠ ì
áááááfor side-effects.
.paè.heungetc ungetc
Push Character Back into Input Stream
NAME
áááááungetc
SYNOPSIS
ááááá#include <stdio.h>
áááááint ungetc(c, stream)
áááááint c;
áááááFILE *stream;
DESCRIPTION
áááááungetc pushe≤ thσ characte≥ c bacδ oε aε inpu⌠ stream« Tha⌠ ì
ááááácharacte≥á wil∞á bσ returneΣ b∙ thσ nex⌠ getc cal∞á oεá tha⌠ ì
ááááástream. ungetc returns c.
áááááOnσá characte≥ oµ pushbacδ i≤ guaranteeΣ provideΣá somethinτ ì
áááááha≤á beeεá reaΣ froφ thσ streaφ anΣ thσ streaφá i≤á actuall∙ ì
ááááábuffered.
áááááfseek erases all memory of pushed back characters.
SE┼ ALSO
ááááágetc, fseek
DIAGNOSTICS
áááááungetc returns EOF if c is EOF.
.he
.pa oè.PN 1
.FO 5-#
5. C U S T O M I Z A T I O N N O T E S
Therσá arσá approximatel∙ 16▓ function≤ anΣá 16╖á parameter≤ ì
(constants¼ macros¼ anΣ globa∞ variables⌐ name≤ iε thσ portablσ ├ ì
subroutinσ library« Oµ these¼ 1▓ arσ systeφ functions¼ fo≥ whicΦ ì
sourcσá codσ i≤ no⌠ included¼á anΣ anothe≥ 14╡ function≤ anΣá 15▓ ì
parameter≤ tha⌠ arσ machine-independent« Onσ oµ thσ system-leve∞ ì
function≤ anΣ thσ remaininτ ╡ function≤ anΣ 5╢ parameter≤ mus⌠ bσ ì
customizeΣá t∩ thσ ideosyncracie≤ oµ thσ hos⌠á environment«á Thσ ì
systeφ interfacσ function≤ arσ listeΣ iε Tablσ 5-1¼á thσ element≤ ì
tha⌠á mus⌠á bσ giveε attentioε arσ listeΣ iε Tablσ 5-2¼á anΣá thσ ì
machine-independen⌠á element≤á arσá giveεá iεá Tablσá 5-3«áá Al∞ ì
elements are listed in Table 5-4.
Thσá procedure≤á fo≥ effectinτ thσ needeΣ change≤á froφá thσ ì
distributioεá sourcσá i≤á containeΣá iεá thσá remainde≥á oµá thi≤ ì
section.
.po11
Table 5-1: PORTABLE C LIBRARY SYSTEM INTERFACE
Element Type File Description
close function csys.lib Close file OS interface.
creat function csys.lib Create file function, OS interface.
exit function csys.lib Close all files and terminate program.
lseek function csys.lib Move file position using arg as offset.
open function csys.lib Open file for operation, OS interface.
read function csys.lib Read from stream into buffer: OS interfc
rename function csys.lib Rename a file: OS interface.
sbrk function csys.lib Set pointer to available memory: OS i/f.
unlink function csys.lib Unlink a file name from a file (delete).
write function csys.lib File write OS interface.
_exit function csys.lib Immediate termination of program.
.paè Table 5-2: PORTABLE C LIBRARY COMPILER- & SYSTEM-DEPENDENT ELEMENTS
Element Type File Description
ALIGN typedef stdtyp.h K & R storage allocation header aligner.
ALTSCRN TEXT scrnio.h Terminal into alternate intensity string
astof function atof.c ASCII number to (double) float. Pointer.
BIG10X constant mathcons.h Largest 10^(2^(BIG10X -1)) < INFINITY
BIGX constant mathcons.h 16 * log2(INFINITY) - 1
BUFSIZ constant stdio.h I/O stream buffer size.
CB4L TBOOL scrnio.h Column-before-row boolean.
chrstc function chrstc.c Return int characteristic of double.
CLEARSCREEN TEXT scrnio.h Terminal clear-screen string.
COFFSET tiny scrnio.c Cursor lead-in column offset value.
CRINSUP constant stdio.h Set TRUE to suppress CR text input.
CROUTADD constant stdio.h Set true to echo '\n' with CR.
DPRECISION constant mathcons.h (int) PRECISION
EDOM constant errno.h Function argument not in defined domain.
EOF constant defs.h Standard End-of-File value.
ERAEOLN TEXT scrnio.c Terminal Erase-to-End-of-Line string.
ERAEOPG TEXT scrnio.h Terminal erase-to-end-of-page string.
fint function fint.c Float (double) INTeger-part function.
ftoa function ftoa.c Float (double) to ASCII conversion.
HEIGHT tiny scrnio.h Terminal height, number of lines.
HOME string scrnio.h Terminal cursor-to-home (0,0) string.
INFINITY constant mathcons.h Largest double value on this machine.
INFINLEG constant math.cons INFINITY / ROOTTWO.
ldexp function frexp.c Load exponent (multiply by power of 2).
LEADIN TEXT scrnio.h Cursor lead-in sequence.
LEAST constant mathcons.h Least double representable in machine.
LINDELETE TEXT scrnio.c Terminal line-delete string.
LININSERT TEXT scrnio.h Terminal line-delete string.
LOGINFINITY constant mathcons.h Largest argument of log function.
LOGLEAST constant mathcons.h Log of smallest machine number
mathcons.h header mathcons.h Constant file for math functions.
MAXCHANNELS constant global.h Maximum number of i/o channels at once.
MAXEXP constant mathcons.h Largest numeric characteristic.
MAXEXPG constant mathcons.h MAXEXP - 3 guard bits.
MAXLINE constant stdio.h Maximum no. of chars. on input line.
MAXSTREAM constant stdio.h Maximum number of buffered i/o streams.
MINEXP constant mathcons.h Characteristic of least machine double.
MINEXPG constant mathcons.h MINEXP + 3 guard bits.
NALLOC constant stdtyp.h No. of HEADER units for malloc().
NORMSCRN TEXT scrnio.h Terminal string, return normal intensity
PMODE constant stdio.h fopen() protection mode (for UNIX).
PRECISION constant mathcons.h -log10(WASHOUT).
RCENDER TEXT scrnio.h Row-column lead-in terminator.
RCSEPARATOR TEXT scrnio.h Cursor row, column separator string.
rename function csys.lib Rename a file: OS interface.
ROFFSET tiny scrnio.h Cursor lead-in row offset value.
RTHLFINF constant mathcons.h sqrt(INFINITY / 2).
SCRNINI TEXT scrnio.h Initialize-terminal string.
SCRNUNI TEXT scrnio.h Terminal un-initialize string.
SCRNWRAP TBOOL scrnio.h Signal for auto terminal wrap-around.
SMALLX constant mathcons.h 16 * log2(LEAST) + 1.0 è
PORTABL┼ ├ LIBRAR┘ COMPILER- ª SYSTEM-DEPENDEN╘á ELEMENT╙ (cont.)
Element Type File Description
SYMLEAST constant mathcons.h Symmetric Least value (1/SYMLEAST) exist
SYS_EOF macro stdio.h System end-of-file marker, if any.
TANHXBIG constant mathcons (No. sig bits + 2) * log(2) / 2
TBITS typedef stdtyp.h Tiny (8 char min) for bit manipulation.
TBOOL typedef stdtyp.h Tiny (8 char min) used tor boolean.
TERMINAL TEXT scrnio.h Terminal identification string.
TINY macro stdtyp.h rvalue for tiny.
USELAST TBOOL scrnio.h Signal to use final terminal column.
UTINY macro stdtyp.h rvalue for utiny.
WASHOUT constant mathcons.h 1.0 + (x < WASHOUT) = 1.0 to precision.
WIDTH tiny scrnio.h Terminal width, number of characters.
XLT2ASCII TBOOL scrnio.h Translate-to-ASCII boolean.
.paè
Table 5-3: PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS
Element Type File Description
ABS macro defs.h Absolute value of any numeric type.
abs function abs.c Absolute value function, int.
acos function asin.c arc cosine, double.
allot function malloc.c malloc() without header overhead.
altscrn function scrnio.c Set terminal to alternate intensity.
AND macro defs.h Logical "and" operator, &&.
asin function asin.c Arc sine function, double.
astoi function atoi.c ASCII int to int. Also returns pointer.
astol function atol.c ASCII to long. Also returns pointer.
atan function atan.c Arc tangent, double.
atan2 function atan.c Two-argument arc tangent, double.
atof function atof.c ASCII to (double) float.
atoi function atoi.c ASCII to int.
atol function atol.c ASCII to long.
bitcount function bitcount.c K & R function counts bits in argument.
BITS typedef stdtyp.h Short used only for bit manipulation.
BOOL typedef stdtyp.h Int used only for boolean.
BUFFER typedef stdtyp.h Used only for pointers to char buffers.
calloc function malloc.c C allocation for arrays.
cbrt function cbrt.c Cube root function, double.
CBRTFOUR constant mathcons.h Cube root of 4.
CBRTTWO constant mathcons.h Cube root of 2.
ceil function floor.c Ceiling function of double.
clearerr macro stdio.h Reset error indicator on file stream.
clrscrn function scrnio.c Clear terminal screen.
cos function sin.c Cosine function, double.
cosh function cosh.c Hyperbolic cosine, double.
cotan function tan.c Cotangent function, double.
CURPOS constant stdio.h Current file position seek indicator.
cursor function scrnio.c Position terminal cursor at row, column.
eprintf function eprintf.c Formatted print to stderr.
eputc macro stdio.c Put character out to stderr.
eputs function eputs.c Put string out to stderr.
eraeol function scrnio.c Erase terminal screen to end of line.
eraeop function scrnio.c Erase terminal screen to end of page.
ERANGE constant errno.h Computed math value out of range.
erf function erf.c Error function, double.
erfc function erf.c Complimentary error function, double.
errno short global.h Standard error variable.
exp function exp.c Exponential function, double.
fabs function fabs.c Absolute value function, double.
FADEOUT constant mathcons.h Magnitude of washout term in Taylor ser.
FAIL constant defs.h Standard Failure value.
FALSE constant defs.h Standard False value.
fclosall function putc.c Close all buffered i/o streams.
fclose function fopen.c Close file using descriptor.
feof macro stdio.h Evaluate end-of-file status, int.
ferror macro stdio.h Boolean for file i/o error.
fflush function fopen.c Flush file buffers to the medium.
fgets function fgets.c Get string from file (buffered). è
PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)
Element Type File Description
FILE typedef stdio.h Standard file type declaration.
FILEND constant stdio.h File end seek position designator.
fileno macro stdio.h Return file descriptor of stream.
floor function floor.c Floor function, double.
flush function putc.c Flush output buffer when char overflow.
fmax function fminmax.c Maximum of a, b, double.
fmin function fminmax.c Minimum of a, b, double.
fopen function fopen.c Open file for buffered operation.
FOREVER macro defs.h Same as "for (::)".
format function format.c Basic output format utility.
FOURTHLOG2 constant mathcons.h log(2) / 4
fprintf function fprintf.c Formatted output to file.
fputs function fputs.c Put string out to file, unformatted.
frac function frac.c Fractional-part function, double.
fread function fread.c Buffered read from file.
free function malloc.c Free previously allocated storage.
frexp function frexp.c Fraction (mantissa) and exponent, double
fscanf function fscanf.c Formatted scan inputs from file.
fseek function fseek.c Buffered file reposition function.
ftell function ftell.c Return current file offset from origin.
fwrite function fwrite.c Buffered write to file.
getbuf function getbuf.c Get an i/o buffer from allot().
getc function getc.c Get character from file.
getca function getc.c Get ASCII char from buffered i/o stream.
getchar macro stdio.c Get character from stdin.
getf function getf.c Prompt and get double from stdin.
geti function geti.c Prompt and get integer from stdin.
getl function getl.c Prompt and get long from stdin.
getns function getns.c Prompt and get string from stdin.
gets function gets.c Get string from stdin.
GLOBAL macro stdtyp.h Pseudo storage class (extern) for port.
GZ macro defs.h Greater than Zero, GZ(x) = (x>0? x : 0)
HALFLOG2e constant mathcons.h log2(e) / 4
HEADER typedef stdtyp.h K & R storage allocation block type.
home function scrnio.c Home the terminal cursor.
hypot function hypot.c Compute hypotenuse of right triangle.
index function index.c Find position of char in string arg.
iniscrn function scrnio.c Initialize terminal screen output.
inverf function inverf.c Inverse of error function, erf, double.
inverfc function inverf.c Inverse of complementart error function.
INVPI constant mathcons.h 1.0 / pi
IObuffs buffers stdio.h I/O buffers for buffered streams.
IS macro defs.h Logical equivalence operator, ==.
isalnum function isalnum.c True if arg is alpha or number.
ISALNUM macro ctype.h True if arg is alpha or number.
isalpha function isalpha.c True if arg is alpha.
ISALPHA macro ctype.h True if arg is alpha.
isascii function isascii.c True if arg is < 128.
ISASCII macro ctype.h True if arg < 128.
iscntrl function iscntrl.c True if arg is control or DEL character. è
PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)
Element Type File Description
ISCNTRL macro ctype.h True if arg is control or DEL character.
isdigit function isdigit.c True if arg is decimal digit.
ISDIGIT macro ctype.h True if arg is decimal digit.
ishex function ishex.c Returns TRUE if argument is hex number.
islower function islower.c True if arg is lower-case alpha.
ISLOWER macro ctype.h True if arg is lower case alpha.
ISNT macro defs.h Logical non-equivalence operator, !=.
ISOCTAL macro ctype.h True if arg is octal character.
isoctal function isoctal.c Returns TRUE if argument is octal digit.
isok function isok.c Prompts and accepts y/n answer.
isprint function isprint.c True if arg is printable character.
ISPRINT macro ctype.h True if arg is printable character.
ispunct function ispunct.c True if arg is punctuation.
ISPUNCT macro ctype.h True if arg is not cntrl or alphanum.
isspace function isspace.c True if arg is space, tab, or newline.
ISSPACE macro ctype.h True if arg is space, tab, or newline.
isupper function isupper.c True if arg is upper-case alpha.
ISUPPER macro ctype True if arg is upper case alpha.
itoa function itoa.c Integer-to-Ascii conversion.
itoab function itoa.c Based int-ASCII conversion.
labs function labs.c Absolute value function, long.
LBITS typedef stdtyp.h Long used only for bit manipulation.
liberate function malloc.c free() without header overhead.
lmax function lminmax.c Maximum of a, b: long.
lmin function lminmax.c Minimum of a, b: long.
log function log.c Natural logarithm, double.
log10 function log10.c Common logarithm, double.
LOG10e constant mathcons.h Log of e base 10.
LOG10two constant mathcons.h log of 2 base 10.
log2 function log2.c Logarithm, base 2, double.
LOG2 constant mathcons.h Natural log of 2.
LOG2e constant mathcons.h Log of e base 2.
LOGe10 constant mathcons.h log of 10 base e.
ltoa function ltoa.c Long-to-ASCII conversion.
ltoab function ltoa.c Long to base conversion.
LURSHIFT macro defs.h Long Unsigned Right Shift long n, b bits
malloc function malloc.c Storage allocator: get memory from OS.
max function max.c Maximum of two integers.
MAX macro defs.h Maximum value of any two numbers.
MAXANGLE constant mathcons.h Maximum trigonometric angle, pi * 2^25.
METACHAR typedef stdtyp.h Augmented char to include EOF value.
min function min.c Minimum of two integer values.
MIN macro defs.h Minimum value of any two numeric values.
modf function modf.c Fraction and integer parts, double.
NO constant defs.h Standard NOt true value.
normscrn function scrnio.c Return terminal to normal intensity.
NOT macro defs.h Logical negation operator, !.
nprob function nprob.c Normal probability function.
nprobc function nprob.c Normal probability tail function, double
NULL constant defs.h Standard NULL pointer value. è
PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)
Element Type File Description
OR macro defs.h Logical inclusive-or operator, ||.
ORIGIN constant stdio.h Beginning of file seek designator.
outcol int array global.h Global variable, output column for chan.
outrow int array global.h Global variable, output row for channel.
PI constant mathcons.h pi
PIover2 constant mathcons.h pi / 2
PIover3 constant mathcons.h pi / 3
PIover4 constant mathcons.h pi / 4
PIover6 constant mathcons.h pi / 6
pow function pow.c Power: raise x to y power, double.
printf function printf.c Formatted print to stdout.
progname TEXT global.h Standard global string to hold prog name
putc function putc.c Buffered char output to stream.
putca function putc.c Buffered ASCII character output.
putchar macro stdio.h Put car out to stdout.
puts function puts.c Put string out to stdout.
putscrn function scrnio.c Put character directly to screen, unbuff
qsort function qsort.c Quicksort an array.
randexp function randexp.c Random number, double, exponential dist.
randize function random.c Seed the random number generator.
randnorm function randnorm.c Random number, double, normal distrib.
random function random.c Random number, double, uniform distrib.
ratfun function ratfun.c Rational function evaluation, double.
realloc function realloc.c Change storage allocator block size.
redirbuf function redirbuf.c Set redirected i/o buffer size.
rewind function rewind.c Rewind buffered i/o medium to beginning.
rindex function rindex.c Find last occurrence of char in string.
rknstep function rknstep.c 4-th order Runge-Kutta n-th order DE.
rkstep function rkstep.c 4-th order Runge-Kutta 1-st order DE.
ROOTHALF constant mathcons.h sqrt(0.5)
ROOTTWO constant mathcons.h sqrt(2.0)
round function round.c Round to nearest integer, double.
scanf function scanf.c Formatted scan input from stdin.
setbuf function setbuf.c Assign memory buffer to i/o stream.
SGN macro defs.h Sign value: +1, 0, -1, any numeric type.
sgn function sgn.c Sign function: +1, 0, -1, double.
simpson function simpson.c Integration by Simpson's modified rule.
sin function sin.c Sine function, double.
sinh function sinh.c Hyperbolic sine, double.
sortB function sortB.c Bubble-sort array in memory, in-place.
sortH function sortH.c Heapsort an array, in-place in memory.
sortQ function sortQ.c Quicksort memory array, in place.
sortS function sortS.c Shell-sort memory array, in-place.
sprintf function sprintf.c Formatted output to string buffer.
sqrt function sqrt.c Square-root function, double.
SQRT3 constant mathcons.h sqrt(3)
SQRT3m1 constant mathcons.h sqrt(3.0) - 1.0
sscanf function sscanf.c Formated scan input from string.
STDERR constant stdio.h Standard error output device number.
stderr macro stdio.h Standard buffered i/o error stream. è
PORTABLE C LIBRARY SYSTEM-INDEPENDENT ELEMENTS (cont.)
Element Type File Description
STDIN constant stdio.h Standard input device number.
stdin macro stdio.h Standard buffered input stream.
STDOUT constant stdio.h Standard output device number.
stdout macro stdio.h Standard buffered output stream.
stradd function stradd.c Multiple string concatenation.
strcat function strcat.c Concatenate two strings.
strcmp function strcmp.c Compare two strings lexicographically.
strcpy function strcpy.c copy one string to another.
streql function streql.c Returns TRUE if strings are equal.
strindex function strindex.c Locate one string in another.
STRING typedef stdtyp.h Used only for pointers to strings.
strlen function strlen.c Compute length of string.
strncat function strncat Concatenate strings up to n chars.
strncmp function strncmp.c Compare strings up to n chars.
strncpy function strncpy.c Copy one string to another, up to n char
strsave function strsave.c Save (copy) a string to heap storage.
SUCCESS constant defs.h Standard non-FAIL value.
TABSTOP macro stdio.h Number of spaces per tab stop.
tan function tan.c Tangent function, double.
tanh function tanh.c Hyperbolic tangent, double.
TEXT typedef stdtyp.h Used only for ASCII printable characters
tiny typedef stdtyp.h A char used for signed int work.
tolower function tolower.c Convert arg to lower-case, if upper.
TOLOWER macro ctype.h Convert arg to lower-case, if upper.
toupper function toupper.c Convert to upper case, if lower.
TOUPPER macro ctype.h Convert arg to upper case, if lower.
TRUE constant defs.h Standard truth value.
TWOLOG2e constant mathcons.h 2 * log2(e)
TWOmSQRT3 constant mathcons.h 2 - sqrt(3)
TWOoverPI constant mathcons.h 2.0 / pi
unformat function unformat.c Basic scan function, arbitrary medium.
ungetc function ungetc.c Put char back into input stream.
uniscrn function scrnio.c Uninitialize terminal screen.
urandom function random.c Random number, unsigned, uniform distrib
URSHIFT macro defs.h Unsigned Right Shift, unsigned n, b bits
utiny typedef stdtyp.h A char used for unsigned int work.
utoa function utoa.c Unsigned to ASCII conversion.
VOID typedef stdtyp.h Used for function returning no value.
YES constant defs.h Standard truth value.
_ALLBUFF constant stdio.h Allocated buffer flag mask.
_BUSY constant stdio.h File open (busy) flag mask.
_EOF constant stdio.h Buffered stream end-of-file flag mask.
_IOERR constant stdio.h Buffered stream i/o error mask.
_RDONLY constant stdio.h File open signal to read only.
_RDWRIT constant stdio.h File open signal for read and write.
_WRONLY constant stdio.h File open signal for write-only access.
.paè.po6
Table 5-4: PORTABLE C LIBRARY ELEMENTS
Element Type File Portable Description
ABS macro defs.h yes Absolute value of any numeric type.
abs function abs.c yes Absolute value function, int.
acos function asin.c yes arc cosine, double.
ALIGN typedef stdtyp.h customize K & R storage allocation header aligner.
allot function malloc.c yes malloc() without header overhead.
altscrn function scrnio.c yes Set terminal to alternate intensity.
ALTSCRN TEXT scrnio.h customize Terminal into alternate intensity string
AND macro defs.h yes Logical "and" operator, &&.
asin function asin.c yes Arc sine function, double.
astof function atof.c customize ASCII number to (double) float. Pointer.
astoi function atoi.c yes ASCII int to int. Also returns pointer.
astol function atol yes ASCII to long. Also returns pointer.
atan function atan.c yes Arc tangent, double.
atan2 function atan.c yes Two-argument arc tangent, double.
atof function atof.c yes ASCII to (double) float.
atoi function atoi.c yes ASCII to int.
atol function atol.c yes ASCII to long.
BIG10X constant mathcons.h customize Largest 10^(2^(BIG10X -1)) < INFINITY
BIGX constant mathcons.h customize 16 * log2(INFINITY) - 1
bitcount function bitcount.c yes K & R function counts bits in argument.
BITS typedef stdtyp.h yes Short used only for bit manipulation.
BOOL typedef stdtyp.h yes Int used only for boolean.
BUFFER typedef stdtyp.h yes Used only for pointers to char buffers.
BUFSIZ constant stdio.h customize I/O stream buffer size.
calloc function malloc.c yes C allocation for arrays.
CB4L TBOOL scrnio.h customize Column-before-row boolean.
cbrt function cbrt.c yes Cube root function, double.
CBRTFOUR constant mathcons.h yes Cube root of 4.
CBRTTWO constant mathcons.h yes Cube root of 2.
ceil function floor.c yes Ceiling function of double.
chrstc function chrstc.c customize Return int characteristic of double.
clearerr macro stdio.h yes Reset error indicator on file stream.
CLEARSCREEN TEXT scrnio.h customize Terminal clear-screen string.
close function csys.lib system Close file OS interface.
clrscrn function scrnio.c yes Clear terminal screen.
COFFSET tiny scrnio.c customize Cursor lead-in column offset value.
cos function sin.c yes Cosine function, double.
cosh function cosh.c yes Hyperbolic cosine, double.
cotan function tan.c yes Cotangent function, double.
creat function csys.lib system Create file function, OS interface.
CRINSUP constant stdio.h customize Set TRUE to suppress CR text input.
CROUTADD constant stdio.h customize Set true to echo '\n' with CR.
CURPOS constant stdio.h yes Current file position seek indicator.
cursor function scrnio.c yes Position terminal cursor at row, column.
DPRECISION constant mathcons.h customize (int) PRECISION
EDOM constant errno.h yes Function argument not in defined domain.
EOF constant defs.h yes Standard End-of-File value.
eprintf function eprintf.c yes Formatted print to stderr.
eputc macro stdio.c yes Put character out to stderr.
eputs function eputs.c yes Put string out to stderr.
eraeol function scrnio.c yes Erase terminal screen to end of line. è
PORTABLE C LIBRARY ELEMENTS (cont.)
Element Type File Portable Description
ERAEOLN TEXT scrnio.c customize Terminal Erase-to-End-of-Line string.
eraeop function scrnio.c yes Erase terminal screen to end of page.
ERAEOPG TEXT scrnio.h customize Terminal erase-to-end-of-page string.
ERANGE constant errno.h yes Computed math value out of range.
erf function erf.c yes Error function, double.
erfc function erf.c yes Complimentary error function, double.
errno short global.h yes Standard error variable.
exit function csys.lib system Close all files and terminate program.
exp function exp.c yes Exponential function, double.
fabs function fabs.c yes Absolute value function, double.
FADEOUT constant mathcons.h yes Magnitude of washout term in Taylor ser.
FAIL constant defs.h yes Standard Failure value.
FALSE constant defs.h yes Standard False value.
FAST macro stdtyp.h customize Pseudo storage class (register).
fclosall function putc.c yes Close all buffered i/o streams.
fclose function fopen.c yes Close file using descriptor.
feof macro stdio.h yes Evaluate end-of-file status, int.
ferror macro stdio.h yes Boolean for file i/o error.
fflush function fopen.c yes Flush file buffers to the medium.
fgets function fgets.c yes Get string from file (buffered).
FILE typedef stdio.h yes Standard file type declaration.
FILEND constant stdio.h yes File end seek position designator.
fileno macro stdio.h yes Return file descriptor of stream.
fint function fint.c customize Float (double) INTeger-part function.
floor function floor.c yes Floor function, double.
flush function putc.c yes Flush output buffer when char overflow.
fmax function fminmax.c yes Maximum of a, b, double.
fmin function fminmax.c yes Minimum of a, b, double.
fopen function fopen.c yes Open file for buffered operation.
FOREVER macro defs.h yes Same as "for (::)".
format function format.c yes Basic output format utility.
FOURTHLOG2 constant mathcons.h yes log(2) / 4
fprintf function fprintf.c yes Formatted output to file.
fputs function fputs.c yes Put string out to file, unformatted.
frac function frac.c yes Fractional-part function, double.
fread function fread.c yes Buffered read from file.
free function malloc.c yes Free previously allocated storage.
frexp function frexp.c yes Fraction (mantissa) and exponent, double
fscanf function fscanf.c yes Formatted scan inputs from file.
fseek function fseek.c yes Buffered file reposition function.
ftell function ftell.c yes Return current file offset from origin.
ftoa function ftoa.c customize Float (double) to ASCII conversion.
fwrite function fwrite.c yes Buffered write to file.
getbuf function getbuf.c yes Get an i/o buffer from allot().
getc function getc.c yes Get character from file.
getca function getc.c yes Get ASCII char from buffered i/o stream.
getchar macro stdio.c yes Get character from stdin.
getf function getf.c yes Prompt and get double from stdin.
geti function geti.c yes Prompt and get integer from stdin.
getl function getl.c yes Prompt and get long from stdin. è
PORTABLE C LIBRARY ELEMENTS (cont.)
Element Type File Portable Description
getns function getns.c yes Prompt and get string from stdin.
gets function gets.c yes Get string from stdin.
GLOBAL macro stdtyp.h yes Pseudo storage class (extern) for port.
GZ macro defs.h yes Greater than Zero, GZ(x) = (x>0? x : 0)
HALFLOG2e constant mathcons.h yes log2(e) / 4
HEADER typedef stdtyp.h yes K & R storage allocation block type.
HEIGHT tiny scrnio.h customize Terminal height, number of lines.
home function scrnio.c yes Home the terminal cursor.
HOME string scrnio.h customize Terminal cursor-to-home (0,0) string.
hypot function hypot.c yes Compute hypotenuse of right triangle.
index function index.c yes Find position of char in string arg.
INFINITY constant mathcons.h customize Largest double value on this machine.
INFINLEG constant math.cons customize INFINITY / ROOTTWO.
iniscrn function scrnio.c yes Initialize terminal screen output.
inverf function inverf.c yes Inverse of error function, erf, double.
inverfc function inverf.c yes Inverse of complementart error function.
INVPI constant mathcons.h yes 1.0 / pi
IObuffs buffers stdio.h yes I/O buffers for buffered streams.
IS macro defs.h yes Logical equivalence operator, ==.
isalnum function isalnum.c yes True if arg is alpha or number.
ISALNUM macro ctype.h yes True if arg is alpha or number.
isalpha function isalpha.c yes True if arg is alpha.
ISALPHA macro ctype.h yes True if arg is alpha.
isascii function isascii.c yes True if arg is < 128.
ISASCII macro ctype.h yes True if arg < 128.
iscntrl function iscntrl.c yes True if arg is control or DEL character.
ISCNTRL macro ctype.h yes True if arg is control or DEL character.
isdigit function isdigit.c yes True if arg is decimal digit.
ISDIGIT macro ctype.h yes True if arg is decimal digit.
ishex function ishex.c yes Returns TRUE if argument is hex number.
islower function islower.c yes True if arg is lower-case alpha.
ISLOWER macro ctype.h yes True if arg is lower case alpha.
ISNT macro defs.h yes Logical non-equivalence operator, !=.
ISOCTAL macro ctype.h yes True if arg is octal character.
isoctal function isoctal.c yes Returns TRUE if argument is octal digit.
isok function isok.c yes Prompts and accepts y/n answer.
isprint function isprint.c yes True if arg is printable character.
ISPRINT macro ctype.h yes True if arg is printable character.
ispunct function ispunct.c yes True if arg is punctuation.
ISPUNCT macro ctype.h yes True if arg is not cntrl or alphanum.
isspace function isspace.c yes True if arg is space, tab, or newline.
ISSPACE macro ctype.h yes True if arg is space, tab, or newline.
isupper function isupper.c yes True if arg is upper-case alpha.
ISUPPER macro ctype yes True if arg is upper case alpha.
itoa function itoa.c yes Integer-to-Ascii conversion.
itoab function itoa.c yes Based int-ASCII conversion.
labs function labs.c yes Absolute value function, long.
LBITS typedef stdtyp.h yes Long used only for bit manipulation.
ldexp function frexp.c customize Load exponent (multiply by power of 2).
LEADIN TEXT scrnio.h customize Cursor lead-in sequence. è
PORTABLE C LIBRARY ELEMENTS (cont.)
Element Type File Portable Description
LEAST constant mathcons.h customize Least double representable in machine.
liberate function malloc.c yes free() without header overhead.
LINDELETE TEXT scrnio.c customize Terminal line-delete string.
LININSERT TEXT scrnio.h customize Terminal line-delete string.
lmax function lminmax.c yes Maximum of a, b: long.
lmin function lminmax.c yes Minimum of a, b: long.
LOCAL macro stdtyp.h customize Pseudo storage class (static) for port.
log function log.c yes Natural logarithm, double.
log10 function log10.c yes Common logarithm, double.
LOG10e constant mathcons.h yes Log of e base 10.
LOG10two constant mathcons.h yes log of 2 base 10.
log2 function log2.c yes Logarithm, base 2, double.
LOG2 constant mathcons.h yes Natural log of 2.
LOG2e constant mathcons.h yes Log of e base 2.
LOGe10 constant mathcons.h yes log of 10 base e.
LOGINFINITY constant mathcons.h customize Largest argument of log function.
LOGLEAST constant mathcons.h customize Log of smallest machine number
lseek function csys.lib system Move file position using arg as offset.
ltoa function ltoa.c yes Long-to-ASCII conversion.
ltoab function ltoa.c yes Long to base conversion.
LURSHIFT macro defs.h yes Long Unsigned Right Shift long n, b bits
malloc function malloc.c yes Storage allocator: get memory from OS.
max function max.c yes Maximum of two integers.
MAX macro defs.h yes Maximum value of any two numbers.
MAXANGLE constant mathcons.h yes Maximum trigonometric angle, pi * 2^25.
MAXCHANNELS constant global.h customize Maximum number of i/o channels at once.
MAXEXP constant mathcons.h customize Largest numeric characteristic.
MAXEXPG constant mathcons.h customize MAXEXP - 3 guard bits.
MAXLINE constant stdio.h customize Maximum no. of chars. on input line.
MAXSTREAM constant stdio.h customize Maximum number of buffered i/o streams.
METACHAR typedef stdtyp.h yes Augmented char to include EOF value.
min function min.c yes Minimum of two integer values.
MIN macro defs.h yes Minimum value of any two numeric values.
MINEXP constant mathcons.h customize Characteristic of least machine double.
MINEXPG constant mathcons.h customize MINEXP + 3 guard bits.
modf function modf.c yes Fraction and integer parts, double.
NALLOC constant stdtyp.h customize No. of HEADER units for malloc().
NO constant defs.h yes Standard NOt true value.
normscrn function scrnio.c yes Return terminal to normal intensity.
NORMSCRN TEXT scrnio.h customize Terminal string, return normal intensity
NOT macro defs.h yes Logical negation operator, !.
nprob function nprob.c yes Normal probability function.
nprobc function nprob.c yes Normal probability tail function, double
NULL constant defs.h yes Standard NULL pointer value.
open function csys.lib system Open file for operation, OS interface.
OR macro defs.h yes Logical inclusive-or operator, ||.
ORIGIN constant stdio.h yes Beginning of file seek designator.
outcol int array global.h yes Global variable, output column for chan.
outrow int array global.h yes Global variable, output row for channel.
PI constant mathcons.h yes pi è
PORTABLE C LIBRARY ELEMENTS (cont.)
Element Type File Portable Description
PIover2 constant mathcons.h yes pi / 2
PIover3 constant mathcons.h yes pi / 3
PIover4 constant mathcons.h yes pi / 4
PIover6 constant mathcons.h yes pi / 6
PMODE constant stdio.h customize fopen() protection mode (for UNIX).
pow function pow.c yes Power: raise x to y power, double.
PRECISION constant mathcons.h customize -log10(WASHOUT).
printf function printf.c yes Formatted print to stdout.
progname TEXT global.h yes Standard global string to hold prog name
putc function putc.c yes Buffered char output to stream.
putca function putc.c yes Buffered ASCII character output.
putchar macro stdio.h yes Put car out to stdout.
puts function puts.c yes Put string out to stdout.
putscrn function scrnio.c yes Put character directly to screen, unbuff
qsort function qsort.c yes Quicksort an array.
randexp function randexp.c yes Random number, double, exponential dist.
randize function random.c yes Seed the random number generator.
randnorm function randnorm.c yes Random number, double, normal distrib.
random function random.c yes Random number, double, uniform distrib.
ratfun function ratfun.c yes Rational function evaluation, double.
RCENDER TEXT scrnio.h customize Row-column lead-in terminator.
RCSEPARATOR TEXT scrnio.h customize Cursor row, column separator string.
read function csys.lib system Read from stream into buffer: OS interfc
realloc function realloc.c yes Change storage allocator block size.
redirbuf function redirbuf.c yes Set redirected i/o buffer size.
rename function csys.lib customize Rename a file: OS interface.
rewind function rewind.c yes Rewind buffered i/o medium to beginning.
rindex function rindex.c yes Find last occurrence of char in string.
rknstep function rknstep.c yes 4-th order Runge-Kutta n-th order DE.
rkstep function rkstep.c yes 4-th order Runge-Kutta 1-st order DE.
ROFFSET tiny scrnio.h customize Cursor lead-in row offset value.
ROOTHALF constant mathcons.h yes sqrt(0.5)
ROOTTWO constant mathcons.h yes sqrt(2.0)
round function round.c yes Round to nearest integer, double.
RTHLFINF constant mathcons.h customize sqrt(INFINITY / 2).
sbrk function csys.lib system Set pointer to available memory: OS i/f.
scanf function scanf.c yes Formatted scan input from stdin.
SCRNINI TEXT scrnio.h customize Initialize-terminal string.
SCRNUNI TEXT scrnio.h customize Terminal un-initialize string.
SCRNWRAP TBOOL scrnio.h customize Signal for auto terminal wrap-around.
setbuf function setbuf.c yes Assign memory buffer to i/o stream.
SGN macro defs.h yes Sign value: +1, 0, -1, any numeric type.
sgn function sgn.c yes Sign function: +1, 0, -1, double.
simpson function simpson.c yes Integration by Simpson's modified rule.
sin function sin.c yes Sine function, double.
sinh function sinh.c yes Hyperbolic sine, double.
SMALLX constant mathcons.h customize 16 * log2(LEAST) + 1.0
sortB function sortB.c yes Bubble-sort array in memory, in-place.
sortH function sortH.c yes Heapsort an array, in-place in memory.
sortQ function sortQ.c yes Quicksort memory array, in place. è
PORTABLE C LIBRARY ELEMENTS (cont.)
Element Type File Portable Description
sortS function sortS.c yes Shell-sort memory array, in-place.
sprintf function sprintf.c yes Formatted output to string buffer.
sqrt function sqrt.c yes Square-root function, double.
SQRT3 constant mathcons.h yes sqrt(3)
SQRT3m1 constant mathcons.h yes sqrt(3.0) - 1.0
sscanf function sscanf.c yes Formated scan input from string.
STDERR constant stdio.h yes Standard error output device number.
stderr macro stdio.h yes Standard buffered i/o error stream.
STDIN constant stdio.h yes Standard input device number.
stdin macro stdio.h yes Standard buffered input stream.
STDOUT constant stdio.h yes Standard output device number.
stdout macro stdio.h yes Standard buffered output stream.
stradd function stradd.c yes Multiple string concatenation.
strcat function strcat.c yes Concatenate two strings.
strcmp function strcmp.c yes Compare two strings lexicographically.
strcpy function strcpy.c yes copy one string to another.
streql function streql.c yes Returns TRUE if strings are equal.
strindex function strindex.c yes Locate one string in another.
STRING typedef stdtyp.h yes Used only for pointers to strings.
strlen function strlen.c yes Compute length of string.
strncat function strncat yes Concatenate strings up to n chars.
strncmp function strncmp.c yes Compare strings up to n chars.
strncpy function strncpy.c yes Copy one string to another, up to n char
strsave function strsave.c yes Save (copy) a string to heap storage.
SUCCESS constant defs.h yes Standard non-FAIL value.
SYMLEAST constant mathcons.h customize Symmetric Least value (1/SYMLEAST) exist
SYS_EOF macro stdio.h customize System end-of-file marker, if any.
TABSTOP macro stdio.h yes Number of spaces per tab stop.
tan function tan.c yes Tangent function, double.
tanh function tanh.c yes Hyperbolic tangent, double.
TANHXBIG constant mathcons customize (No. sig bits + 2) * log(2) / 2
TBITS typedef stdtyp.h customize Tiny (8 char min) for bit manipulation.
TBOOL typedef stdtyp.h customize Tiny (8 char min) used tor boolean.
TERMINAL TEXT scrnio.h customize Terminal identification string.
TEXT typedef stdtyp.h yes Used only for ASCII printable characters
tiny typedef stdtyp.h yes A char used for signed int work.
TINY macro stdtyp.h customize rvalue for tiny.
tolower function tolower.c yes Convert arg to lower-case, if upper.
TOLOWER macro ctype.h yes Convert arg to lower-case, if upper.
toupper function toupper.c yes Convert to upper case, if lower.
TOUPPER macro ctype.h yes Convert arg to upper case, if lower.
TRUE constant defs.h yes Standard truth value.
TWOLOG2e constant mathcons.h yes 2 * log2(e)
TWOmSQRT3 constant mathcons.h yes 2 - sqrt(3)
TWOoverPI constant mathcons.h yes 2.0 / pi
unformat function unformat.c yes Basic scan function, arbitrary medium.
ungetc function ungetc.c yes Put char back into input stream.
uniscrn function scrnio.c yes Uninitialize terminal screen.
unlink function csys.lib system Unlink a file name from a file (delete).
urandom function random.c yes Random number, unsigned, uniform distrib è
PORTABLE C LIBRARY ELEMENTS (cont.)
Element Type File Portable Description
URSHIFT macro defs.h yes Unsigned Right Shift, unsigned n, b bits
USELAST TBOOL scrnio.h customize Signal to use final terminal column.
utiny typedef stdtyp.h yes A char used for unsigned int work.
UTINY macro stdtyp.h customize rvalue for utiny.
utoa function utoa.c yes Unsigned to ASCII conversion.
VOID typedef stdtyp.h yes Used for function returning no value.
WASHOUT constant mathcons.h customize 1.0 + (x < WASHOUT) = 1.0 to precision.
WIDTH tiny scrnio.h customize Terminal width, number of characters.
write function csys.lib system File write OS interface.
XLT2ASCII TBOOL scrnio.h customize Translate-to-ASCII boolean.
YES constant defs.h yes Standard truth value.
_ALLBUFF constant stdio.h yes Allocated buffer flag mask.
_BUSY constant stdio.h yes File open (busy) flag mask.
_EOF constant stdio.h yes Buffered stream end-of-file flag mask.
_exit function csys.lib system Immediate termination of program.
_IOERR constant stdio.h yes Buffered stream i/o error mask.
_RDONLY constant stdio.h yes File open signal to read only.
_RDWRIT constant stdio.h yes File open signal for read and write.
_WRONLY constant stdio.h yes File open signal for write-only access.
.po 17
Customization Procedure
T∩á customizσ anΣ instal∞ thσ ├ languagσ portablσ subroutinσ ì
(function⌐á librar∙ oε ß ne≈ host¼á thσ procedurσ i≤á roughl∙á a≤ ì
follows:
ááááá1.ááDeterminσá thσá exten⌠ t∩ whicΦ thσ 1░ systeφá function≤ ì
ááááááááágiveεá iεá Tablσ 5-▒ (i.e.¼á al∞ bu⌠ rename⌐á exis⌠á anΣ ì
ááááááááásatisf∙á thσá interfacσ specification≤ iε Sectioεá │á oµ ì
áááááááááthi≤á manual«á Determinσá thσá systeφá run-time-suppor⌠ ì
áááááááááinterfacσá requirement≤á withiεá thσá supplieΣáá librar∙ ì
áááááááááfile(s).
ááááá2.ááPrograφá ß renameé functioε anΣ conver⌠ i⌠ t∩ relocatablσ ì
áááááááááforφáá suitablσá fo≥á thσáá linkinτáá loader«áá Modify¼ ì
áááááááááreprogram¼á o≥ creatσ an∙ oµ thσ 1░ systeφ function≤ anΣ ì
ááááááááábasiπá runtime-suppor⌠ function≤ t∩ makσ theφ conforφ t∩ ì
áááááááááthσ interface¼ anΣ similarl∙ conver⌠ theφ t∩ relocatablσ ì
áááááááááform«áá Iµáá redirecteΣá i/∩á i≤á handleΣá withiεáá thσ ì
áááááááááaccessiblσ systeφ functions¼á alte≥ thesσ a≤ appropriatσ ì
ááááááááát∩á cal∞á redirbuféá t∩ expanΣá stdiεá o≥á stdou⌠á streaφ ì
ááááááááábuffer≤á t∩á BUFSIZ╗á otherwisσá redirecteΣ i/∩á ma∙á bσ ì
áááááááááconsiderably slower.
ááááá3.ááExtrac⌠á thσ remaininτ (conformant⌐ systeφ function≤á iε ì
áááááááááTablσ 5-▒ anΣ al∞ systeφ run-time-suppor⌠ function≤ froφ ì
áááááááááthσ existinτ hos⌠ ├ functioε library¼á anΣ inser⌠ al∞ oµ ì
áááááááááthσ systeφ interfacσ function≤ int∩ ß librar∙ o≥ archivσ ì
áááááááááfilσ usinτ thσ hos⌠ librar∙ maintenancσ program¼ cal∞ i⌠ ìèááááááááácsys.liΓáá (o≥áá csys.a¼áá etc.¼áá dependinτáá oεáá hos⌠ ì
ááááááááárestrictions)«á Observσ topologica∞ sortinτ precedence≤ ì
áááááááááimposed by the system.
ááááá4.ááCustomizσá thσ function≤ anΣ parameter≤ listeΣ iεá Tablσ ì
ááááááááá5-2¼á anΣá recompilσá al∞ function≤ iεá thσá portablσá ├ ì
ááááááááálibrary¼á usinτá thσá hos⌠á ├ compiler¼á int∩á thσá forφ ì
áááááááááexpecteΣá b∙á thσ linkinτ loader«á Combinσá thesσá witΦ ì
ááááááááácsys.liΓáá functions¼ááá observinτáá topologica∞ááá sor⌠ ì
áááááááááprecedences¼á int∩ ß ne≈ librar∙ file¼á cal∞ i⌠ lib0.liΓ ì
ááááááááá(or other, depending on host restrictions).
Iµá thσá origina∞á hos⌠ ├ librar∙á contain≤á function≤á tha⌠ ì
satisf∙á thσ functiona∞ description≤ hereiε giveεá exactly¼á theε ì
the∙á ma∙á bσá extracteΣá froφ thi≤á librar∙á anΣá includeΣá int∩ ì
lib0.lib in lieu of the portable-source version, if desired.
Customization Example
Thσá procedurσá outlineΣá iεá thσá precedinτá paragraph≤á i≤ ì
perhap≤ bes⌠ detaileΣ b∙ illustration«á Thσ followinτ step≤ werσ ì
takeεá t∩á instal∞ thσ portablσ ├ librar∙ function≤ int∩á ßá filσ ì
acceptablσá fo≥á thσá AZTEC-I╔á (Versioεá 1.50¼áá copyrigh⌠á Man° ì
Softwarσ Systems¼á Shrewsbury¼á NJ⌐ ├ compile≥ oε ß microcompute≥ ì
witΦ CP/═ (ß trademarδ oµ Digita∞ Research¼á Inc.¼ Pacifiπ Grove¼ ì
CA⌐á operatinτá system«á Thσ ├ librar∙ filσ delivereΣá witΦá thσ ì
compiler was named libc.lib.
ááááá1.ááStudy of existing system:
áááááááááa« Iε extractinτ thσ systeφ interfacσ froφ libc.lib¼ i⌠ ì
áááááááááwa≤á noteΣ tha⌠ _exité wa≤ absent¼á bu⌠ al∞ othe≥á systeφ ì
áááááááááfunctions were present.
áááááááááb«á Thσá sbrké functioε (anΣ aε internally-useΣá callcpφ ì
áááááááááfunction) did not function properly.
ááááááááác«á Thσá STDI╬ readé functioε alway≤ buffereΣ character≤ ì
áááááááááuntil a newline was received.
ááááááááád«á RedirecteΣ outpu⌠ wa≤ handleΣ withiε thσ ├á system¼ ì
áááááááááanΣ iµ redirecteΣ t∩ ß file¼á wa≤ ver∙ slow¼ onσ writteε ì
ááááááááácharacter per disk access.
áááááááááe«á Thσá ├á run-timσá systeφá invokeΣá strcpy¼á strcat¼ ì
ááááááááástrcmp,éá anΣá strlenéá function≤ withiεá thσá portablσá ├ ì
ááááááááálibrary being installed.
áááááááááf«á Thσ systeφ invokeΣ ß functioε closall_é t∩ flusΦ al∞ ì
áááááááááopeε stream≤ anΣ closσ al∞ files¼ anΣ ß functioε putterré ì
áááááááááto output a character to STDERR.
ááááá2.ááCorrective system actions:
èáááááááááa«á renameéá wa≤ presen⌠ anΣ correc⌠ withiε thσ supplieΣ ì
ááááááááásystem, thus not reprogrammed.
áááááááááb«á Thσá functioεá puterr(c)é wa≤á made¼á equivalen⌠á t∩ ì
áááááááááwrite(STDERR, &c, 1).
ááááááááác«á Thσ _exité functioε wa≤ programmeΣ a≤ ß direc⌠á jum≡ ì
áááááááááto the reboot function of the CP/M operating system.
ááááááááád«á ┴ correctl∙ functioninτ versioε oµ sbrké anΣ callcpφ ì
áááááááááwerσá availablσá iε sourcσ forφ oεá thσá vendor-supplieΣ ì
ááááááááádiskettes╗á thesσá werσ compileΣ anΣ substituteΣ fo≥ thσ ì
áááááááááfunctions extracted from libc.lib.
áááááááááe«á ┴ closeall_é functioε wa≤ programmeΣ t∩ cal∞ fclosallé ì
ááááááááá(ßá functioεá withiε putc)╗á wheneve≥á buffereΣá outpu⌠ ì
áááááááááfunction≤á arσ used¼á outpu⌠ stream≤ arσá thu≤á properl∙ ì
áááááááááflusheΣá anΣ closeΣ b∙ exit«á ┴ dumm∙ fclosallé functioε ì
áááááááááfilσ wa≤ provideΣ merel∙ t∩ closσ al∞ opeε file≤ iεá thσ ì
áááááááááevent output is unbuffered (putc not used).
áááááááááf« Fortunately¼ thσ sourcσ codσ wa≤ availablσ fo≥ read¼ ì
ááááááááás∩á i⌠á wa≤ modifieΣ t∩ delive≥á single-characte≥á inpu⌠ ì
áááááááááimmediately, without waiting for a newline.
ááááááááág«á Sincσ sourcσ codσ wa≤ available¼ i⌠ wa≤ possiblσ t∩ ì
áááááááááalte≥á thσá systeφ crooté functioε t∩ cal∞ redirbuféá wheε ì
áááááááááinpu⌠ o≥ outpu⌠ i≤ redirecteΣ t∩ ß file. Notσ tha⌠ botΦ ì
ááááááááágetcéá anΣá putcéá contaiεá unreachablσá codσá t∩áá invokσ ì
áááááááááredirbuf╗ wheε STDI╬ o≥ STDOU╘ i≤ redirecteΣ t∩ ß file¼ ì
áááááááááit≤ streaφ buffe≥ i≤ thu≤ expandeΣ froφ ▒ t∩ BUFSIZ«á ┴ ì
áááááááááfile¼á dredir.c¼á containinτ ß do-nothinτ dumm∙ redirbufé ì
áááááááááwa≤á supplieΣá fo≥ loadinτ wheε stdio.Φ stream≤ arσá no⌠ ì
áááááááááused.
3. Create system interface library.
Al∞á systeφ function≤ werσ archiveΣ b∙ thσá librar∙á manage≥ ì
functioεá int∩á thσ ├ systeφ interfacσá library¼á csys.lib«á Thσ ì
contents and order of functions in the file are:
supp8080 fsubs puterr uexit callcpm croot
closall dfclose open read write lseek
blkio rename unlink block lsubs sbrk
dredir strlen strcpy strcmp strcat stradd
Notσá tha⌠á i⌠ wa≤ necessar∙ t∩ includσ strlené anΣá othe≥á strinτ ì
function≤á iεá thi≤ file¼á becausσ the∙ werσ invokeΣá withiεá thσ ì
system functions (actually, croot).
4. Customize, compile, and form function library.
Constants¼ floating-poin⌠ numbe≥ formats¼ anΣ othe≥ element≤ ì
t∩ bσ customizeΣ werσ madσ t∩ conforφ witΦ thσ AZTEC-I╔á compile≥ ì
specifications. See the following files for details:è
atof.c chrstc.c defs.h errno.h fint.c frexp.c
ftoa.c global.h mathcons.h scrnio.h stdio.h
stdtyp.h
Al∞á non-matΦ librar∙ function≤ werσ compileΣ anΣá collecteΣ ì
into the file lib0.lib in the following order:
random getf geti getl isok getns
sortB sortH sortS bitcount scrnio printf
eprintf fprintf sprintf fscanf format eputs
sscanf scanf fwrite unformat fputs ftoa
fgets puts putc fopen rewind qsort
fseek fread gets getc redirbuf getbuf
atof strsave realloc sortq atoi setbuf
isupper islower ispunct isoctal ishex isprint
iscntrl isascii isalnum atol malloc rindex
min max lminmax labs itoa ftell
ungetc index ltoa isdigit isspace isalpha
abs utoa tolower toupper strncmp strncal
strindex streql strncpy
┴á separatσ librar∙ file¼á mathlib¼á wa≤ madσ t∩ contaiε thσ ì
mathematical functions:
asin randnorm randexp hypot cosh cbrt
sqrt tanh tan sinh sin nprob
inverf erf rkstep rknstep pow floor
exp log2 log10 log frexp sgn
ratfun fminmax modf chrstc round frac
fint fabs atan simpson
Duσ t∩ thσ fac⌠ tha⌠ thσ vendo≥ linkagσ edito≥ wa≤ incapablσ ì
oµ workinτ witΦ file≤ large≥ tha⌠ 64K¼á i⌠ wa≤ necessar∙ t∩ leavσ ì
the library in these three segments.
.pa oè.heappendix appendix
.PN 1
.FO A-#
A. R E F E R E N C E S
1.áááUNI╪ Programmer'≤ Manual¼ Bel∞ Telephonσ Laboratories¼ Inc.¼ ì
áááááMurra∙ Hill¼ Ne≈ Jersey¼ 1983.
2. ááKernighan¼áá Briaεá W.¼áá anΣá Ritchie¼á Denni≤á M.¼á Thσá ├ ì
áááááProgrammingô Language¼ Prentice-Hall¼ Inc.¼ EnglewooΣ Cliffs¼ ì
áááááNe≈ Jersey¼ 1978.
3.áá Handbooδá oµá Mathematica∞á Functions¼á Nationa∞á Burea⌡á oµ ì
áááááStandard≤á ApplieΣ Mathematic≤ Serie≤ #55¼á U.S«á Governmen⌠ ì
áááááPrintinτ Office¼ Washington¼ D.C.¼ 1964.
4.á Plum¼áá Thomas¼á ├á Programminτá Standard≤á anΣá Guidelines¼ ì
áááááVersioε ╒ (UNI╪ anΣ offspring)¼á Pluφ Hall¼á Inc.¼á Cardiff¼ ì
áááááNe≈ Jersey¼ 1982.
5. ááCoty¼á Williaφ J.¼á Jr.¼ anΣ Waite¼ William¼ Softwarσ Manua∞ ì
áááááfo≥á thσá Elementar∙á Functions¼áá Prentice-Hal∞á Serie≤á iε ì
áááááComputationa∞ Mathematics¼á Prentice-Hall¼á Inc.¼á InglewooΣ ì
áááááCliffs¼ Ne≈ Jersey¼ 1980.
6.á J«á F« Hart¼ E« W« Cheney¼ C« L« Lawson¼ H« J« Maehly¼ C« K« ì
áááááMesztenyi¼á J« R« Rice¼ H« C« Thacher¼ Jr.¼ anΣ C« Witzgall¼ ì
áááááCompute≥ Approximations¼á Johε Wile∙ ª Sons¼ Inc.¼ Ne≈ York¼ ì
áááááNe≈ York¼ 1968.
7.á Schonfelder¼á J«á L.¼ Mathematic≤ oµ Computation¼ Volumσ 32¼ ì
áááááNo. 144¼ October¼ 1978, pp. 1232-1240.
8. áBlair¼á J«á M.¼á et« al.¼ "Rationa∞ Chebyshe÷ Approximation≤ ì
áááááfo≥ thσ Inversσ Erro≥ Function"¼ Mathematic≤ oµ Computation¼ ì
áááááVolumσ 30¼ No. 136¼ October¼ 1976.
9.á Wirth¼á Nicklaus¼á Algorithm≤á ½ Datß Structure≤ ╜ Programs¼ ì
áááááPrentice-Hall¼ Inc.¼ EnglewooΣ Cliffs¼ Ne≈ Jersey¼ 1976«
10.á Aho¼á AlfreΣ v.¼ Hopcroft¼ Johε E.¼ anΣ Ullman¼ Jeffre∙ D.¼ ì
áááááThσá Desigεá anΣ Analysi≤ oµ Compute≥á Algorithms¼á Addison-ì
áááááWesle∙ Publishinτ Company¼ Reading¼ Massachusetts¼ 1975¼ pp« ì
ááááá87-92.
11.á Knuth¼á DonalΣá E.¼á Ar⌠ oµ Compute≥á Programming¼á Vol«á 2¼ ì
áááááSemi-Numerica∞áá Algorithms¼ááá Addison-Wesle∙ááá Publishinτ ì
áááááCompany¼ Reading¼ Massachusetts¼ 1973.
12.ááTausworthe¼á R«á C.¼á "Randoφá number≤á generateΣ b∙á linea≥ ì
ááááárecurrencσ modul∩ two"¼á Mathematic≤ oµ Computation¼á Volumσ ì
ááááá19¼ 1965¼ pp« 201-209.
13.ááPurdom¼áá Jack¼á Thσá ├á Programmer'≤á Library¼á Quσá Corp.¼ ì
áááááIndianapolis, 1984.
è14.ááThσ ├ User'≤ Grou≡ Newsletters¼á McPhereson¼á K« S.¼ Vol« I¼ ì
áááááNo« 1¼ June¼ 1981¼ througΦ Vol« II¼ No« 6¼ March¼ 1985.
15.ááPortablσá ├ Subroutinσá Library¼á Vol«á II¼á Je⌠á Propulsioε ì
áááááLaboratory, 1985.
.pß oè.PN 1
.FO B-#
B. I N D E X
.FI B:USEGUIDE.IDX