- 在线时间
- 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>
5 H: U7 ]7 o4 s/ k</P>
+ z# z, Y" J u
' u0 Y/ R y4 p0 k9 s X. a) d; F: }$ k9 v, p9 h# ?4 ~
< ><FONT color=#ff0000>函数名: ecvt </FONT>3 `) [5 u0 U: z
功 能: 把一个浮点数转换为字符串
$ S/ d* C0 `. p* `! _用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); 6 M6 c1 [, a/ W4 u3 d
程序例: </P>0 V# }8 F% e8 w# U2 v, s
< ><FONT color=#0000ff>#include <STDLIB.H>
- O! n! h L5 J5 V2 f3 r9 b% d* _#include <STDIO.H>: ?" h8 a9 U3 s9 c/ d
#include <CONIO.H></FONT></P>
! G* l3 E. `7 l& O< ><FONT color=#0000ff>int main(void) ) ~3 H$ g8 S3 G- ^
{
! n/ i9 f& P5 D0 E' \char *string; 2 r3 b4 u! A$ Z% i$ S
double value;
5 `- V! Q) d, d( tint dec, sign;
( R3 H- M1 y qint ndig = 10; </FONT></P>1 \& `- e- M. b% x. I$ L
< ><FONT color=#0000ff>clrscr();
& y& H& m7 {6 ~value = 9.876; * \% j2 W& O5 M+ r/ M5 a
string = ecvt(value, ndig, &dec, &sign);
U5 w, [8 [8 E4 e1 Y3 U7 d$ q Fprintf("string = %s dec = %d \
5 n" a1 L/ H6 |" E4 osign = %d\n", string, dec, sign); </FONT></P>
. S$ ~* z+ P- w' G& y2 `< ><FONT color=#0000ff>value = -123.45; ; c3 q) u& Q/ @
ndig= 15; * P; q) i; _4 s: ] Z' J
string = ecvt(value,ndig,&dec,&sign);
2 b* x; K% @+ ~printf("string = %s dec = %d sign = %d\n",
. N$ G, V2 Y, F6 `3 ]0 astring, dec, sign);
. g9 U( @; \' g/ W# g, G</FONT></P>
" g# G6 \6 d3 X- L' v< ><FONT color=#0000ff>value = 0.6789e5; /* scientific " L2 V) ?3 r7 s5 D
notation */ 2 M, r4 V. W% v7 a, L
ndig = 5;
/ H! \9 `5 u* n& h2 f4 l ~/ Dstring = ecvt(value,ndig,&dec,&sign); 2 y! S: v$ [1 x8 E4 E5 E
printf("string = %s dec = %d\
8 }2 _6 }0 B) [3 [sign = %d\n", string, dec, sign); </FONT></P># ^* ^ m3 b' j9 G2 \4 _& ?; }( h5 X
< ><FONT color=#0000ff>return 0;
" M- O3 j4 M& Z: Y1 D5 T} </FONT>! J/ Q* I# E2 f; d8 o9 A
1 ]& L; w: h- `$ ^7 V5 z
</P>
1 U4 \: X) | D* L, v* o< ><FONT color=#ff0000>函数名: ellipse </FONT>! \; s7 D* {* q& ` }
功 能: 画一椭圆 K$ I. r0 `5 u# b& u
用 法: void far ellipse(int x, int y, int stangle, int endangle,
& u0 J! k2 C6 R |# @! @" N0 Lint xradius, int yradius);
: U8 i( C3 S/ ?' i( a程序例: </P>
S9 g2 t# u: t }! l% n, P1 k< ><FONT color=#0000ff>#include <GRAPHICS.H>
* r5 G8 F% U& i8 A#include <STDLIB.H> E8 ]( R) h. K2 K
#include <STDIO.H>
3 O+ G6 Y9 N* k2 c& P5 R#include <CONIO.H></FONT></P>
* U, y0 t; T R- ]! v, t< ><FONT color=#0000ff>int main(void)
0 ?! m6 }- E' W4 R) R- I{
- b/ k1 q0 W" [' r0 A" E6 y. r/* request auto detection */
7 _! D& P+ z R% y1 x1 Kint gdriver = DETECT, gmode, errorcode;
$ J3 _, y0 Z3 W' ?) d# E' Pint midx, midy;
& G: O6 S# C8 n: _# N$ Gint stangle = 0, endangle = 360; ) p% T5 d+ v% g% A Z% H
int xradius = 100, yradius = 50; </FONT></P>
: ?/ t( a. M4 M/ J% c! l( W; a1 b< ><FONT color=#0000ff>/* initialize graphics, local variables */
" d! f+ M* x- Ginitgraph(&gdriver, &gmode, ""); </FONT></P>( n, c. r$ A1 l8 Y. T$ `+ ~5 M/ a
< ><FONT color=#0000ff>/* read result of initialization */ * { K$ r5 [7 D# V1 _8 Z
errorcode = graphresult();
3 e8 ]; n5 i5 r: B. I; tif (errorcode != grOk)
' Q, H8 c4 _$ a h8 \/* an error occurred */ $ s) G$ M( j ~+ e2 q+ b. E
{
) s& n7 f2 L8 c+ ^9 y5 g: Wprintf("Graphics error: %s\n",
6 i3 z+ t' e$ d" X. N: E( Dgrapherrormsg(errorcode));
$ W0 Y4 `2 @$ e/ Y0 Vprintf(" ress any key to halt:");
5 w+ A) |6 o: `0 ]getch(); ! M7 c3 V [; q \! y. Y/ |
exit(1); . W M; K" V0 m, i2 U: x, _" ^' D
/* terminate with an error code */ 0 x; W# E: `; G) q
} </FONT></P>
; H7 R, E- N9 O& O< ><FONT color=#0000ff>midx = getmaxx() / 2;
) J4 g6 @1 r1 \& h- c9 H5 Q3 e( Bmidy = getmaxy() / 2;
+ X' J3 A" d$ W, m! v" A U# ]setcolor(getmaxcolor()); </FONT></P>
+ {; r; l8 A* o< ><FONT color=#0000ff>/* draw ellipse */ % Q! T9 G' o. z# c- o' }$ F
ellipse(midx, midy, stangle, endangle, , s- |. h+ s$ L2 M0 ^
xradius, yradius); </FONT></P> o8 e# Z* Q% ^. P1 b8 {
< ><FONT color=#0000ff>/* clean up */ & P/ M7 K3 G! n& F! K
getch();
7 m$ _% r' Y" E2 l1 m& mclosegraph();
& a* J0 S# t/ h# I* Vreturn 0; . {8 B# E% ?3 x l! j, G6 ?
} </FONT>
) R, e, z% ]; Z2 {' d' h% }7 Q# d$ Q6 ~
</P>& u, o. T6 y Q2 o
< ><FONT color=#ff0000>函数名: enable </FONT>
6 [" U: J# J" D* C' X1 T! z) d功 能: 开放硬件中断 $ @* n: k4 z7 i5 i# c E8 B
用 法: void enable(void);
' C9 h" o3 J4 n( `& c" l程序例: </P>- \ G$ o( s( Z
< ><FONT color=#0000ff>/* ** NOTE:
B/ O9 i) {) IThis is an interrupt service routine. You can NOT compile this program : l, f; _. p1 \4 J# D3 D7 C
with Test Stack Overflow turned on and get an executable file which will
9 h7 ?0 {6 _% ^- Ioperate correctly. 5 j+ U0 ]) ~& H/ M$ @
*/ </FONT></P>* y3 ~4 p& @5 s1 P7 I5 s4 Q. a
< ><FONT color=#0000ff>#include <STDIO.H>
7 }* P9 [$ K) z#include <DOS.H>7 |1 O: ]2 t8 b; E
#include <CONIO.H></FONT></P>
$ H, `# d6 D* k" V< ><FONT color=#0000ff>/* The clock tick interrupt */
; L! A' {' K* ^% ]3 z#define INTR 0X1C </FONT></P>$ p. S- a$ [3 p$ b$ W3 b
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>/ z/ {0 K6 Q+ D( b. R
< ><FONT color=#0000ff>int count=0; </FONT></P>4 w3 j) n, q. ? j! C
< ><FONT color=#0000ff>void interrupt handler(void) 5 A+ q# B* k$ }' b! y
{ + V! [' b, y7 O7 M
/*
6 T' ]. F# x1 M( U/ fdisable interrupts during the handling of the interrupt ; G8 N7 D0 G% U
*/
2 P& f; i# }$ {* D# d) P8 Sdisable(); ( r; O2 K9 v( W% v2 v/ t7 i
/* increase the global counter */ + `; M/ L. f( R# _' L
count++;
8 e) ], p; B |" R1 X; G$ l5 v8 Y/* . M- q: a; e2 `# a) x% I7 @! B- }
re enable interrupts at the end of the handler
4 @7 S& l! i S* _! Y*/
6 H/ J" s6 q4 j% t" aenable();
4 G: S4 f) L! c" w# R/* call the old routine */ ! O: {, w v; z0 M
oldhandler(); * N) \1 f2 m0 u2 X' Q) i
} </FONT></P>
& c8 }7 @( H; l$ d' D' ^6 d< ><FONT color=#0000ff>int main(void) + @; E l. W) M0 d- @
{
) y+ @5 I0 x0 W7 u' {* Y. @4 ?/* save the old interrupt vector */ - n6 W9 K, r# m
oldhandler = getvect(INTR); </FONT></P>
: ^8 I4 \' w: o< ><FONT color=#0000ff>/* install the new interrupt handler */
9 B: ~. d- J3 V# [) Asetvect(INTR, handler); </FONT></P>
" ^: Y$ D0 @& K. G4 j$ k( T< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
1 T% j7 ]/ ?1 Swhile (count < 20) 5 B' v! N$ ~* Z9 B& m }$ w
printf("count is %d\n",count); </FONT></P>
1 g0 \( F+ L" c# P1 H< ><FONT color=#0000ff>/* reset the old interrupt handler */
! \$ E/ p0 r/ u4 ` a( F) @% lsetvect(INTR, oldhandler); </FONT></P>
4 Q6 C+ ]+ }- n) L4 Y' R< ><FONT color=#0000ff>return 0;
* s) H! Y, s/ Q} </FONT>/ n( p% [7 d B3 G( e; ~7 S3 E c* K
! t# M$ t+ u5 e {1 Z</P>
4 i$ N6 [) h( U5 O) F4 C8 q- j< ><FONT color=#ff0000>函数名: eof </FONT>
" H8 ?0 m) L% L3 S( t: j: b- ]功 能: 检测文件结束 # S5 R" |$ q" v C
用 法: int eof(int *handle); + t4 `' m; V1 Q* e8 S
程序例: </P>9 C* Z W: m& C
<P><FONT color=#0000ff>#include <SYS\STAT.H>7 N* @( c( s& @, I1 Z% X
#include <STRING.H>6 D2 g% M, v3 q# J
#include <STDIO.H>
( S8 T- q* G: c2 V m#include <FCNTL.H>( y2 w1 d7 |" G+ A
#include <IO.H></FONT></P>) ?) ?" N" V$ Q8 M, [) z
<P><FONT color=#0000ff>int main(void)
8 [( m3 V- z3 S{
/ P+ p4 `5 {) ~. k4 v+ ]5 wint handle; & M* D6 y# z: _. ` }4 e
char msg[] = "This is a test";
) |3 F$ q# i# p4 R+ \: M; Xchar ch; </FONT></P>5 Z" z4 ^% Q+ U( ~' \8 ]
<P><FONT color=#0000ff>/* create a file */ ' m# I9 e5 g. Q+ G6 S
handle = open("DUMMY.FIL", $ T- a4 K% |, t
O_CREAT | O_RDWR, * W3 d, L& z: A. J0 h
S_IREAD | S_IWRITE); </FONT></P>1 k# w2 P% C4 Q. d/ M
<P><FONT color=#0000ff>/* write some data to the file */ + G3 z, r7 r! f; a
write(handle, msg, strlen(msg)); </FONT></P>) T$ G$ v* ` S& y
<P><FONT color=#0000ff>/* seek to the beginning of the file */ / E3 j# }8 Q7 F
lseek(handle, 0L, SEEK_SET); </FONT></P>
* }1 w* j: b$ ?3 D' x, r<P><FONT color=#0000ff>/*
X' G; V1 c6 B5 x% Freads chars from the file until hit EOF
9 i; @5 j9 E4 {2 D*/
R& Y9 {4 J/ n4 ddo + ?. I$ Z; U# _8 i
{
3 S- t+ V* C9 z; E! L3 \+ {read(handle, &ch, 1); 0 S8 s) |( I- r4 g
printf("%c", ch);
( Y+ A1 ? n! W: c, X} while (!eof(handle)); </FONT></P>3 C! D. T- @; _1 Z4 k0 `
<P><FONT color=#0000ff>close(handle);
; b6 W0 U* Z, x, G- v+ zreturn 0;
! I% E& V3 i9 A* e# [ \}
: J. N/ A y2 v7 z</FONT>
6 m* A. U# T+ ^8 Q! |$ d' `</P>
$ x% g4 l. V! }" X9 @<P><FONT color=#ff0000>函数名: exec... </FONT>: g: t6 t+ y. ?1 C5 C3 V( ~" j
功 能: 装入并运行其它程序的函数 g2 [" ^/ H" o) o4 K9 L+ s
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); - [7 M# f9 z# b; I, [. A
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
( K+ T3 E7 U9 o; H8 I6 h8 a4 ]char *envp[]); ) J, Y# ]1 E/ j- c0 s
int execlp(char *pathname, char *arg0, arg1, .., NULL); & P0 V+ w3 p5 I9 Q9 L2 W
int execple(char *pathname, char *arg0, arg1, ..., NULL,
9 _, `% c! l) P6 }5 echar *envp[]); % h U; I% a3 S8 [$ M
int execv(char *pathname, char *argv[]);
' z0 J6 H) |& ]: N5 w. {, ^int execve(char *pathname, char *argv[], char *envp[]);
3 E0 N* G+ p! E% P! [- lint execvp(char *pathname, char *argv[]);
0 _3 {! Q& y- l7 R' Wint execvpe(char *pathname, char *argv[], char *envp[]); / e* C' S/ n4 E5 K
程序例: </P>
3 j* X8 ~0 ?% j+ x G2 J<P><FONT color=#0000ff>/* execv example */ 9 K! b! T/ q# `! J, `. Y
#include <PROCESS.H>4 A% ^) ~+ g' d' x1 `1 x
#include <STDIO.H>
P, z+ F( n$ ~6 f# w#include <ERRNO.H></FONT></P>7 ] I) k0 D% n# P& a4 N: z7 u) K
<P><FONT color=#0000ff>void main(int argc, char *argv[]) b# k1 A% v) V. o s1 p
{ : i$ n1 I$ q& p3 R5 w3 A6 l
int i; </FONT></P>' c$ f% u& M/ V: j( Z$ u, l
<P><FONT color=#0000ff>printf("Command line arguments:\n");
; @$ R# G2 Q6 ~' J1 Z( Q$ ~for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>" b8 a$ ^6 [2 h: e4 m2 o2 d& c
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); ' C8 _1 k: `# Q" ~" J8 s; P
execv("CHILD.EXE", argv); </FONT></P>
4 w) t; [! \7 Z: w, f) p<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
9 F \) Q2 c" K) E+ e& M, C<P><FONT color=#0000ff>exit(1); ) \% U! ]5 x! V) b& @2 \% K: p
}
1 z. ^" e( M& i* J0 G, {- T0 f</FONT>
+ b5 c7 b) ^4 z</P>
7 E# A& \$ k' O7 @<P><FONT color=#ff0000>函数名: exit </FONT>
0 C, _" i" V* B7 y) s& U功 能: 终止程序 * O+ t, B( E4 D/ D n3 W5 |9 @
用 法: void exit(int status);
$ c& W; u. U% ?* G8 O& v程序例: </P>
8 c( B1 n5 z- C! Y- F; a% t% f& p<P><FONT color=#0000ff>#include <STDLIB.H>
1 ]9 M0 j4 L( ^5 v0 V#include <CONIO.H>
5 u. y5 h3 V% B) Y6 Z# ~# S#include <STDIO.H></FONT></P>
^- D$ B5 D4 K* k# n8 \, r* ?8 Y<P><FONT color=#0000ff>int main(void)
6 D) O; |! x' z9 D2 t3 a{
4 g" a; |# ~; ~4 gint status; </FONT></P>8 x* } X" l( W7 ^9 H
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); ; \4 _* |7 m" e4 m$ P8 L
status = getch(); # j. r$ q9 j" y
/* Sets DOS errorlevel */ + z. D1 P0 Y' Q& D% x
exit(status - '0'); </FONT></P>
3 w9 y0 g& x! |4 k: L4 H<P><FONT color=#0000ff>/* Note: this line is never reached */ * `1 Z7 a& L7 O8 G
return 0;
. j3 e3 Q3 V; |! e/ X, g}
' n) x# E$ M8 y* v7 j' Y% }</FONT>
+ T/ C3 S, \, `+ { P$ Z' w0 w! K</P>
: N; h6 Q& I) p* ~, \, L<P><FONT color=#ff0000>函数名: exp </FONT>
2 x7 D; {$ M9 R$ z, G功 能: 指数函数
. c" h0 O( y/ l" T3 z, u' b, h) Z用 法: double exp(double x); 6 J. v4 { ?+ {, n% I
程序例: </P>
2 X( D4 ~* @) o" B' `<P><FONT color=#0000ff>#include <STDIO.H>
$ L6 N( z) L: @) y#include <MATH.H></FONT></P>% \, A) r7 @& ^, l* A& C
<P><FONT color=#0000ff>int main(void)
3 E* _* g5 p0 q6 k{
: |4 K3 l" o5 {: y* y' F# Idouble result;
; X$ J0 C) T! T. Q/ Xdouble x = 4.0; </FONT></P>( h! `6 z0 J$ c y) S
<P><FONT color=#0000ff>result = exp(x); $ [( n: m! ]% Z/ L) M x7 O
printf("'e' raised to the power \
: S" V2 ]5 G. h% f3 ^/ Z) Qof %lf (e ^ %lf) = %lf\n", 9 G: \: Y5 j. L7 i- f, p# [
x, x, result); </FONT></P>( ?$ e4 v1 g4 E7 L! e& I' n
<P><FONT color=#0000ff>return 0;
# z) i* ~ d" X$ a+ a3 ?% |; s6 r}
# M, r) }8 M1 x8 l3 S- {</FONT></P> |
zan
|