- 在线时间
- 0 小时
- 最后登录
- 2007-9-23
- 注册时间
- 2004-9-10
- 听众数
- 3
- 收听数
- 0
- 能力
- 0 分
- 体力
- 9975 点
- 威望
- 7 点
- 阅读权限
- 150
- 积分
- 4048
- 相册
- 0
- 日志
- 0
- 记录
- 0
- 帖子
- 1893
- 主题
- 823
- 精华
- 2
- 分享
- 0
- 好友
- 0

我的地盘我做主
该用户从未签到
 |
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(e开头)</FONT></B></FONT>4 P9 S) x7 j' I
</P>+ ~& V+ d9 j0 i% o+ ?; A+ Y2 o
& V1 h/ {7 p+ ^/ s
* o8 [" V6 K5 @) i' y; u6 T. | s< ><FONT color=#ff0000>函数名: ecvt </FONT>
" b4 ^+ b: E0 S) A8 [3 C功 能: 把一个浮点数转换为字符串 7 G D K9 h6 y4 y' A5 ]
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); ) O) O0 U0 a2 @- E1 E3 b
程序例: </P>$ l7 x/ {$ o5 N3 b" J
< ><FONT color=#0000ff>#include <STDLIB.H>
0 L( K @- A5 N- a#include <STDIO.H>
- J7 D2 X: ?! y: z#include <CONIO.H></FONT></P>
& H ]7 q, `1 ]% @< ><FONT color=#0000ff>int main(void) % w; f! a- y* n/ ]( K# u
{
8 z: @ d, {5 q4 a. d, nchar *string;
! E4 P8 b; E& [! Fdouble value;
& V% }3 ^! y9 K& k1 yint dec, sign;
% L; {; _& R$ ]+ R g* X( t# ?int ndig = 10; </FONT></P>0 Z2 W( F) z& h7 [ g
< ><FONT color=#0000ff>clrscr();
& n4 w5 G8 M% c; u9 m& D/ [; w# svalue = 9.876;
0 E& B5 M6 c: Sstring = ecvt(value, ndig, &dec, &sign); " e b: v* H5 M; \8 ~6 i/ d" G
printf("string = %s dec = %d \
' ?7 T; g2 k# ^0 \sign = %d\n", string, dec, sign); </FONT></P>$ X3 b- {; _: Z6 i n; x1 x
< ><FONT color=#0000ff>value = -123.45; 8 E3 r& s' U, ]7 s: G H' }& A
ndig= 15;
( |* a! Q1 [4 q) {; S8 O% Tstring = ecvt(value,ndig,&dec,&sign); ?3 a, u6 S9 T# t0 S. D
printf("string = %s dec = %d sign = %d\n", # A8 o% v3 {, E2 Y
string, dec, sign);
+ V, X; P( [1 _! k: e</FONT></P>* F6 T1 ~/ U2 C7 _: V/ d
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific ! M6 w+ k; d- H* `$ A1 H
notation */
: x5 z" `6 s, ^) v& @# A; Z$ i' Wndig = 5;
& h7 d* v# t7 Q7 i$ y7 Pstring = ecvt(value,ndig,&dec,&sign);
! H# B/ Y" W9 uprintf("string = %s dec = %d\
- c* Z6 w- }0 Z' U7 Ssign = %d\n", string, dec, sign); </FONT></P>2 ~+ |( P( |4 A j- h: k$ ~& K. A
< ><FONT color=#0000ff>return 0;
! G) P/ F9 [1 ]+ L* }- w& o} </FONT>
3 n9 K# l, N& f6 m" G: H! M6 Q
0 X h2 @! ~% `1 u9 K</P>" g3 P" _# U' G& q! m* i. k
< ><FONT color=#ff0000>函数名: ellipse </FONT>. d5 Z7 B. Y/ S
功 能: 画一椭圆
- b- A; d! Q9 V! U用 法: void far ellipse(int x, int y, int stangle, int endangle,
" ^, ~; ~, O8 s: V7 H9 _int xradius, int yradius); 7 }( s+ D$ S3 E/ b# Z& X8 t
程序例: </P>
4 B% [$ T/ ?; X6 n" p% O' k< ><FONT color=#0000ff>#include <GRAPHICS.H>
# j" i) P, O1 H2 x @# k" e#include <STDLIB.H>5 u# K% Z2 ~! ^ Y$ a
#include <STDIO.H>/ D6 Q. m* c+ I
#include <CONIO.H></FONT></P>
, B6 d- P" p3 W" F; O, c8 j< ><FONT color=#0000ff>int main(void)
2 y* E: @1 w- ?; t5 V* {{
" x+ g) n" l! G" K1 ~/* request auto detection */
6 }' Z6 Q1 i5 K i- ^& Vint gdriver = DETECT, gmode, errorcode; 4 o) n4 |7 J' Q
int midx, midy;
, M; W {( q4 rint stangle = 0, endangle = 360;
3 J0 t: C$ p& iint xradius = 100, yradius = 50; </FONT></P>' T0 x! M2 s* D8 \# J' p
< ><FONT color=#0000ff>/* initialize graphics, local variables */
6 r' E! l. a* E9 {9 Iinitgraph(&gdriver, &gmode, ""); </FONT></P>
3 O. X2 d5 B6 `- o; |0 j< ><FONT color=#0000ff>/* read result of initialization */ * D: B) Q9 E% m- s) {8 W
errorcode = graphresult();
, Y6 v A1 P+ z5 rif (errorcode != grOk)
. m: D' u1 l* X D5 P$ P/* an error occurred */
- I8 [. b9 q* L* z{ ' e4 T6 s# K4 V) i; S: _ i
printf("Graphics error: %s\n", # |- Z2 |/ p9 ^* j2 S
grapherrormsg(errorcode)); 9 Q0 q* e7 F) h/ b; {% X: c y
printf(" ress any key to halt:"); : o6 v8 r4 Q0 F7 T" Z1 `9 |
getch(); , s8 ]1 N7 M. i: }/ ^2 i' K; H3 _8 a/ r
exit(1);
Q3 _" U& j( \/* terminate with an error code */
2 B, [' G' {+ K} </FONT></P>$ P# d8 b8 ~) v7 F9 r( I
< ><FONT color=#0000ff>midx = getmaxx() / 2;
6 v, l' b& b7 mmidy = getmaxy() / 2; ' G$ l5 b+ a- c* w; b3 ?( r+ d5 f
setcolor(getmaxcolor()); </FONT></P>8 t" x; H& N- `# X } Y
< ><FONT color=#0000ff>/* draw ellipse */
6 V) o/ e' B" r i0 r5 Vellipse(midx, midy, stangle, endangle, 4 ?) p+ ?3 ^* w' V I4 d/ ]
xradius, yradius); </FONT></P>" k4 L& t! |! J. P! {. s
< ><FONT color=#0000ff>/* clean up */ " _6 F9 D" @3 u2 c& C' ?! T7 V
getch(); . m; |; h6 h; T# q; t1 w
closegraph();
! u( B; ]' F8 i' @& freturn 0; - J# Y- l- \* ^; Y- t/ p" J
} </FONT>
! a5 J- J( x+ s! Y: v: m% q0 v! M7 D3 d9 ?+ x# A. _, \
</P>6 r) R4 T3 Z% L+ _7 p! ]
< ><FONT color=#ff0000>函数名: enable </FONT>0 P5 a3 o+ e- z. V
功 能: 开放硬件中断 6 X" H$ A7 {' Z* G- k0 _
用 法: void enable(void);
) F1 q' z1 g& R: ~: n3 o( w# Q! }/ x程序例: </P>5 n+ R& U* Q6 X* x' G, [5 i
< ><FONT color=#0000ff>/* ** NOTE:
9 J2 G6 u2 m4 l+ v: nThis is an interrupt service routine. You can NOT compile this program 3 x" w, `1 `# n
with Test Stack Overflow turned on and get an executable file which will
/ H& R5 N0 d* v( W6 uoperate correctly. ! r7 l! S; v1 C1 K, i6 w
*/ </FONT></P>& Z) R4 x$ p2 o2 o
< ><FONT color=#0000ff>#include <STDIO.H>
2 N) R/ T' [1 b* F7 f#include <DOS.H>& b4 H8 P0 j7 i
#include <CONIO.H></FONT></P>6 r# w4 J/ o, [2 O& B, ^
< ><FONT color=#0000ff>/* The clock tick interrupt */
3 K4 `4 Z# F! Z#define INTR 0X1C </FONT></P>
' |- f" `6 j+ x0 q< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>: n0 w) b& ^! r% y. J9 ]! e" H* ^2 ]
< ><FONT color=#0000ff>int count=0; </FONT></P>
J1 x K9 m" A< ><FONT color=#0000ff>void interrupt handler(void) 9 f. d4 Q# A# h1 D- j r
{
4 i# P6 D' z' H6 y4 c( @/*
' J l( v3 Y( F0 Adisable interrupts during the handling of the interrupt
# g" |6 g1 f* l7 O- i*/ 1 M$ [- @- Y/ m$ b- D5 L4 }& i
disable(); 7 Q! ]9 A$ X9 s3 E; x+ |# e
/* increase the global counter */ 7 b5 J. C2 y3 a2 L \
count++; 0 F1 m+ ?/ K1 O7 R
/* ) j( I. w |# X" X
re enable interrupts at the end of the handler ) M! _/ f2 S# y. `
*/ ; a" x7 F7 u# u: T; R, z
enable();
0 |0 w& U% f8 |; V7 ?/* call the old routine */ ! L" e( @7 e" t
oldhandler();
* X F' j' W" @% R} </FONT></P>6 K3 f6 b3 W7 E1 d
< ><FONT color=#0000ff>int main(void)
8 |" J& u7 \: k, N{ 6 i9 B2 l9 k: q& f/ H
/* save the old interrupt vector */ / v2 K& p, W) R. `2 l
oldhandler = getvect(INTR); </FONT></P>
7 f2 L% v4 z' L% T( Q8 `4 H< ><FONT color=#0000ff>/* install the new interrupt handler */ 0 o7 e4 G1 `$ H; f/ F, |" x
setvect(INTR, handler); </FONT></P>4 r$ {% T/ \% [% _- Y4 i; e# D# l6 v5 U
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
0 k! _2 h! T# N+ iwhile (count < 20) 5 m; L" }8 u: O
printf("count is %d\n",count); </FONT></P>% y; R4 A1 ^1 l5 d
< ><FONT color=#0000ff>/* reset the old interrupt handler */
# r% t* J9 \* C5 j; Q) E9 msetvect(INTR, oldhandler); </FONT></P>+ R2 A0 O- J$ z0 O
< ><FONT color=#0000ff>return 0; ! B* ]( j4 Q; s# x' c- g
} </FONT>. ]" \% z: ]& H, k( ]8 Z; v$ v/ s
8 y% s' h/ x6 a9 J: J: \
</P>
5 S( R$ F" t6 {! g9 d* S+ k< ><FONT color=#ff0000>函数名: eof </FONT>
. G U; l9 g$ G' Q8 Z功 能: 检测文件结束
& H' b5 ~! y1 i# P用 法: int eof(int *handle);
$ _2 E/ `, Z" P, _9 C, z! G! D! H# [程序例: </P>
1 F- E' t* v' Z/ }<P><FONT color=#0000ff>#include <SYS\STAT.H>) B2 H! e; R1 O
#include <STRING.H>6 _1 `5 f. ] R& p: V, q
#include <STDIO.H>, M0 d3 c- e8 o' J, m- { x. g
#include <FCNTL.H>
/ f7 }" F$ l; x4 R#include <IO.H></FONT></P>
Q2 P1 z; q( [7 V2 F, x& r<P><FONT color=#0000ff>int main(void) % ?$ X# q( H4 Q" [% L8 P
{
8 g( O6 k4 D& R* Pint handle;
9 [6 @9 ?. a. `char msg[] = "This is a test";
! c- A3 s/ }' N3 [7 t' s. @char ch; </FONT></P>* W6 w& s4 y" e
<P><FONT color=#0000ff>/* create a file */ . r6 |$ {% x# Q
handle = open("DUMMY.FIL", ' `* v3 q/ |5 z5 _0 B- M3 T
O_CREAT | O_RDWR, ! ^) ]% Q: ]* T p( P) W- {
S_IREAD | S_IWRITE); </FONT></P>( K% J. F& x; e$ ?- Z+ h% }
<P><FONT color=#0000ff>/* write some data to the file */
5 d$ i+ ~! X/ ewrite(handle, msg, strlen(msg)); </FONT></P>. ~+ e5 ?7 e/ v; \+ Z1 d8 x
<P><FONT color=#0000ff>/* seek to the beginning of the file */
1 _$ \# N) u! r6 d# k: H9 m, W: J7 H) elseek(handle, 0L, SEEK_SET); </FONT></P>
4 @% n: a( m4 S" X+ X" F% I<P><FONT color=#0000ff>/*
L/ s4 Y$ o8 b2 z( ?reads chars from the file until hit EOF
, b" z0 \ @; X" Q" z4 y9 ^6 X*/ " K8 j- p& p A9 Y
do
! k1 u C$ K7 z5 ~{
# f+ e! @* n- ^& i! [read(handle, &ch, 1); & V/ W5 p: V% U U' |) ?6 P% r& ]2 {
printf("%c", ch);
2 y T' _7 D6 U9 I4 {, H} while (!eof(handle)); </FONT></P>2 m# e' Q) K! u( X5 f9 m
<P><FONT color=#0000ff>close(handle); . l6 N- A9 ]: q% t$ C( ~! o" w
return 0; 5 s1 ]$ ~: \& D, m i
}
- W+ f2 v! }, A1 [. L" Q3 l- e</FONT>, V' u: I5 z# O0 b$ A' @' X2 H9 R
</P>
- ]2 P8 t: M1 U" Q K: X<P><FONT color=#ff0000>函数名: exec... </FONT>
7 v. T, Q; s% D& h$ A' i6 Q- a功 能: 装入并运行其它程序的函数 ) Y5 v8 o) m" T3 y" D
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
2 ?% S* w$ n1 D8 v8 ?+ lint execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
7 _# m; |* c2 E+ ichar *envp[]); 4 _5 V: X5 W" Y
int execlp(char *pathname, char *arg0, arg1, .., NULL);
5 T# w2 R! [) e! _1 pint execple(char *pathname, char *arg0, arg1, ..., NULL, 7 \- r* g9 p! T, t6 j- S& C3 C
char *envp[]); & {9 ~. L8 b" j
int execv(char *pathname, char *argv[]); 6 `2 I8 y& F$ w+ x% f% I
int execve(char *pathname, char *argv[], char *envp[]); / F9 E' {4 h3 I
int execvp(char *pathname, char *argv[]); : y7 X3 I, b7 q- M3 t. a
int execvpe(char *pathname, char *argv[], char *envp[]); 3 M3 D1 ^: q8 G8 ^& ^6 w
程序例: </P>
1 w( z1 N$ H1 [/ W<P><FONT color=#0000ff>/* execv example */ - d$ y z0 L& v4 R) C
#include <PROCESS.H>
' ~" V' }9 W; D: d2 k5 p#include <STDIO.H>& |7 H4 \2 h" h
#include <ERRNO.H></FONT></P>
6 a' J5 u" k8 h, I<P><FONT color=#0000ff>void main(int argc, char *argv[])
) j6 l( E0 S7 c{
! ^/ X( y! i+ `int i; </FONT></P>* l, H9 X/ [( O" f3 k4 S
<P><FONT color=#0000ff>printf("Command line arguments:\n");
/ }* u1 s9 K, R: v& ~for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>: T \0 M; `& G
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); ! L' J' |7 V8 A$ \, ^) F+ [
execv("CHILD.EXE", argv); </FONT></P>
8 ]& K* b. F# ?, v- A- [7 M4 `<P><FONT color=#0000ff>perror("exec error"); </FONT></P># g& h* E) l+ C# m( j
<P><FONT color=#0000ff>exit(1);
, T" }, e9 L) \" d2 h}
: e5 r: J! V- a0 R6 V</FONT>
# f8 x3 L1 O2 t$ U* @) _</P>
* A% b* {" o: I8 U7 A( X& h/ ?3 {<P><FONT color=#ff0000>函数名: exit </FONT>
5 x' T! Y+ Z( S5 ~功 能: 终止程序 " P+ ?6 I3 w; N2 e+ Z' \1 D
用 法: void exit(int status); ; G, J) m @0 e$ Z/ E( K6 a. s
程序例: </P>* X _4 z5 K' n/ f* L- n1 ?
<P><FONT color=#0000ff>#include <STDLIB.H>
: [6 ?% Y* t- {5 V4 V5 u/ O! ]$ ]#include <CONIO.H>
3 n7 o1 }! S& h# z* I#include <STDIO.H></FONT></P>8 g5 j7 R: I* ]( F; A
<P><FONT color=#0000ff>int main(void) 2 a: W) r5 X( p+ R! d
{ , q/ B X- x* [: Y+ ~) E, Q5 Q
int status; </FONT></P>1 J) B- y ~! H# i3 `, E2 j4 X" U
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
4 h! O' v, {' U! Astatus = getch();
1 \' B# |2 W& C- R7 L/* Sets DOS errorlevel */
, ?9 d: A! k: rexit(status - '0'); </FONT></P>: I' O- E/ s7 m6 N, I1 u
<P><FONT color=#0000ff>/* Note: this line is never reached */ i3 X* v* H0 ~9 X4 l
return 0;
2 }' l- c# z$ D3 s i}
& a8 v* J$ g# ]" H6 c0 h, V</FONT>. o6 J# i; m4 ~8 X' K
</P>
6 W5 x) `! o! z<P><FONT color=#ff0000>函数名: exp </FONT># E3 \" _* k& S* \) b
功 能: 指数函数 3 m6 q# }' u8 w2 o" N
用 法: double exp(double x); 5 S; l4 c+ w6 w2 |6 |, P
程序例: </P>: j/ m5 A3 U% e$ J, _ x" j: V
<P><FONT color=#0000ff>#include <STDIO.H>4 ?: [' q9 D- {. ?; C3 u2 m- w% o
#include <MATH.H></FONT></P>
8 f \: h' v3 u# ^<P><FONT color=#0000ff>int main(void) $ |0 H- Y$ N9 K. S8 w
{ : ?* T5 B0 M# z, L. u6 |4 g
double result; 3 ^8 g2 k2 E2 @
double x = 4.0; </FONT></P>. h5 x, p, a9 ^2 O& @& }
<P><FONT color=#0000ff>result = exp(x); e1 b8 P& ^, s5 ^: Z! j
printf("'e' raised to the power \ ) N6 c2 R* i+ D4 L
of %lf (e ^ %lf) = %lf\n", 6 R$ j/ }) |8 o0 c9 _4 A
x, x, result); </FONT></P>
9 T( v5 [, q2 d' F$ O" ?. N) ]<P><FONT color=#0000ff>return 0; 6 C0 S' K+ F/ W# d1 ?
}
M8 o% A5 z1 _4 q4 `9 R</FONT></P> |
zan
|