- 在线时间
- 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>9 T5 H8 k( a3 d9 Y9 A( }: \
</P>
5 J z9 H# r3 v0 O5 m
|/ x) z# d) ?7 W* H9 z! R$ l( c. s% I: S
< ><FONT color=#ff0000>函数名: ecvt </FONT>+ F8 o$ \. S% r7 k# U
功 能: 把一个浮点数转换为字符串
% @3 h. ]- U! f& A# Y y用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
9 i# X8 `; p% g& \8 K程序例: </P>0 x; l9 ], p. E9 ]. e6 s* p
< ><FONT color=#0000ff>#include <STDLIB.H>
- q/ Z* x* ~: v5 D- w6 M. |#include <STDIO.H>
9 Q7 R) B8 o9 C7 b; x" t3 v& b* X#include <CONIO.H></FONT></P>) ^% {' C: S6 C. T D8 k
< ><FONT color=#0000ff>int main(void) , t& G& J6 [) R' U; |& r
{ $ H+ E# V% c2 Y/ Y; b: B9 r
char *string;
2 s4 @! b. |2 i( D- d5 B1 E, Idouble value;
9 o. L9 w- U) I3 S3 E- w) k; Bint dec, sign; + j$ p7 X$ T. V3 j, E, K
int ndig = 10; </FONT></P>
# x- A- M" r1 D5 h+ N< ><FONT color=#0000ff>clrscr();
9 r: y* {$ ~; Y. i, L! avalue = 9.876; 5 R! E' V0 u/ X# ?
string = ecvt(value, ndig, &dec, &sign); # _- _3 `! V1 A6 |$ {) _
printf("string = %s dec = %d \
; n! a6 E: D$ U. `% J$ @3 C$ A! V" ] Y- `sign = %d\n", string, dec, sign); </FONT></P>
2 n6 e5 b, O* v/ Q) l+ F, F* @< ><FONT color=#0000ff>value = -123.45; " o8 _+ S4 Z7 s5 p
ndig= 15; - u" H2 ]# n/ _7 _/ k6 z& X& k7 s
string = ecvt(value,ndig,&dec,&sign);
8 T v% u% r1 \" h% Q) ]4 Y2 _printf("string = %s dec = %d sign = %d\n", 9 u" q; [" y6 G) ]9 q" W
string, dec, sign); ( u/ n6 v+ ]9 R! j
</FONT></P>; N9 M! h+ N% S
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific 5 z# x; E6 a/ Y' V/ F M
notation */
% a4 n$ X+ `' X# N9 nndig = 5;
8 o/ C+ ^2 b4 a/ pstring = ecvt(value,ndig,&dec,&sign);
3 Z& c2 N A. x% qprintf("string = %s dec = %d\
5 A* r) G I) J S9 Rsign = %d\n", string, dec, sign); </FONT></P>9 T1 {7 ^, h+ U" n! C! \
< ><FONT color=#0000ff>return 0; * Z0 ^! q) C8 o& S. v2 B
} </FONT>
6 H, d9 \, `0 R+ R5 }9 ]$ `3 e) ^% G/ ~, T- G- d' m
</P>- ^3 p$ J# O: M! M# r3 v, }
< ><FONT color=#ff0000>函数名: ellipse </FONT>. d4 B! p% E6 Q/ z
功 能: 画一椭圆
! \& v, l; M& X& \用 法: void far ellipse(int x, int y, int stangle, int endangle,
/ H2 S; z9 B' ]! }int xradius, int yradius);
! M9 F1 d' X b6 z- r程序例: </P>
6 p0 ^$ f' x" q# v* f- b' d< ><FONT color=#0000ff>#include <GRAPHICS.H>
- q' W! \9 N/ s' g! w8 v- }#include <STDLIB.H>
. z8 x* \$ X9 i! g1 `2 e9 I1 M, ?#include <STDIO.H>
/ k, C. a' a1 [3 B# ]9 I; T#include <CONIO.H></FONT></P>
; s1 G7 F/ C& N8 t/ K! b& l9 d< ><FONT color=#0000ff>int main(void) 3 v- k% _5 i, ^, o% l
{
( e2 t/ O: u; E4 `# v9 t/* request auto detection */ / J, y c7 g, d3 g; w; B
int gdriver = DETECT, gmode, errorcode;
7 C; c/ Z: B: ^, L, S; Aint midx, midy;
2 t: K$ u9 c5 z( K$ i5 i6 C. fint stangle = 0, endangle = 360; ; \- T+ _0 a+ t
int xradius = 100, yradius = 50; </FONT></P>& F4 L% f& i/ L2 l9 j, d& V4 q4 P5 b
< ><FONT color=#0000ff>/* initialize graphics, local variables */
% x" E& y& Y$ vinitgraph(&gdriver, &gmode, ""); </FONT></P>! N6 e4 t7 d1 J0 H# V% V9 C2 P
< ><FONT color=#0000ff>/* read result of initialization */
! }2 }/ i/ e. N S* y! k6 }errorcode = graphresult();
& h. z: y9 N6 o% a& O1 ^if (errorcode != grOk)
7 }7 t a' z7 C1 x7 m/ ~5 @/* an error occurred */
: _6 ]2 P, N9 H' T+ e{ * @5 L: z( w K/ b! J1 L
printf("Graphics error: %s\n",
, S1 Y l$ G$ j- V9 N' b. M( `: F. agrapherrormsg(errorcode)); 9 |3 A. M; x; c+ ]7 x0 |/ T
printf(" ress any key to halt:"); ' N" u6 \9 Z! X- s8 K( _& {) \
getch(); 7 M6 S0 m' j7 K3 w' ~ H0 E% @* h
exit(1);
4 {: }# s( ?6 d4 K5 [' V4 {2 x- l5 \/* terminate with an error code */ R9 S$ N/ i) f+ ^% }% l3 o
} </FONT></P>$ _# r/ d( {, O) ^
< ><FONT color=#0000ff>midx = getmaxx() / 2; , U( A" O. ^4 T q: a" Y7 _2 G! b
midy = getmaxy() / 2;
0 {) ?: u8 X. x) @8 G$ g; @6 [$ wsetcolor(getmaxcolor()); </FONT></P>) x& q& S4 J/ h
< ><FONT color=#0000ff>/* draw ellipse */ 3 r4 Q( i! p2 E6 |* Q Y8 h: e5 q
ellipse(midx, midy, stangle, endangle, - p' t! V. O- X% J* f
xradius, yradius); </FONT></P>
8 B: H5 n7 Z" z0 Y< ><FONT color=#0000ff>/* clean up */ 6 `" k$ A* p4 T8 ^0 b$ a( C
getch(); j6 V8 @! i3 w, x& V" Y
closegraph(); 6 P% L8 ^1 @5 r' C. l4 C0 s0 T
return 0;
6 Y7 d5 @3 l; c* a} </FONT>
* }1 ?7 J; ~1 U+ g7 V0 z* ~0 _4 Y& n ^2 `" |$ g' A# t
</P>
/ ]' e; c; {7 I& o< ><FONT color=#ff0000>函数名: enable </FONT>8 \* m. K$ b) i& @) T
功 能: 开放硬件中断 + O. q+ s9 C: t
用 法: void enable(void); + Y$ r. G0 y7 S7 x
程序例: </P>
# X0 Y; Q" h6 ^& H' Z. n< ><FONT color=#0000ff>/* ** NOTE: + l9 Y9 P$ B; u2 l) t- a
This is an interrupt service routine. You can NOT compile this program 1 j1 @' P! i: C+ q- ^9 R3 p2 D3 ]/ ]! J+ I
with Test Stack Overflow turned on and get an executable file which will
1 @2 w: ?5 B" D: a, J7 foperate correctly.
8 r A' N0 y( t9 s9 p' s# o*/ </FONT></P>$ d+ x( H$ F* w
< ><FONT color=#0000ff>#include <STDIO.H>
1 J: ~0 G! R5 v#include <DOS.H>
/ Q' P$ h/ b/ p6 w#include <CONIO.H></FONT></P>, Z" s. ]; p$ e- W3 V3 q0 Z
< ><FONT color=#0000ff>/* The clock tick interrupt */
4 S8 |3 m; Z2 H2 J( Y$ l" c$ ^#define INTR 0X1C </FONT></P>
$ c5 j& b' X$ E< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>
4 d0 ? J% g0 K; @/ z& K< ><FONT color=#0000ff>int count=0; </FONT></P>
- ^$ V( j5 B5 M! d5 d! N& r5 o< ><FONT color=#0000ff>void interrupt handler(void) " d3 @0 A, C5 Y2 ?) S
{ 6 f2 M' ~% u- x" j2 ?
/* 2 O+ C1 v* Y5 n0 b$ D3 x6 e; m, k! G1 i) h
disable interrupts during the handling of the interrupt
. j' P: v. U3 i( A+ Z*/
: q$ Z# x+ L. ?. ndisable(); ( T8 a1 W0 l9 x1 E
/* increase the global counter */ & q; ^. C6 f) r( ]2 { h1 G
count++; ! N9 ?+ H! _7 t1 c6 G
/*
2 W7 Y: L% p3 h9 Z! Q5 v8 w+ {re enable interrupts at the end of the handler 9 r3 I5 ?. Q+ Q: r& j: e
*/
4 q. f$ f- I8 t; Genable();
+ }! s3 a; o# K- R2 T/* call the old routine */
7 W+ G1 f, W! }# g Soldhandler();
" a4 |7 a) J: ?6 E, i0 W} </FONT></P>
% K" [; l' X3 V& { H+ i< ><FONT color=#0000ff>int main(void)
. T: q4 b: L6 t( D8 I7 |{
1 D, [# z5 L- W" P4 n; K$ h( _, F/* save the old interrupt vector */
6 C* u1 \2 ~0 b1 Y. Uoldhandler = getvect(INTR); </FONT></P>' g6 {2 z# w8 m! ~& t! {
< ><FONT color=#0000ff>/* install the new interrupt handler */
$ O4 `( X2 A1 e! Rsetvect(INTR, handler); </FONT></P>' c3 s0 ?+ K5 M0 ~8 w- t0 U
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
8 j- e4 C" R6 b. \# D7 ywhile (count < 20) 5 k) C1 }3 G* B5 I! V
printf("count is %d\n",count); </FONT></P>7 h6 {9 c( U. E, M( d" k# X' J
< ><FONT color=#0000ff>/* reset the old interrupt handler */ ' o9 K+ [: M- ?9 y
setvect(INTR, oldhandler); </FONT></P>* Y) O5 e* N* ~' \; `
< ><FONT color=#0000ff>return 0;
0 V) m+ \# J" n$ E f} </FONT>9 v4 `5 T* y! O( u9 |# Z- V* {, D
9 H7 m$ \# \( ]. V( e7 Z
</P>) o7 A, C! Q7 C
< ><FONT color=#ff0000>函数名: eof </FONT>: Z2 T! C+ H( j" ?
功 能: 检测文件结束 , Z' B: s" B0 M- `" ]+ a
用 法: int eof(int *handle);
. c9 M6 D G1 X程序例: </P>
$ u6 C3 \+ K0 X' b<P><FONT color=#0000ff>#include <SYS\STAT.H>
7 W0 l K9 S5 }: ^- i* U$ A#include <STRING.H>
& z2 t4 B6 _; A9 `#include <STDIO.H>5 v" v& u: j) u" y- |: H0 p
#include <FCNTL.H>
6 A7 W+ m! @# b2 y#include <IO.H></FONT></P>0 W4 ~0 M9 E( U& c) s! N3 H! y% m: v
<P><FONT color=#0000ff>int main(void)
8 {% ?$ T' \1 T/ e }5 o {/ w{
4 q/ H# k C1 Lint handle;
+ ]6 o' d: v1 r) e5 fchar msg[] = "This is a test";
9 _! _; r( B5 jchar ch; </FONT></P>
5 t" |5 S' ^& `+ ~<P><FONT color=#0000ff>/* create a file */ 8 [' U& b* Z4 \7 `
handle = open("DUMMY.FIL",
& }2 k, K2 P/ @& g' g1 FO_CREAT | O_RDWR,
) P$ W: Z- \: ?S_IREAD | S_IWRITE); </FONT></P>- Z6 A; }' K1 q9 O6 l5 i
<P><FONT color=#0000ff>/* write some data to the file */ 4 B/ n6 K- \" T
write(handle, msg, strlen(msg)); </FONT></P>+ l* S, o+ o7 }& I4 H% X
<P><FONT color=#0000ff>/* seek to the beginning of the file */
: t, h% R" X! d7 r2 |" F m$ \ Tlseek(handle, 0L, SEEK_SET); </FONT></P>) o5 r" o& N4 O
<P><FONT color=#0000ff>/*
9 B$ W& n# t5 c- R+ l- m) p: m8 Creads chars from the file until hit EOF
H+ m" J5 z! f# v: e*/ * S' D# B# ]6 e4 j0 h- W5 B
do 7 k4 B0 s) A3 _* k1 a P0 u
{ ! r& S) T, `" z8 X1 j/ W8 D5 b
read(handle, &ch, 1); - v7 u0 l1 F3 @7 _
printf("%c", ch); : P; E1 j# L( ^' V
} while (!eof(handle)); </FONT></P>$ U% ?; R4 D. x/ o+ _' k) w
<P><FONT color=#0000ff>close(handle);
$ w5 y: s0 E1 o' L/ l# y( m! sreturn 0;
( k' S: ]: b* ?' w} . ]9 c" s2 F' w; Y/ {3 r
</FONT>
) m2 r6 n0 D. z. C</P>
( {4 v- }; v+ Q" ~8 {<P><FONT color=#ff0000>函数名: exec... </FONT>
8 t# H9 b; m5 B6 N- N5 I3 w) X1 t% e功 能: 装入并运行其它程序的函数 9 m- m* I* D$ L e* ]4 }
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); # {: b% T0 l- p
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL, 7 |$ N$ r: o% n0 U* `0 I
char *envp[]);
2 s8 k1 H- J7 J* B% _ Y+ U- d2 ^int execlp(char *pathname, char *arg0, arg1, .., NULL);
' A, ^. r# o; N$ [7 }! Q( t1 oint execple(char *pathname, char *arg0, arg1, ..., NULL, " I9 Y% U- I5 {; O- R
char *envp[]);
' F4 k' |: X* S2 n# R i; H' L( pint execv(char *pathname, char *argv[]);
- {0 }8 F" m; k+ q2 rint execve(char *pathname, char *argv[], char *envp[]);
8 _" B$ H2 ]+ h3 A6 b8 G. x9 t3 [0 kint execvp(char *pathname, char *argv[]);
3 q+ V4 ~; I0 O9 ^' ^int execvpe(char *pathname, char *argv[], char *envp[]); 3 b. b* E& [2 c: {; {
程序例: </P>8 b- I7 X% Y1 Y$ [4 A" B F
<P><FONT color=#0000ff>/* execv example */ 7 w- B+ F( R' `
#include <PROCESS.H>, n7 L. b- ~5 H" |: V
#include <STDIO.H>
. p8 |1 y. M& {+ I$ ?3 q) `1 _- m5 p#include <ERRNO.H></FONT></P>
4 g# Q+ _+ I0 U, T7 u# e<P><FONT color=#0000ff>void main(int argc, char *argv[]) 6 i& E% f* M! G; @" w2 A
{
* l8 m+ F" q( z: I8 a+ aint i; </FONT></P>
+ y; H* _7 Z1 X9 o7 `<P><FONT color=#0000ff>printf("Command line arguments:\n");
/ M* |8 _6 P) lfor (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
3 A5 x% A0 [- ~3 \8 C8 ]& @<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); . c7 H( o) j H4 g3 l/ i
execv("CHILD.EXE", argv); </FONT></P>
$ f8 j& s @4 Q/ j0 V<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
. ?3 O- o! K3 i( T5 V5 T<P><FONT color=#0000ff>exit(1); 6 T7 W" q- ^% }+ ~& Q/ u2 H
}
: c7 }$ x. X& ?9 F6 Y. q3 ~1 t5 F</FONT>
/ e! c5 N9 ~1 O; o6 d5 f</P>5 o- N' b, O# n: w/ t& O4 d- K
<P><FONT color=#ff0000>函数名: exit </FONT>1 I! v$ ^% V6 G; L2 [+ K4 R+ a3 Q
功 能: 终止程序
: ?3 U3 K: ^( Z# g& o: B' z用 法: void exit(int status);
2 m. w6 }# d8 k3 ^: G8 D程序例: </P>1 W- q2 ~) O/ D% {/ H
<P><FONT color=#0000ff>#include <STDLIB.H>
# [1 s5 e7 o6 Y3 v9 N4 P2 G! A#include <CONIO.H>, G% e9 ^4 {; k5 b/ _( k2 z
#include <STDIO.H></FONT></P>. u2 F$ A8 o) R7 c
<P><FONT color=#0000ff>int main(void) 3 H5 G$ K( v2 r+ z
{
4 X9 s6 X: t6 q, I7 F1 F) [" R, i& ?. Oint status; </FONT></P>
5 d, l% w" }. ]1 P, J6 x- ~<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); % {" B7 F. Z* T3 k# @
status = getch(); 6 G+ h: L. p9 @
/* Sets DOS errorlevel */ R* ]4 [. m, ?1 ]
exit(status - '0'); </FONT></P>- e" I! ~& c5 o' f9 l& O9 W& T' U# N' g
<P><FONT color=#0000ff>/* Note: this line is never reached */
# n6 W" w6 G2 |return 0;
# j, X; g; x. w' p& V" l} - b7 b+ e2 Y4 [) n
</FONT>: T! h1 k6 v0 V5 i
</P>
( Y$ ?: [- u+ u. O<P><FONT color=#ff0000>函数名: exp </FONT>
9 ~! M* W9 d4 |9 A9 ~, I功 能: 指数函数 1 I2 {6 z# }3 s" r3 t. c6 J- }
用 法: double exp(double x);
7 F' h& f" g' O; S' X6 |' V! w8 ]7 a程序例: </P>3 \0 [( m4 A& s3 E+ p
<P><FONT color=#0000ff>#include <STDIO.H>
- c( w G% o3 N T( t: B7 R#include <MATH.H></FONT></P>9 n' o. |! h& H, O/ u* l: F: ]. u. r
<P><FONT color=#0000ff>int main(void) 2 F3 g" h5 j' d+ Y& G0 g, |7 S
{ K* A' b- S# D
double result; : P4 f! s3 \. K5 d/ z+ U
double x = 4.0; </FONT></P>
) ^% h) v1 {4 T. w2 u5 p) H/ a3 }<P><FONT color=#0000ff>result = exp(x);
4 n. y4 Q1 n" k! M7 b6 T9 w) Dprintf("'e' raised to the power \ , n; P' t* b [- X( M( `0 s
of %lf (e ^ %lf) = %lf\n",
+ V4 q) B, |$ h5 mx, x, result); </FONT></P>
" @5 ^- k/ ?% T0 ^# ?+ P<P><FONT color=#0000ff>return 0;
- ^4 E5 `% ?. I6 q}7 n% H$ W4 A C3 r( E, k, ~) @
</FONT></P> |
zan
|