C语言库函数大全(字母a)---使用说明(转)
函数名: abort
?#HH/2 7 功 能: 异常终止一个进程
~$:GV1/ 用 法: void abort(void);
`??31,],1 程序例:
1paW_ #include
;K}h^$>] #include
xV,F8"=% int main(void)
=0T#IF2"> {
M?IS0/ printf("Calling abort() *ICyJe~ ");
G>o?pDa abort();
yggr,q return 0; /* This is never reached */
Nzv#e`sE5 }
2L'8%{^~2
'PBrn.@B
0L?h<Mm
COz#}I@nf' 函数名: abs
c: HXw 功 能: 求整数的绝对值
Xb`]Y$Y 用 法: int abs(int i);
[dX+*u]} 程序例:
q?Eb\%K:7X #include
W/-#> & #include
W^|PvzU
@nCDuw&; int main(void)
J_a_k_2> {
BL\XjYQv int number = -1234;
2NSvT6
'b!5u}={m printf("number: %d absolute value: %d BA*8~3^K ", number, abs(number));
l!ume/>s return 0;
: JN
xAr }
-k|xYKC
lsp\Gn<
b
/R7O9ta
&4mF[- 函数名: absread, abswirte
z{|2x
mE 功 能: 绝对磁盘扇区读、写数据
P,@h$7Ne 用 法: int absread(int drive, int nsects, int sectno, void *buffer);
K.k|~# int abswrite(int drive, int nsects, in tsectno, void *buffer);
"2=Y+l'OA 程序例:
'q?mc0{U /* absread example */
v3L@pA`
6GEW'9Qg #include
l0;rTs #include
?EG~uic' #include
3'
/ vV
[ #include
5mU('[R
Iy^^g int main(void)
Lm%DBQ
{
3'"U7u2L int i, strt, ch_out, sector;
.@1:Yv char buf[512];
ds[f#r^U
=7pk3 ^IO printf("Insert a diskette into drive A and press any key {?}@m1k ");
aOiy1eX getch();
.K[lV{9$ sector = 0;
(q> if (absread(0, 1, sector, &buf) != 0)
?\gA63s {
b5WD ;{@X perror("Disk problem");
$d+Ll
q6E exit(1);
/tAI=>VcIL }
.dpG$gK
printf("Read OK >3MiFUu ");
+B/Zq\sk# strt = 3;
C*@Gh.%a for (i=0; i<80; i++)
uYq]MZ {
TNq[9>lpr ch_out = buf[strt+i];
xoq8;q'.I putchar(ch_out);
/M~+&YV }
!Wyzt(3[ printf(" ;Fxc0$$& ");
NyS+BlK\y return(0);
ISHhKOz"Y }
-L7
v<#[L{
EQ4 y_Y
+e<r0%
,-%/$Y.>
2[ j-%ZFG 函数名: access
0!V={+:B 功 能: 确定文件的访问权限
&,C=-F)} 用 法: int access(const char *filename, int amode);
Ro0925IS^ 程序例:
`<{>k-ZZ #include
&q+FM4gS' #include
uF-SU[4@O8
m0^eA)61v int file_exists(char *filename);
^x&\#J< E
4rYJ *wF int main(void)
$o'3wG\l {
+ 14?xub printf("Does NOTEXIST.FIL exist: %s !z$5T ",
FNxz2XB*y file_exists("NOTEXISTS.FIL") ? "YES" : "NO");
[kLYW8ZS@ return 0;
_1]/|3& }
;^!kjQu1
03O%
O0msO int file_exists(char *filename)
t{yN&?};c
{
-pJ\tS_ return (access(filename, 0) == 0);
7ZU"T)uX^i }
{/O>4B4W
0JujNu`v
)u0>/>v 函数名: acos
C@yVD#.u 功 能: 反余弦函数
r(zZ=")y 用 法: double acos(double x);
fcfiJ} 程序例:
DJ;Cwy> #include
29ErvF{| #include
NI dO
WP
?-fx_O int main(void)
[2QQ>xm {
RfKy1HF=u7 double result;
~eY^sbB double x = 0.5;
i\^@>C@$
9]}<P`" result = acos(x);
C5o8wA printf("The arc cosine of %lf is %lf oo.;j- ", x, result);
C<wb\M5 return 0;
nEKb#~? }
9.uDdT'!w
nO-.)=LPk
x-;JZ9?+
pk.3>}"M 函数名: allocmem
`]39^ inT 功 能: 分配DOS存储段
ZQ(qH
x 用 法: int allocmem(unsigned size, unsigned *seg);
%}l|l 程序例:
ial]NZ~ #include
/rR;|Mj\ #include
QiqV@}'* #include
< 7&I&MG
!Xub.P!<j int main(void)
cg'{y4O?> {
9WwA6g unsigned int size, segp;
oW85,It
Z7 int stat;
OZ5B%{I7XL
8Y'pQd@i size = 64; /* (64 x 16) = 1024 bytes */
:&|C-%y stat = allocmem(size, &segp);
b'bFeqH if (stat == -1)
IP%OJrhu printf("Allocated memory at segment: %x 9wn!knL ", segp);
/g0A;DeR) else
r&@QL printf("Failed: maximum number of paragraphs available is %u d9?lS@5 RF ",
84Bbvi&xz stat);
C4(dsm6n?
m}bkY1Ds return 0;
C:"#G~,` }
NN{ q.
d~t*D[
)fYSV~q
zJX~!Mk =J 函数名: arc
<*:;"4A8 功 能: 画一弧线
,<]c Gaj5 用 法: void far arc(int x, int y, int stangle, int endangle, int radius);
=(2$Wa9w\ 程序例:
jlKQ/aL~ #include
;?^[jvF{o #include
ZVU=@v!x #include
m}OFZ9k-- #include
POz)IQAy
BM
%@;}C int main(void)
7:2 ,>muz {
6rh%B_kU+ /* request auto detection */
p{cu#{m int gdriver = DETECT, gmode, errorcode;
k)MG0hJWe@ int midx, midy;
WJ@;1LQ)}6 int stangle = 45, endangle = 135;
N`^dc[ int radius = 100;
y*$F]_5(
A3mv)\3Y /* initialize graphics and local variables */
c=fBCyv]E initgraph(&gdriver, &gmode, "");
EQ@ylc<eY
2M@-fJA /* read result of initialization */
\;tZkr}#J errorcode = graphresult(); /* an error occurred */
v
nT
tQ)Y if (errorcode != grOk)
f_]:FY {
3N$5Z
? printf("Graphics error: %s t6&k-M ", grapherrormsg(errorcode));
zG3@wB= printf("Press any key to halt:");
seZ*7IU getch();
iADk<h0@
rl[INo(feZ exit(1); /* terminate with an error code */
GV-ws0JM
}
RzG%l
A`yMPz midx = getmaxx() / 2;
0^fc:?Q
midy = getmaxy() / 2;
6n$67g setcolor(getmaxcolor());
jVn2J(`cML
6N}6& |