- 在线时间
- 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>
+ O, ?% _" I9 K* z, r</P>
) _# p; t9 _/ B4 W2 [1 Q& X. e* X) l
' u% w& @* m/ h$ C( \4 ~* }& k2 v! ?< ><FONT color=#ff0000>函数名: ecvt </FONT>2 }! G. ~4 o3 f/ p
功 能: 把一个浮点数转换为字符串 $ V5 y c+ D2 [# E3 m7 m; N
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
. N/ c7 B" M* [& `程序例: </P>
3 @% z" e( \; E< ><FONT color=#0000ff>#include <STDLIB.H>, ~' f( Z9 L+ M' `
#include <STDIO.H>" ^* M0 Z1 r0 S
#include <CONIO.H></FONT></P>
7 c% i4 F4 D! }< ><FONT color=#0000ff>int main(void) 8 l3 ]7 E9 z w' v3 ^# ~% p" D8 }) {
{ ! H: j0 ^( v$ s" ~$ C/ f
char *string;
; v6 h# y" ?& A$ s9 I+ ?double value;
7 S) Z# k {. \, `int dec, sign; 6 L) |. K# e* N5 A. j0 y6 H
int ndig = 10; </FONT></P>& i, h1 g- Z" Z5 z4 @* e* i. J6 ]
< ><FONT color=#0000ff>clrscr(); 3 P' z& A3 Y' g7 ?% W) F
value = 9.876;
; E/ r6 x8 t6 k: p- ostring = ecvt(value, ndig, &dec, &sign); 6 \- F+ d! B* m! _
printf("string = %s dec = %d \
2 }: M2 N! n% {) nsign = %d\n", string, dec, sign); </FONT></P>
, c' Y, C$ ]. Q9 P: y. b3 b< ><FONT color=#0000ff>value = -123.45;
. A3 [, G# ?/ z9 c$ s3 |4 l# zndig= 15;
" k9 g- l( F, q( o7 r# q# ystring = ecvt(value,ndig,&dec,&sign); 2 e- v9 E$ @4 I- |, H
printf("string = %s dec = %d sign = %d\n", 7 r* v, M8 q+ Y. q4 F* l; }
string, dec, sign);
. m" C! Z" L3 ~/ O2 B& C& | L2 e" h</FONT></P>( o [" X7 n7 c4 G
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific # i) h, o5 i1 \' j" i
notation */
) r0 }0 {# S0 Z. dndig = 5; . n8 q( P3 ^3 K
string = ecvt(value,ndig,&dec,&sign); ) }$ v2 x8 j# T+ g7 C
printf("string = %s dec = %d\
6 Q1 v6 G4 w; E4 V! Lsign = %d\n", string, dec, sign); </FONT></P>$ s6 W' Q/ P. {+ c) @. r
< ><FONT color=#0000ff>return 0;
9 _" e1 z4 T# L( Z' b! j3 F: B} </FONT>
/ Z% W8 g& M' x! z2 h* F# l& X' }, o* I
</P>
4 a4 h1 S5 _# |" v8 v" I/ w; i< ><FONT color=#ff0000>函数名: ellipse </FONT>
' f6 d7 t: I. Q5 ^功 能: 画一椭圆
9 s/ [% Z0 N* J用 法: void far ellipse(int x, int y, int stangle, int endangle, * L" _) d/ y9 X0 M# R4 m) K
int xradius, int yradius); % W& ^; i+ G+ u ?. S- ^
程序例: </P>! v1 n" N8 _: I$ E! I7 |8 x/ v
< ><FONT color=#0000ff>#include <GRAPHICS.H>0 N* l' `8 Z! u4 k: b6 }/ W
#include <STDLIB.H>
8 j" d( [, t! R* D. A0 i+ a#include <STDIO.H> p' l* k$ @' s$ p( r7 K# C9 b' ]
#include <CONIO.H></FONT></P>/ L4 n- M- Z! V) S4 @3 D
< ><FONT color=#0000ff>int main(void) ! N1 f3 m$ W% R
{
' d+ O4 y g1 A+ G3 y+ @/* request auto detection */ ; H. _) _8 a% ] Z" ^( A
int gdriver = DETECT, gmode, errorcode; 7 ^1 |% f( g# c4 ~5 l
int midx, midy;
& E. U* s7 L* s/ t. }# o. Z4 y2 `int stangle = 0, endangle = 360; , x1 o6 |# U# m% q; H4 z! M2 ^4 N
int xradius = 100, yradius = 50; </FONT></P>* _' ?8 J2 Q9 n1 W: K- @( B9 D
< ><FONT color=#0000ff>/* initialize graphics, local variables */ 7 `, J6 j* [% m2 P( O, ~* z, p
initgraph(&gdriver, &gmode, ""); </FONT></P>
! V7 x: y# u! z _< ><FONT color=#0000ff>/* read result of initialization */
! \2 i+ Q. g# ?8 L, t' lerrorcode = graphresult(); 4 h% T! {) H% u3 r) e# l; [% p
if (errorcode != grOk) 7 A8 r: k/ |2 o# t, y% y9 b
/* an error occurred */ 2 A5 q' k3 d, \9 C) f9 z) K
{ ! u5 L; r) n0 `7 u% r
printf("Graphics error: %s\n",
+ m7 c3 }' v P0 ^+ U# K9 hgrapherrormsg(errorcode));
0 G) z+ ?1 L- _) F* y! q6 {printf(" ress any key to halt:");
" t5 @' L& t- r# k) s: B/ vgetch(); 9 l. p, ?, {( K2 E& M+ e* [# x9 g
exit(1);
- R: C6 M6 Y- H9 R9 L0 j# U: Q/* terminate with an error code */
- B; b5 [6 o) @ X* `} </FONT></P>
# _) G V K- R< ><FONT color=#0000ff>midx = getmaxx() / 2; ; f2 n4 F% x0 a$ z- v- A0 H$ B. t0 X
midy = getmaxy() / 2;
. _2 e4 ]' @8 y9 s) csetcolor(getmaxcolor()); </FONT></P>
8 y6 n. W, t+ j< ><FONT color=#0000ff>/* draw ellipse */ 2 g1 y' L5 l* ^ m7 d4 D6 [0 A. o
ellipse(midx, midy, stangle, endangle,
7 R5 K2 G/ {# |xradius, yradius); </FONT></P>
* \6 o& h* k. o" A" X0 G< ><FONT color=#0000ff>/* clean up */ * d6 b8 l$ l) W0 h
getch(); & Z9 o# d8 d7 L% ]
closegraph(); W& m1 @$ m5 d5 g& O, A; o# d9 m
return 0;
6 u* [0 B& V! L0 j' H2 C) G} </FONT>: [' i3 j# z1 N# ]7 u
# `7 b; V' J- |5 u( {& e7 t
</P>
% G+ c x- i Q* M3 ?< ><FONT color=#ff0000>函数名: enable </FONT>
/ k# m2 {+ p3 j7 r1 ~, \功 能: 开放硬件中断
% Q2 P9 W3 n; G+ q用 法: void enable(void); , `& {% c0 A1 |% N7 X+ Y
程序例: </P>
, d! w& P& F: K) [ }! S< ><FONT color=#0000ff>/* ** NOTE:
& ]7 M6 g: Z; EThis is an interrupt service routine. You can NOT compile this program
( z8 O" D/ M1 ?3 c" [2 q: C. }! twith Test Stack Overflow turned on and get an executable file which will 6 r. u$ A; U& p' b
operate correctly.
+ z( P% [6 d* j$ {$ }. U( [*/ </FONT></P>
1 W( ]# |" t: h' l. o7 s: t< ><FONT color=#0000ff>#include <STDIO.H>
: Z, r$ n O4 Y$ r( o1 Q#include <DOS.H># A( m5 C* O% k& v
#include <CONIO.H></FONT></P>
( ]* y/ A; h; e) T' {7 i+ G# R< ><FONT color=#0000ff>/* The clock tick interrupt */ - @ a2 h" Q7 k; N% N
#define INTR 0X1C </FONT></P>+ E- ~$ B z; y7 R# s8 z f% A* D
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>
% ~! @* C9 L% O' A* }< ><FONT color=#0000ff>int count=0; </FONT></P> F& U1 |1 d6 w
< ><FONT color=#0000ff>void interrupt handler(void) ( V# l4 B7 Q. v" v' e$ {0 H" {4 z
{
% o" c3 f; ~( _" F O% @3 r! |/*
$ ~- ]) e: N3 Z% |disable interrupts during the handling of the interrupt
7 S% B+ h" t; L' u*/ 6 |" X* C' w5 U0 u2 H8 d
disable();
& k: j8 w/ U- `: g# q/* increase the global counter */ ; E+ P% @' L* ~0 S1 G
count++;
% e1 G, n1 e9 {3 S! m. w6 B/*
+ f/ w3 h3 D% @+ [9 L3 \9 mre enable interrupts at the end of the handler
$ }, ?+ K8 e5 F- N6 ~3 e. g: b/ N*/
; U* a% }" t7 `/ lenable();
: @ j: a/ V( X1 {/* call the old routine */ * ^% T% k8 p. ?5 `# S5 X
oldhandler(); % z+ a8 A: `6 g6 I2 v; j
} </FONT></P>
. K4 ^+ A1 m8 n2 ?$ O( g" M2 G< ><FONT color=#0000ff>int main(void)
7 Y$ x7 ^: {$ r, R{
0 R2 Y) B+ H, k/* save the old interrupt vector */ * A% a0 n3 i# }+ u2 X0 A2 k1 o! d
oldhandler = getvect(INTR); </FONT></P>; O/ s' \# i& x8 n2 q
< ><FONT color=#0000ff>/* install the new interrupt handler */
+ ], G, c* E0 i( ~4 C( `" `: fsetvect(INTR, handler); </FONT></P>/ m( K, J$ t- [& D" Z5 Y9 O
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
% X: U/ B4 `- q: L1 Awhile (count < 20)
' U% h* r6 r$ v5 T$ K" r3 Aprintf("count is %d\n",count); </FONT></P>
~) z0 j- z/ |/ e: ^) B w. g< ><FONT color=#0000ff>/* reset the old interrupt handler */
9 y7 H& ?# P- Q; C. Nsetvect(INTR, oldhandler); </FONT></P>
0 k( O9 ?5 h$ R0 J6 \< ><FONT color=#0000ff>return 0;
2 R* O# O z/ @7 D: l' {' ~} </FONT>. ~) J3 f6 |/ R" q: k+ C( `/ N" B
. D" l9 \+ U' S3 Y- E. W9 t8 J. G</P>
$ k7 p/ n9 P. W, g/ K< ><FONT color=#ff0000>函数名: eof </FONT>$ Q* Q1 P* N! q- z' t
功 能: 检测文件结束
# ?3 Y5 I0 S0 t用 法: int eof(int *handle);
. o' l/ u8 Y/ K" M# ?. |程序例: </P>9 X! r. b# C! R. F1 B: J1 U
<P><FONT color=#0000ff>#include <SYS\STAT.H>
( a) t9 r9 o* Q8 N- l7 ~6 s#include <STRING.H>
+ ~+ A4 }% Q) m3 J1 |7 t y" C#include <STDIO.H># d5 p, |: v4 M/ ~ P# o
#include <FCNTL.H>
$ H+ g+ ~* c( ^( T& v#include <IO.H></FONT></P>
" J' f! ^" h$ W( [) y, o<P><FONT color=#0000ff>int main(void) ' Y4 C0 e. K5 i( E
{
/ Z" m5 |) d: J$ q1 `' eint handle; 0 U2 p6 Q+ {/ d. V
char msg[] = "This is a test"; 1 E" v. c9 p o/ B* M
char ch; </FONT></P>- e2 @4 J( A6 ?5 d# Y) q0 P
<P><FONT color=#0000ff>/* create a file */
7 Q( O; P! x: w$ Nhandle = open("DUMMY.FIL",
8 x& c+ m6 v1 U+ `7 \ \O_CREAT | O_RDWR,
* Q7 _& A( `) b3 X5 |' ZS_IREAD | S_IWRITE); </FONT></P>( \1 l% x8 r" J, [
<P><FONT color=#0000ff>/* write some data to the file */
a* m9 X4 @. M2 N$ gwrite(handle, msg, strlen(msg)); </FONT></P>
2 {$ v2 B* j9 _% I<P><FONT color=#0000ff>/* seek to the beginning of the file */
g6 i% X1 }, i- v0 a; P- ]& s& Ilseek(handle, 0L, SEEK_SET); </FONT></P>
4 \0 o! V( z4 @2 w<P><FONT color=#0000ff>/*
# r, H, M. @; x- G. X% e. Hreads chars from the file until hit EOF 0 ^8 I2 T5 F; G
*/
_0 Y3 `6 H, [: y3 Q6 ^: kdo H4 {# a6 Z6 y& m; K, w/ Z
{
9 a4 C+ W) |" B2 P4 f& kread(handle, &ch, 1);
& o; V8 R$ R) q3 U5 F! Fprintf("%c", ch);
4 X6 X& d7 h; J# K% b) l} while (!eof(handle)); </FONT></P>) t/ U% h8 x6 S
<P><FONT color=#0000ff>close(handle);
! B1 ?, D; {2 o. ]* ^return 0; 3 Z) U' ]6 N3 K4 I ]
}
# @1 K* {: j1 f* \8 P</FONT>
6 ?) G; f; J5 }9 @</P>- C0 z8 i: U2 D9 `8 l$ v
<P><FONT color=#ff0000>函数名: exec... </FONT>! l" v( i) I8 A0 p( h& ?; p, Y. m7 ^
功 能: 装入并运行其它程序的函数
* J1 \6 c7 x/ L+ M f/ R用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
2 r) q5 B3 A% d( dint execle(char *pathname, char *arg0, arg1, ..., argn, NULL, 5 Y$ w$ W! x E- y5 Y
char *envp[]);
- e7 H1 f# @& Bint execlp(char *pathname, char *arg0, arg1, .., NULL); # N. z! m( B q% [* r3 z* t. |
int execple(char *pathname, char *arg0, arg1, ..., NULL, : M5 F1 m5 M# O- A) A# j
char *envp[]); 0 n. N3 C9 F. W& M4 M) t, W& e
int execv(char *pathname, char *argv[]);
+ P. e/ [3 t2 k7 q3 D& gint execve(char *pathname, char *argv[], char *envp[]);
3 S' u( n: A2 uint execvp(char *pathname, char *argv[]); : q0 X, {3 n0 I% E4 s
int execvpe(char *pathname, char *argv[], char *envp[]); ! l: r/ z( B2 ]( X( ~5 V# z
程序例: </P>
9 o9 y2 N! [9 ?# G" H<P><FONT color=#0000ff>/* execv example */ , N& S+ T V; ?: D w
#include <PROCESS.H>
3 C3 @. g% V' u9 c+ {0 F* T) f#include <STDIO.H>0 s- M9 ^* ~0 ?5 C) V# p- _
#include <ERRNO.H></FONT></P># W; n( T4 v4 J* s8 W: O4 j7 T
<P><FONT color=#0000ff>void main(int argc, char *argv[])
9 J4 q( @( w, t1 z7 K{ ( ? f4 p! ~* q8 c3 }
int i; </FONT></P>( A0 |. E0 P7 b+ R
<P><FONT color=#0000ff>printf("Command line arguments:\n");
( Z2 r: Q2 M! W( n" Ifor (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>! K; t, b9 w) K Y4 w3 \
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); ( s, Z4 z9 \5 |" l2 {" g% ^
execv("CHILD.EXE", argv); </FONT></P>$ ~ W( Z% y: u& n
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
/ ~- j) r- [: w' g1 D<P><FONT color=#0000ff>exit(1);
! m1 M- T5 `7 x1 c} ; u/ V( r* ]9 {+ l7 A) R0 J, C9 T
</FONT>, s+ G0 x: q7 f+ o8 _6 W
</P>' X# Q7 L' v; }9 @
<P><FONT color=#ff0000>函数名: exit </FONT>
7 y3 g; K# e$ ?3 \2 Z4 X$ \+ _功 能: 终止程序
0 W& G% f! h. j, @4 y) c用 法: void exit(int status); 1 j$ \ B4 _4 \
程序例: </P>
5 e$ i% Z, W' X% @<P><FONT color=#0000ff>#include <STDLIB.H>
. `8 h5 R( t- v# L; C: ?" ~#include <CONIO.H>5 T8 @7 c# g+ ]& k8 j: W: Q$ \: P
#include <STDIO.H></FONT></P>8 Z! W3 g! Y. P8 b6 M
<P><FONT color=#0000ff>int main(void)
! C7 e, D) C+ O) e{ , F/ `% R) F, i9 K+ N* Q3 J
int status; </FONT></P># C6 A3 D$ J; I% f* G$ y; e8 k
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
- u0 x( w% i+ J- g2 A& kstatus = getch(); % b A( {/ o, y# p! J
/* Sets DOS errorlevel */ , D% _7 g. U4 E) p
exit(status - '0'); </FONT></P>. m% _* T1 z6 i
<P><FONT color=#0000ff>/* Note: this line is never reached */ # `& z1 b& D! l$ w
return 0; ' |! W5 a2 i! |' Q2 o
}
2 _3 r3 ?; l M, o7 _9 a9 \</FONT>. y/ a4 W+ i# R3 T0 \: f$ \
</P>
* c- Z* e) a% I<P><FONT color=#ff0000>函数名: exp </FONT>
' a# s/ H' [3 V& I; _功 能: 指数函数 + I6 L: V- R5 e
用 法: double exp(double x);
6 i, q- U( ]' G+ r' o程序例: </P>- [! a9 E6 F+ ^) x7 t# T5 T
<P><FONT color=#0000ff>#include <STDIO.H>
- G1 r1 M3 Q( C+ Z) H#include <MATH.H></FONT></P>
, m+ D) Q Z- G8 ]& r( D<P><FONT color=#0000ff>int main(void) : y: l' m- c0 {. I
{
. K" d4 R$ ~9 i2 D+ o* L6 D. Edouble result;
! Z5 ?3 I* ~9 P9 P2 _9 Q9 bdouble x = 4.0; </FONT></P>/ }% m( m! Z4 \4 J9 [! n
<P><FONT color=#0000ff>result = exp(x); " i2 o/ N/ |; E: H, N7 T
printf("'e' raised to the power \
0 t6 @6 ^3 ~& h. u' u) J4 |7 Cof %lf (e ^ %lf) = %lf\n",
) w/ `3 E! o6 q" Qx, x, result); </FONT></P>4 v/ y+ W$ J% t3 R, P, x- C
<P><FONT color=#0000ff>return 0; , K6 L6 B9 `0 B% V) x+ b
}9 N( @% I9 g' N1 A; @& U4 t
</FONT></P> |
zan
|