- 在线时间
- 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 ^$ p Z* F' P# Q& g- j$ Y) q5 j: u</P>- t& d. J4 v( N
6 z2 W# Q+ X4 H
0 d7 x$ l+ O. M, [& S< ><FONT color=#ff0000>函数名: ecvt </FONT>
0 E+ X8 t) T# H功 能: 把一个浮点数转换为字符串
- s! _% S% Q Z7 }, j. K+ M7 A6 w用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); 5 V+ K# ]0 X L* w
程序例: </P>1 C( X, N* Y9 t% Y" C
< ><FONT color=#0000ff>#include <STDLIB.H>
6 T, k8 W8 `0 g: u" ?& M' {9 U#include <STDIO.H>
3 S/ o! S5 o8 \$ k/ O- w# ?8 A0 S% b#include <CONIO.H></FONT></P>
; d7 b8 g! L8 Z6 b! g- P4 D; T' j< ><FONT color=#0000ff>int main(void) 2 ^4 Y, m" F- Z3 F. `- W( b2 r e' l
{ ; E+ Y$ Q8 Y; P+ i
char *string;
& c+ S% N2 H! Ydouble value; + J4 T: W- f& g* ?
int dec, sign; : h; I; a1 ]! ^: E" u' w
int ndig = 10; </FONT></P>
* G X/ U. @8 S% d; A< ><FONT color=#0000ff>clrscr();
# z- J" o: c# e3 Yvalue = 9.876; ( T5 ~* S" l3 ~4 C9 c
string = ecvt(value, ndig, &dec, &sign); : U* V# u8 \; C5 }
printf("string = %s dec = %d \
1 n$ n, x1 s6 \+ H' T; i) [sign = %d\n", string, dec, sign); </FONT></P>
4 K5 C, o' D' a$ p4 D+ ?< ><FONT color=#0000ff>value = -123.45;
; r6 c8 Q' v( R2 sndig= 15;
4 ~' b6 E5 _& g0 pstring = ecvt(value,ndig,&dec,&sign);
! x' L j9 v3 d9 dprintf("string = %s dec = %d sign = %d\n",
) w7 k5 ^" ~2 m' W8 Wstring, dec, sign);
' y: q! c+ K0 ]6 G' d# a2 L) j</FONT></P>/ \& T1 \- K- n( q1 K
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
6 Q+ s2 W F5 W; L5 }0 @" f2 O3 Lnotation */ a: L' Z& z5 h$ R& j8 D6 G
ndig = 5; ) k" [) T, D- [" J4 ?8 S2 d C
string = ecvt(value,ndig,&dec,&sign);
+ J+ ?* c1 q3 ^, ?" j1 U" s# Iprintf("string = %s dec = %d\
' I/ l, J6 T* ?4 C$ _sign = %d\n", string, dec, sign); </FONT></P> S1 } l: m0 W
< ><FONT color=#0000ff>return 0;
1 ?! @* g$ ?9 U/ G1 f. K} </FONT>6 N! s* V, W' z/ I
. g1 \) N1 }# b
</P>
& }1 C: r3 ?; p< ><FONT color=#ff0000>函数名: ellipse </FONT>+ i+ c# w6 F* j, _6 `( R* c
功 能: 画一椭圆 3 e8 e# W, ?, w( V- m
用 法: void far ellipse(int x, int y, int stangle, int endangle,
5 e: ?7 e- c" C4 p8 Tint xradius, int yradius); 7 N; R" r2 ]: e. V$ y( H
程序例: </P>. o0 d6 I" _! ?
< ><FONT color=#0000ff>#include <GRAPHICS.H>
' e! h% j0 O, _) X% y0 J# R! d#include <STDLIB.H>
1 l2 D3 R1 H9 L* x# c- w' |#include <STDIO.H>
' v# |; w6 E% f#include <CONIO.H></FONT></P>: X0 s; X/ V' y. j( a
< ><FONT color=#0000ff>int main(void) ! G2 y8 T1 D. h. b. s9 M
{ 5 w+ G) h) {; F j& N6 K9 M. j8 \
/* request auto detection */ $ ]( [/ O( n) D( o+ ?# Q
int gdriver = DETECT, gmode, errorcode; z% N% w2 s% T9 p
int midx, midy;
, y3 [: m$ J$ {int stangle = 0, endangle = 360; 3 b' `0 G' v9 _' m2 y/ ?
int xradius = 100, yradius = 50; </FONT></P>4 U) Z# R3 {0 n8 h3 j
< ><FONT color=#0000ff>/* initialize graphics, local variables */
0 ^' G% W; u8 t9 Minitgraph(&gdriver, &gmode, ""); </FONT></P>
$ i4 p; V$ a4 t' P1 E" x+ N< ><FONT color=#0000ff>/* read result of initialization */ 2 T- u: _6 s$ V$ T4 x1 n
errorcode = graphresult(); ; x# Y9 s3 W% y: a
if (errorcode != grOk)
2 v# h# ~, J4 `1 J/* an error occurred */
2 k. ]+ J. E5 ?3 b/ M{
$ w, t4 R$ G$ ~. D7 j+ n( a! }! G- dprintf("Graphics error: %s\n", : H4 `/ n& e# \7 z( F
grapherrormsg(errorcode)); ( Z: M0 O U* k2 H6 n/ b7 l
printf(" ress any key to halt:"); : J) |; h' H j' C- O! T
getch();
8 ?- \1 ?7 @1 H) X$ V' qexit(1);
3 K% S! n8 @8 j9 O, u' D/* terminate with an error code */ " p; Y+ z" [7 C+ w
} </FONT></P>8 _: U- d$ j( I, ]8 F) Z) ~
< ><FONT color=#0000ff>midx = getmaxx() / 2; & c8 O0 p& u5 X5 o0 w# y
midy = getmaxy() / 2;
( ?1 C" E8 r1 Rsetcolor(getmaxcolor()); </FONT></P>9 _/ E5 ]: ?6 Q9 a
< ><FONT color=#0000ff>/* draw ellipse */
, f, i" k7 o6 y" H+ ?' `$ @ellipse(midx, midy, stangle, endangle,
8 Z% t3 ^. v9 ~. H' X! [xradius, yradius); </FONT></P>
" j. b; l$ V* V; S< ><FONT color=#0000ff>/* clean up */ 0 b) G4 k. h' e7 l7 u5 _, P& U, a
getch();
: E* A/ b: K& F: A Xclosegraph(); ; T' [6 z {# x$ h
return 0; 7 L. W. }: t# H- p& M8 v' |" y1 ]4 b$ i
} </FONT>
) \- M0 Q) p, J' U+ N: L- u
9 H W& u% }3 d. L2 z</P>' i* L& S1 z2 v: g; I: L0 ~
< ><FONT color=#ff0000>函数名: enable </FONT>
2 h& _& m9 B- t1 T8 [ ~# Z4 b; X( T功 能: 开放硬件中断 * l5 ~) F$ z4 @* x" W, X
用 法: void enable(void); 3 q* D; N$ I3 y, j4 ?
程序例: </P>
0 T) d9 U8 B" Y$ ?- c( j; r< ><FONT color=#0000ff>/* ** NOTE: 8 E) W9 |* u* x
This is an interrupt service routine. You can NOT compile this program
) I! q: d0 Y+ X0 }" ?with Test Stack Overflow turned on and get an executable file which will
* {" k+ u0 i0 J4 L3 roperate correctly.
6 E2 I7 t% U1 R3 P2 W*/ </FONT></P>1 q$ j& `( t# v1 f5 o
< ><FONT color=#0000ff>#include <STDIO.H>
8 I7 K6 C8 ~' `1 R2 A#include <DOS.H>
" I& {; M: f& a8 {" @#include <CONIO.H></FONT></P>( j, y+ r2 o4 u, K4 v/ J
< ><FONT color=#0000ff>/* The clock tick interrupt */ . o8 E3 v7 G: s' s: c5 W; X( x
#define INTR 0X1C </FONT></P>, e2 ~4 r% O! E+ g3 Q6 `: _
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>1 d6 f' s# r; q: a2 I% E
< ><FONT color=#0000ff>int count=0; </FONT></P>% k5 X$ A, k6 b$ A
< ><FONT color=#0000ff>void interrupt handler(void) ) l' Z W! `8 d D$ Z
{ ) n1 c" z! `) O
/*
, } f, y5 q; y: ]/ M( Sdisable interrupts during the handling of the interrupt
n. m. g5 v1 }! N7 Z*/ * F# M' E/ F* m' I; F
disable();
4 ~* V' J9 t8 {" A u4 ~; v l/* increase the global counter */ $ O# x n" l6 U e: C) }3 ~
count++; ! s$ V6 B8 e( Y, G
/*
$ ?/ e6 }' F3 D+ M3 v( \2 d& H! b3 Lre enable interrupts at the end of the handler
& h2 Z5 y$ K: a4 q$ a*/ ) m0 ?* J& z, H5 A8 m) F, D
enable(); ; d1 q# _5 L B8 L5 {0 e+ ~7 d/ b
/* call the old routine */
8 ^# {8 I( E; w5 Zoldhandler();
H1 L! e$ `2 L9 P" Z. _} </FONT></P>' q, R( }8 {3 F+ ^0 k) r4 [
< ><FONT color=#0000ff>int main(void)
8 s" ]. Z' P4 Q, f1 a l* }' T# u{
( l/ J# Y7 ]2 b" }/* save the old interrupt vector */
* t% |9 I. u* ]8 U1 qoldhandler = getvect(INTR); </FONT></P>* p/ w* q5 b5 I& t# g2 A) X r
< ><FONT color=#0000ff>/* install the new interrupt handler */ ( a5 f1 A$ X2 ?
setvect(INTR, handler); </FONT></P>3 ?) e5 ^( z( S4 ? u5 e
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */ , d9 O' S3 E, H/ _6 P I. T
while (count < 20) ! n5 Z! ?9 ~7 p0 p
printf("count is %d\n",count); </FONT></P>. |, {6 S" }; Z2 _ V; L) s
< ><FONT color=#0000ff>/* reset the old interrupt handler */
: f) _% D# J0 F3 ~* l' M4 ^setvect(INTR, oldhandler); </FONT></P>0 H t* F! M) Z9 M
< ><FONT color=#0000ff>return 0;
) j4 ^. W" z' ^4 k) U} </FONT>: V( V& r' c' y6 Y
, k' j4 L' C; f( I% S- W) U</P>
& G- S" M9 p# S7 ?< ><FONT color=#ff0000>函数名: eof </FONT>5 k& Q$ f& R7 t) ]5 l, P- I% F
功 能: 检测文件结束 $ H/ ~& Q$ n3 T8 o
用 法: int eof(int *handle); 7 J% W! J. f1 }- y9 X. v6 G
程序例: </P>$ Z/ l' v; J+ C0 ^5 w
<P><FONT color=#0000ff>#include <SYS\STAT.H> K: r5 d* d1 ~6 Y; L* R- \
#include <STRING.H>% x, R$ d" G A# O) L2 _
#include <STDIO.H>
5 z9 P- P: n- ^0 {#include <FCNTL.H>
8 k( i, Y- x8 a& y; s#include <IO.H></FONT></P>6 w; g @; c) j$ Y+ m' {, s/ K
<P><FONT color=#0000ff>int main(void) ; w, q+ v |/ h4 J& ^$ a' `
{ ) O( N8 Z, X7 M6 i. `
int handle; ( U/ ^, a1 @; n9 a
char msg[] = "This is a test"; 5 x% D9 f; z$ @# C* F( W
char ch; </FONT></P>* B3 M4 c. P$ q8 o, t# B* F
<P><FONT color=#0000ff>/* create a file */ 0 _/ B- `$ t1 n2 G, ^
handle = open("DUMMY.FIL",
1 T* m; A$ Q: DO_CREAT | O_RDWR,
8 c p2 j+ \+ ~7 l& pS_IREAD | S_IWRITE); </FONT></P>
1 v- w% u, m. G, s" p0 Q<P><FONT color=#0000ff>/* write some data to the file */ 3 j& @- o8 A3 P& q
write(handle, msg, strlen(msg)); </FONT></P>
0 q" m5 U. k5 n/ N( ~4 Y- e<P><FONT color=#0000ff>/* seek to the beginning of the file */ ! H& d# P* ^9 V- c1 ~$ z' u
lseek(handle, 0L, SEEK_SET); </FONT></P>% V( k, S$ }1 \4 ]& l
<P><FONT color=#0000ff>/* 8 o( ?9 n3 x; F' I2 q N. j
reads chars from the file until hit EOF ) |" L F$ z! h" _* y
*/ * f% s2 I9 u y4 {6 L" R- r" z
do 0 k# `6 P1 ]" w# h. Q
{
/ k) P& X* z% J* vread(handle, &ch, 1); : ~: [# ?6 r' |
printf("%c", ch);
/ {7 y. u# w" b* _ e5 y9 M0 M/ i} while (!eof(handle)); </FONT></P>
6 {) o3 n* U7 ^7 M: ^0 X<P><FONT color=#0000ff>close(handle);
. R) X3 W4 X/ f# Q6 B# Freturn 0;
8 }8 i7 y6 y5 { E}
0 n: q8 ?& O y+ d</FONT> n4 L9 Y2 ]" q
</P>
: m; ]$ v/ }+ A. |4 P<P><FONT color=#ff0000>函数名: exec... </FONT>7 I( B( m8 |3 L+ m, o: o
功 能: 装入并运行其它程序的函数
: a5 C( ?6 X* y4 p. G用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); 5 i4 l U7 o1 i
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL, + P3 Z4 i) a5 c) c: D
char *envp[]); + z, W V1 n% c7 g% L: [1 y4 c
int execlp(char *pathname, char *arg0, arg1, .., NULL);
" [: d. J. A+ i* v. xint execple(char *pathname, char *arg0, arg1, ..., NULL,
# `- Q5 l; M; n; K/ y' l8 ~char *envp[]); D7 U) j! V* x& F6 \' q8 S
int execv(char *pathname, char *argv[]); 5 J4 g+ P+ L3 |* I* A/ G
int execve(char *pathname, char *argv[], char *envp[]); + i! S0 f( d- G+ y2 p* ?; A' l
int execvp(char *pathname, char *argv[]);
, y- G7 ]( y, ~: ^int execvpe(char *pathname, char *argv[], char *envp[]);
4 M. P5 C+ o; i: l2 a4 n. }程序例: </P>
# O' p6 |' B4 m! g% a. h) X<P><FONT color=#0000ff>/* execv example */ # ^4 \& V3 [; F3 i# j- d5 x
#include <PROCESS.H>, e" B- ?9 }. V- s
#include <STDIO.H>. F. K- y$ z" L2 l( G& y
#include <ERRNO.H></FONT></P>
) Z0 d" m0 J8 f<P><FONT color=#0000ff>void main(int argc, char *argv[]) 9 y. U0 L8 b0 ` t6 V$ `* \$ G6 f
{
8 I/ [ C, i( T7 \+ _int i; </FONT></P>* f( j# u' i" g( R& L7 @8 X
<P><FONT color=#0000ff>printf("Command line arguments:\n");
0 S- o* ^0 l5 t) o. K, Q) s2 Zfor (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
/ R; z w0 a9 k1 V<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); + n+ O1 U( ]" k" {! W& ]: k
execv("CHILD.EXE", argv); </FONT></P>
" A/ M7 Z/ _8 c6 V7 w<P><FONT color=#0000ff>perror("exec error"); </FONT></P>! A1 T1 K; v7 N' T4 ~
<P><FONT color=#0000ff>exit(1); , S; v& ]/ t: L; o
} " ]6 Q; ^% w9 U" ?
</FONT>
1 j3 X- z8 F! L* U. e</P>
7 O7 r; m0 N7 w' @5 C<P><FONT color=#ff0000>函数名: exit </FONT>
+ U# ~& T( x2 J) P) N9 D. z) X功 能: 终止程序 # \, G2 W3 p0 ]7 s! a4 i
用 法: void exit(int status); - _5 @$ K: J& {/ v& [' y
程序例: </P>
' h9 D. F( l4 a7 \- R<P><FONT color=#0000ff>#include <STDLIB.H>
# M3 ]$ F( b, D#include <CONIO.H>
* c8 ^' w! _2 J# i#include <STDIO.H></FONT></P> |0 G+ ^9 n8 ` d
<P><FONT color=#0000ff>int main(void)
1 [9 V* V- d3 P0 v) ^{ ! u# V1 E! A/ Q, N2 ^* S: s& ?
int status; </FONT></P>
) L! X3 V) ]" y4 n) t<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
; j4 L2 r/ \, Y6 l) j1 l3 jstatus = getch(); 5 F8 v/ G/ k" j$ T" j
/* Sets DOS errorlevel */
- u& Z% P, N+ p( j- }0 @exit(status - '0'); </FONT></P>
0 r) P, r- d( m$ ?& O" S<P><FONT color=#0000ff>/* Note: this line is never reached */
, ?) O' D: a. j! Vreturn 0;
" @$ U2 ? t6 D* G8 }; y}
2 m. m1 P4 R9 y" ]</FONT>* F) w! L& U9 Q3 G4 O
</P>
2 k7 {" |- I# @8 g<P><FONT color=#ff0000>函数名: exp </FONT>, V+ x, f8 l, R8 \
功 能: 指数函数
# i% _& G4 D3 V, ]# R) C2 f R用 法: double exp(double x);
* y+ W8 \/ f. m程序例: </P>
6 c |+ v* I0 v7 a6 M4 }- F) t) U4 l<P><FONT color=#0000ff>#include <STDIO.H>
1 c, r" b, m, i( n4 \; R) @! f9 p#include <MATH.H></FONT></P>2 X1 i8 n" i2 R# i6 q: M; d* ?
<P><FONT color=#0000ff>int main(void) ) x& @; `: ~6 y. G6 w) Y
{ ' @ V! I0 G8 |0 ]1 ?; I" K
double result; 6 @" `% E* Y0 `2 T, g
double x = 4.0; </FONT></P>; D0 s8 N6 I/ p* D2 y
<P><FONT color=#0000ff>result = exp(x); ! F: ~6 |6 |: O' {& h1 _
printf("'e' raised to the power \
& u. b+ h$ ~+ Rof %lf (e ^ %lf) = %lf\n", , @0 U( h& f2 P2 P6 P) d
x, x, result); </FONT></P>2 z0 G6 [' G) e
<P><FONT color=#0000ff>return 0; * f' g$ R+ `0 ]) G' v& n
}
7 x$ K" |' s! o</FONT></P> |
zan
|