- 在线时间
- 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>) t6 N) E. x$ ^9 N+ r
</P>) ~. M- r: }5 r9 I9 }
6 u$ p/ [) L9 Y" F
: ]) J. b+ \% z/ b, |/ C" y) M2 g< ><FONT color=#ff0000>函数名: ecvt </FONT>
3 u% O4 b( e0 y' }功 能: 把一个浮点数转换为字符串
% T. f/ c, o6 |) J/ i用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
; j; o% g- r8 [+ w* z! q$ A程序例: </P>
' C. f% Y/ k4 I$ d< ><FONT color=#0000ff>#include <STDLIB.H>
$ `6 M u9 N/ J. V6 o" U#include <STDIO.H>
4 Z* ]$ x$ u7 N [$ m3 e0 ?#include <CONIO.H></FONT></P>
' m8 @+ B! a j; t2 _- d4 {< ><FONT color=#0000ff>int main(void)
/ x0 H b" x& z{
6 c5 A& p/ W$ H& h wchar *string;
0 L; q% {. q+ H. f" |double value; 0 [/ Y2 b' c. m4 o& E# Q
int dec, sign;
3 z: [- k+ d- sint ndig = 10; </FONT></P>; w4 @( G- r" q5 v. y
< ><FONT color=#0000ff>clrscr();
% j% T" _" h- l& F: evalue = 9.876; 8 ^$ g: U V* \' k# [. M+ C* p
string = ecvt(value, ndig, &dec, &sign); * D: p$ ~; V% T w& N
printf("string = %s dec = %d \ 8 x9 n, [* T; ?4 G [! x ?, n3 u
sign = %d\n", string, dec, sign); </FONT></P>0 o, W. C4 Z1 F6 N7 I6 P4 o
< ><FONT color=#0000ff>value = -123.45;
0 h( N; B) m9 T6 ]8 ]& [ndig= 15; / y" _- {7 m3 H+ Z' {. o
string = ecvt(value,ndig,&dec,&sign);
6 M R2 }4 s/ T6 N5 u; Wprintf("string = %s dec = %d sign = %d\n", ! d. o7 R1 P2 c& M+ Z/ J$ G
string, dec, sign); 6 I; d" q' l7 l# b
</FONT></P>
2 z* H7 ?* |" O- V9 G6 {< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
) V0 W' a/ b" U2 R& {: r `notation */
: \! l+ O! u9 t' Zndig = 5;
# q7 D7 g% [* j hstring = ecvt(value,ndig,&dec,&sign); ; `- d Z4 k& M. J& R$ P; E: }
printf("string = %s dec = %d\
, e4 u' H. t) L4 _0 Ysign = %d\n", string, dec, sign); </FONT></P>' X9 q4 |% g$ E) }& Y( M6 b9 W& k1 Q
< ><FONT color=#0000ff>return 0;
1 h5 k4 ^- v! A, t7 p} </FONT>) N4 D! u* y. C7 ?0 l/ g
$ c- Q1 q6 Y; N. m* n
</P>
7 p' c! k2 q7 q$ d< ><FONT color=#ff0000>函数名: ellipse </FONT>
4 R. F; v% Y) l+ V5 m p功 能: 画一椭圆
# @8 t k# J; O9 K, Y' e5 R6 i) F- w4 W用 法: void far ellipse(int x, int y, int stangle, int endangle, * s* H; P l' c/ s3 u, S
int xradius, int yradius);
4 V% k" S! c4 p2 H+ |! L: ~程序例: </P>
6 \! B: [) T! L% \< ><FONT color=#0000ff>#include <GRAPHICS.H> F6 _2 D3 E- y" n* R# f
#include <STDLIB.H>/ Q8 C% H/ B8 A" o' u: a2 B
#include <STDIO.H>
1 _) g) D4 Z0 ^/ M, l0 q; B$ |#include <CONIO.H></FONT></P>
* {0 [+ s( a3 l! f$ v1 Z( {< ><FONT color=#0000ff>int main(void) 1 a, @8 U' v/ e5 T7 `( X- g
{ " `6 \9 F' P: s! C) i! p
/* request auto detection */ ( R2 n/ ^2 F2 s( m- L3 }
int gdriver = DETECT, gmode, errorcode; ; Y) K9 A4 H& l Y8 b5 P
int midx, midy; , U4 q1 t- Y3 c. O% R. ]" t" c
int stangle = 0, endangle = 360;
3 o9 }, l# J! F& h aint xradius = 100, yradius = 50; </FONT></P>
" R; m# l K) R0 a( i7 s3 h8 |< ><FONT color=#0000ff>/* initialize graphics, local variables */ ' p$ w- g& v3 X/ D
initgraph(&gdriver, &gmode, ""); </FONT></P>
: g3 r2 U8 U+ c% |8 ]; I4 D: f' B< ><FONT color=#0000ff>/* read result of initialization */ & l U2 K0 h/ o+ { @& ?
errorcode = graphresult();
) |- i- T; R1 G0 d% w$ `/ d$ Lif (errorcode != grOk)
5 M4 p2 N1 i( ?0 @/* an error occurred */ , B$ {$ ~' s/ t; ?9 r
{
: [/ R- O g5 g+ D! _printf("Graphics error: %s\n", . i2 G# Z( {7 ?7 G9 V) G
grapherrormsg(errorcode)); * L/ I; U. |: m3 @! C: z) A7 B8 R a
printf(" ress any key to halt:");
% ^; P4 l7 J3 k; Y2 wgetch(); 7 m3 \. C2 m7 |0 H' B6 y$ |* a
exit(1); ( ]1 I7 q2 ^0 @5 V
/* terminate with an error code */ 2 [# |) {1 U) I8 ~3 O- X
} </FONT></P>
1 G0 u: U. ?. ~9 h< ><FONT color=#0000ff>midx = getmaxx() / 2; 4 ]3 a8 g+ n( S
midy = getmaxy() / 2; 0 I u6 Y! V5 D/ e$ C7 A, X5 _
setcolor(getmaxcolor()); </FONT></P>% }( [ w2 O& W3 {; _
< ><FONT color=#0000ff>/* draw ellipse */
" F8 s) l* b. a, i! P3 w# U V0 g- sellipse(midx, midy, stangle, endangle,
5 @( l9 ^8 P) `, Lxradius, yradius); </FONT></P>, X4 ]6 m7 |! x+ h$ K) |: K. ~
< ><FONT color=#0000ff>/* clean up */ + ~/ w, Q. i2 U
getch(); . _9 v3 ?8 A# \( c* Y
closegraph(); : K6 t1 |; \+ \! O f9 i* C0 q
return 0;
. i; {+ Z/ p: w5 |- @$ x} </FONT>
4 p. l% i* d0 c+ V; S! R( a) _* L& d, g; o1 ^) j2 }$ ?
</P>, x. A1 v9 W! y& i# q! o
< ><FONT color=#ff0000>函数名: enable </FONT>
/ s9 Q+ C- O, q2 R/ M. w- S5 Y功 能: 开放硬件中断
4 V& {7 j O: x6 M# ?/ e用 法: void enable(void);
" c, u. C: }6 x程序例: </P>
4 y4 S% ?/ y; r, g+ t# K' e, W4 x< ><FONT color=#0000ff>/* ** NOTE: / H# Q1 B! D9 e: Q3 B) Z
This is an interrupt service routine. You can NOT compile this program ; `4 W. p8 o* K: E5 Q# l% b6 y S- D# c
with Test Stack Overflow turned on and get an executable file which will $ ^6 [$ i! t, [! y5 p% J
operate correctly.
U" T7 I5 I1 v1 |2 ]9 D! [1 m! C*/ </FONT></P>
3 B& m, U" U" J1 t6 f< ><FONT color=#0000ff>#include <STDIO.H>
' L( A# h$ Y. ?) D; A. m#include <DOS.H>2 K6 @" M+ S5 S& W2 \% d
#include <CONIO.H></FONT></P>
. i! @! w1 ~3 [6 _" K1 ~" u% H$ P* z3 z" }< ><FONT color=#0000ff>/* The clock tick interrupt */ ! h2 K8 y- o, p1 z6 v/ I7 ?; j
#define INTR 0X1C </FONT></P>
/ j. H" B0 L+ {' |% L1 S0 \8 x< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>9 X5 @4 R' D- I9 F" K7 ^. ?- |8 [' s+ \
< ><FONT color=#0000ff>int count=0; </FONT></P>
" c1 R5 R$ _6 \1 _, M8 Y& U< ><FONT color=#0000ff>void interrupt handler(void) ! x& G0 i q( B2 w) s8 l C
{
y. x% m0 f4 ?" G' F7 ^/*
7 L1 R: P" ]1 {$ {0 ]" f' ydisable interrupts during the handling of the interrupt
. W5 s( {. O0 s1 r2 ^: {" g*/ 7 A" f& f0 i. ] k" Y1 \
disable(); . ]: A a# M! H0 N
/* increase the global counter */
$ g5 F* e5 G( I+ Y, |' n" wcount++; , [/ v- u. L& X Q7 v: q5 `
/*
; r1 _$ Y5 R' U3 S0 ~% J9 F" Xre enable interrupts at the end of the handler
. \. m* Q! \4 N* W& k*/
. U5 K/ V' G3 |7 Oenable(); % U9 Q5 \' j9 F! _! R! y$ ]
/* call the old routine */ 6 y+ f. n! `9 q2 l
oldhandler();
+ c( d D) w& r/ ?3 W/ U/ R% n# C} </FONT></P>) ^& O% r0 _3 \3 \3 I4 M" q/ M
< ><FONT color=#0000ff>int main(void) 8 I1 m. ~0 n- {. C% \/ I, W
{ ! F+ S8 Y, E/ Q# y8 m/ N! V' @1 f
/* save the old interrupt vector */ " c( q0 X' Y2 L/ v# g
oldhandler = getvect(INTR); </FONT></P>
$ R) j3 t+ [4 A3 N9 H< ><FONT color=#0000ff>/* install the new interrupt handler */
+ {* ?) r; D9 e$ s8 x2 G+ ysetvect(INTR, handler); </FONT></P>
% ?; g( u; r& ^0 B< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */ 4 k. t- g7 f% D0 f3 I
while (count < 20) $ }5 }% p6 r5 p: }. N4 H9 ]: V. _
printf("count is %d\n",count); </FONT></P>
: s3 O: w+ `& t< ><FONT color=#0000ff>/* reset the old interrupt handler */ 3 z/ G- i+ j! t! |
setvect(INTR, oldhandler); </FONT></P>
3 A# `6 z: s; \) l< ><FONT color=#0000ff>return 0;
" Y7 }- C4 U8 Z( b& a. {& ~$ c} </FONT>) I/ B) V. f9 b3 y! S5 E3 ~5 h
$ W3 G) J e" U* p: l( K</P>0 V3 G% K+ B6 O7 ~% G$ }
< ><FONT color=#ff0000>函数名: eof </FONT>3 Y: |: b, E, h% v6 c3 a7 W j
功 能: 检测文件结束
; T& p# ~" D# I/ u$ Q- a用 法: int eof(int *handle); . ], M$ |) V, t r, O6 A# K; d, h
程序例: </P>2 M Q( h5 n+ v7 y
<P><FONT color=#0000ff>#include <SYS\STAT.H>- e6 S2 l3 d; G
#include <STRING.H>
8 C5 @9 I' ~( f: V#include <STDIO.H>2 x J3 b, b+ v, ^& s4 u+ U( i2 X( J
#include <FCNTL.H>0 ^; Y7 G1 c) \* R4 [9 u
#include <IO.H></FONT></P>; d* ~- F5 F. v0 z$ A0 ]
<P><FONT color=#0000ff>int main(void) 9 E2 D" y2 c( T: G2 b( C
{ 0 U+ a7 g* x: u' W" ]% o
int handle;
( \+ q q9 A( `+ q8 fchar msg[] = "This is a test"; / O, c4 ?1 I- q H; y" U4 C
char ch; </FONT></P>
! V. l3 P3 x. k( A<P><FONT color=#0000ff>/* create a file */
! b& w% ?1 I& \% Khandle = open("DUMMY.FIL",
: g i3 @. |) y* r6 Z5 J3 s! C4 \O_CREAT | O_RDWR,
4 I5 h7 Z7 u, f" d! CS_IREAD | S_IWRITE); </FONT></P>9 B- h& ]; g+ u3 ^
<P><FONT color=#0000ff>/* write some data to the file */ % y( d# k+ @* V b# r
write(handle, msg, strlen(msg)); </FONT></P>
# d# A/ o9 A" f% ~2 S<P><FONT color=#0000ff>/* seek to the beginning of the file */
$ e$ {9 G y; ?. [$ ^! T+ Olseek(handle, 0L, SEEK_SET); </FONT></P>
x6 P2 q, S7 a" z<P><FONT color=#0000ff>/*
( ]) S2 w9 m+ J, Treads chars from the file until hit EOF
) A6 @8 l* `8 ?*/ * q7 Q1 o0 y8 n2 N4 E4 ^4 O# o
do `: Y* ~# f. k. b
{ % U9 Q' s+ b+ I6 V: d, e
read(handle, &ch, 1);
) B9 O& e h: ]; q8 w! s( j6 }printf("%c", ch); H3 G' f9 l$ @3 }
} while (!eof(handle)); </FONT></P>
" o9 K- W5 M3 H: ^<P><FONT color=#0000ff>close(handle);
A/ i3 e5 q- N. nreturn 0; 3 u: u1 L& k* l# ^4 g7 [) u2 e \
} # l6 Q# m8 o6 ?: E/ P: b) p0 U
</FONT>) Q5 I" n$ ?1 D7 U
</P>
0 u+ V' T, z' b/ A( i8 a<P><FONT color=#ff0000>函数名: exec... </FONT>
5 K M( J* ?4 F e) f功 能: 装入并运行其它程序的函数 : b7 I3 z1 V1 U1 h9 ^
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); 9 x W$ r, z, e" _" u% i
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
& B- ]$ h; s5 l- s* Zchar *envp[]);
6 }: ^" {5 g! Hint execlp(char *pathname, char *arg0, arg1, .., NULL); 5 k% U ?! T" h' o7 ^0 G- S3 {
int execple(char *pathname, char *arg0, arg1, ..., NULL,
( d0 N; V1 @+ m# t& Q7 rchar *envp[]); + e% L4 W" U9 j, ^+ r% h/ [% h* P
int execv(char *pathname, char *argv[]);
: p7 O( a( L! ^" g6 ~int execve(char *pathname, char *argv[], char *envp[]); 9 d" U/ J; A+ J. ?9 G5 z8 O
int execvp(char *pathname, char *argv[]); 5 g0 L( V9 i! J8 m; h _
int execvpe(char *pathname, char *argv[], char *envp[]);
, T) y+ J: |# v q H# \) \程序例: </P>! |- U* [! ~% W& \" E# f" ^
<P><FONT color=#0000ff>/* execv example */
/ {! E5 M. }4 G% |! Q#include <PROCESS.H>
. p( e! G+ g6 a* u: ^! l#include <STDIO.H>
: x! I* j1 {6 `3 ~, k3 Q X#include <ERRNO.H></FONT></P>6 m5 G9 p( `4 Y, s
<P><FONT color=#0000ff>void main(int argc, char *argv[])
- D4 \! g3 L+ w{ / P' `- c- h- R8 G, w( z
int i; </FONT></P>
8 z0 c2 S2 v7 {2 K- @* H<P><FONT color=#0000ff>printf("Command line arguments:\n"); & P q% E# C) j; G* ?
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
* H7 g$ i- w- B: z! I, y O% I<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
$ L* \3 z; r5 `) D) p, nexecv("CHILD.EXE", argv); </FONT></P>) ]2 p, K. r0 j
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
- C- A, @# X7 e9 j( H/ s! e. j<P><FONT color=#0000ff>exit(1); 9 e! B0 R6 S9 o2 B0 A( s( R% m
} 9 {, S" { h, B: A( y3 T- K3 w% P
</FONT>
1 c0 p0 R3 ?% {- D+ Y1 k) B2 V' F</P>
$ `2 N; x" r2 ]0 Y! F<P><FONT color=#ff0000>函数名: exit </FONT>( f' ?8 |) J) a6 {: {! P
功 能: 终止程序 7 {3 E1 e9 k7 s0 H8 q2 m
用 法: void exit(int status);
( E' P! S/ r/ D" M8 I程序例: </P>
2 a3 ^" a) d! H1 w<P><FONT color=#0000ff>#include <STDLIB.H>4 B9 z/ y2 d2 U" e- q: F, f2 C
#include <CONIO.H>
" w2 i+ p$ L; q7 u8 ~#include <STDIO.H></FONT></P>
) [9 S1 d9 {' A1 N$ f<P><FONT color=#0000ff>int main(void)
8 I+ ^9 {; v8 _& \2 O; X$ i{
- C, w$ c; {6 r7 N* u" vint status; </FONT></P>" K. c% s7 i7 ~/ Q
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
9 D& p3 z6 u* p6 H/ o8 Jstatus = getch(); 2 V6 _! u7 K/ a% P4 W
/* Sets DOS errorlevel */
5 ^ j1 g! t+ ]/ E) Q. D. d0 Wexit(status - '0'); </FONT></P>; t& q; y% Q q) B- x+ d. q. Y1 A. e
<P><FONT color=#0000ff>/* Note: this line is never reached */
0 C3 C8 {" r7 e( \return 0; 3 m! u6 l/ b- `: z
}
9 I) q! a! n. |+ d# K1 |+ s( S$ \</FONT>
" f4 L. ]0 O: R" ^6 P: O) ^( Z</P>1 I4 A ]# B$ s* w. `# F0 w3 P6 G
<P><FONT color=#ff0000>函数名: exp </FONT>/ c/ D: e4 s) n- ]2 S, ^: Z& }
功 能: 指数函数
: a5 Q/ p0 z% n, q* M用 法: double exp(double x);
! H4 k2 c! M, v, Q- N6 n) v$ L1 V' w$ `程序例: </P>
! V( i- N: s6 x$ M<P><FONT color=#0000ff>#include <STDIO.H>
$ w' n5 D3 Z6 j; k* g#include <MATH.H></FONT></P>
" H. U7 W, P& x* `<P><FONT color=#0000ff>int main(void)
6 I/ G. B j, D7 G0 |! A" O/ a{
# _' H' ^4 [2 h2 S, ^( l1 d0 R0 Ndouble result;
; N, D s2 B1 k" U/ F2 `' Wdouble x = 4.0; </FONT></P>5 |$ d7 G% q0 k2 f
<P><FONT color=#0000ff>result = exp(x);
2 C" d) h/ l9 r* a7 a$ Yprintf("'e' raised to the power \
$ d$ a: ?$ g: g4 P, Qof %lf (e ^ %lf) = %lf\n",
& i3 J( {* K' m4 P) Hx, x, result); </FONT></P>4 M# X( G! B5 N3 x
<P><FONT color=#0000ff>return 0; # X7 y1 \) U! d I" d
}' W5 m. I8 `3 E Y0 W
</FONT></P> |
zan
|