- 在线时间
- 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>
% H% q! Y! A, o4 _3 v, b</P>! u' F$ [; y# W6 K/ {
9 u6 e+ \( w* L& K/ o# E% |$ p% r& x: o6 V( C
< ><FONT color=#ff0000>函数名: ecvt </FONT>
2 y+ ~4 p4 k0 {& h. h, K功 能: 把一个浮点数转换为字符串
# m% B7 D$ {9 p/ [3 `用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); ) U4 Q" R1 R, t: X6 O K
程序例: </P>
/ A% I! W s- c k. C) d! V< ><FONT color=#0000ff>#include <STDLIB.H>' {1 V3 x _: @; Y
#include <STDIO.H>
6 H' h! t1 @8 `. M#include <CONIO.H></FONT></P>& h! `! @2 ~; t: ~
< ><FONT color=#0000ff>int main(void) 7 K# X: Q' H9 Y& m( C( h8 I
{
: _" M# D8 X+ q* u. Uchar *string;
8 R& B3 B" Z7 l2 d7 q5 \' a/ O3 X; Qdouble value; + Y0 g; {$ Z9 I
int dec, sign;
6 i4 s& b, b8 B* f( Eint ndig = 10; </FONT></P> I) h! N, N6 q) A
< ><FONT color=#0000ff>clrscr(); + q$ x' _ V; O5 s( q9 ~
value = 9.876;
8 g8 c7 o' |* q5 Q7 i# |5 Ustring = ecvt(value, ndig, &dec, &sign); 2 ~0 U0 H! r* Q, g+ c# a
printf("string = %s dec = %d \ M# | q3 e, ?& [! u- F7 P# f
sign = %d\n", string, dec, sign); </FONT></P>/ m* y0 V1 O" t; ]
< ><FONT color=#0000ff>value = -123.45; ; c8 g2 ~; T, j' r7 D
ndig= 15;
8 }$ o# q" O: c0 W$ ystring = ecvt(value,ndig,&dec,&sign); 3 F8 h/ }! P) d H
printf("string = %s dec = %d sign = %d\n",
8 j4 r3 q! O' S5 G* ?string, dec, sign);
/ U7 K1 m2 W' M# ~</FONT></P>8 V- v$ t N( {, @! ]! x
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific $ e' S1 _' C4 N+ ~/ H( b% e: O
notation */ - y9 ^1 }. Y% _( u* p; E
ndig = 5; $ ], Z- V8 x% Z: S6 W
string = ecvt(value,ndig,&dec,&sign); 7 i# m% M0 m: @8 G
printf("string = %s dec = %d\
% {" S* u$ C) ]: c+ ?0 w- V; ysign = %d\n", string, dec, sign); </FONT></P>: L) W( l7 E# ~" l
< ><FONT color=#0000ff>return 0;
0 c, Z: }* S* T/ D1 a$ v, _% f} </FONT>1 u% y1 c/ g& X, v9 W. G
8 ^# C/ F6 T- _% a/ n
</P>. z0 S$ m/ H& _6 x5 W4 `8 }
< ><FONT color=#ff0000>函数名: ellipse </FONT>
& }3 O i+ O; X+ F8 k- _功 能: 画一椭圆
1 p$ ?" o) s4 p2 [- h/ g用 法: void far ellipse(int x, int y, int stangle, int endangle,
( P4 N& Z" g/ o+ b7 C8 O- P5 g/ D4 \ gint xradius, int yradius);
% T. A0 ~: N2 q- S+ g程序例: </P>3 w a6 ?1 Z- m
< ><FONT color=#0000ff>#include <GRAPHICS.H>
6 l$ p, K" l8 y! G5 @#include <STDLIB.H>4 {: S) ~- `7 K" ^! @3 G
#include <STDIO.H>
1 E' w0 B5 z m& V: {#include <CONIO.H></FONT></P> X' {0 p! U0 i
< ><FONT color=#0000ff>int main(void)
3 N" |, h, Y- F2 v{
) `( h5 P8 k) W: v6 T/* request auto detection */ 6 s. o# u8 L- X3 ]& O5 W
int gdriver = DETECT, gmode, errorcode;
; H3 n# P: n% _: l3 \1 M4 q1 w Yint midx, midy;
$ `# A/ q# z3 l+ @6 Hint stangle = 0, endangle = 360;
. v" z( M& K6 I: }/ V: Oint xradius = 100, yradius = 50; </FONT></P>
# u4 z2 o1 u$ |0 s" i( A! @< ><FONT color=#0000ff>/* initialize graphics, local variables */
2 x( s& }9 J9 X2 Iinitgraph(&gdriver, &gmode, ""); </FONT></P>
7 [9 U0 z0 m; b8 s9 X# {( q< ><FONT color=#0000ff>/* read result of initialization */ 8 W4 {5 }9 v N0 J% w+ V
errorcode = graphresult();
# }4 Q. a( L4 `7 q# sif (errorcode != grOk)
# O- d' \# I5 j1 g1 S/* an error occurred */
Q& i! C6 o) x! s6 m% T( M9 ?{
# V# `# @! G0 N5 ?* x4 |1 eprintf("Graphics error: %s\n",
/ ^1 F) l! K8 }- W& p2 _3 ?8 Egrapherrormsg(errorcode));
5 V, o4 s. d+ E' R+ Vprintf(" ress any key to halt:"); ) M: l6 O+ G# @4 Y# ]8 ^, p, A9 x
getch(); 6 Q. B; {6 T2 ?# I
exit(1); # A/ D( I7 ], Y
/* terminate with an error code */
. [# u+ ?# c! `$ \} </FONT></P>4 Q: W. |9 `. s+ x# K& r
< ><FONT color=#0000ff>midx = getmaxx() / 2;
2 g4 b" w- W6 f. f- E6 tmidy = getmaxy() / 2;
# t7 v' k( ?' z# ~* ysetcolor(getmaxcolor()); </FONT></P>
) W- o m$ j* ]< ><FONT color=#0000ff>/* draw ellipse */
, S+ u5 Q4 m1 }* z2 A- g" yellipse(midx, midy, stangle, endangle, + ~: J$ e* @3 m. D
xradius, yradius); </FONT></P>9 N/ K, H% r! [# ?) G8 c+ _
< ><FONT color=#0000ff>/* clean up */
: P) A O" r) P; k) P, M- Egetch();
! I& R% B+ S) Q) R4 sclosegraph();
, g& n) X" Q0 t8 N1 j$ V2 @return 0;
) d) w1 i# l4 o( |: I- K b} </FONT>" Y4 y3 ]# V) p: y1 H
d5 ]4 _: r8 A3 G, f
</P>; B7 u g& ~: p. _1 V8 I5 ?4 t1 k
< ><FONT color=#ff0000>函数名: enable </FONT>8 A8 |) _, s! ~$ v& q. b
功 能: 开放硬件中断 + W# e1 X( t) R; J& m8 a
用 法: void enable(void); 8 `+ }) b9 \. p1 b2 L
程序例: </P>6 {) x& j4 H0 q# n- l9 t
< ><FONT color=#0000ff>/* ** NOTE:
. U, w, K1 c w( b3 ^, K$ S1 VThis is an interrupt service routine. You can NOT compile this program & ?6 g. M# [* ?7 F8 Q
with Test Stack Overflow turned on and get an executable file which will , c" z& K s% b0 m: i( M* Z
operate correctly.
( t$ `0 `7 w, w4 Q( F0 c* N*/ </FONT></P>! I0 \4 D, Z! K5 a
< ><FONT color=#0000ff>#include <STDIO.H>
6 j+ `7 @+ m: c) Y3 E! t#include <DOS.H>
1 K/ _' U4 l+ T#include <CONIO.H></FONT></P>7 g7 e; l' x* T' i. c! D
< ><FONT color=#0000ff>/* The clock tick interrupt */
) f% Y _) K& V9 C$ g/ Q- Y#define INTR 0X1C </FONT></P>: c8 w! D1 R0 t: V! K/ {7 J
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>
, p, f. h8 h; Q< ><FONT color=#0000ff>int count=0; </FONT></P>
- m7 ~, x7 b' h) ]< ><FONT color=#0000ff>void interrupt handler(void) " W; h( ]# p2 D7 A
{ % \1 x, o# ]) P. [, t# P
/*
6 K& m- R' z8 r2 r/ W- Pdisable interrupts during the handling of the interrupt
# {) O+ v0 G8 r! k [) ~: X! B# v*/
, J4 x6 I4 g. ~0 ]3 Y) idisable(); 7 f/ G7 Q& k' }; |8 P
/* increase the global counter */
. ^& m; j& v/ ecount++; * R0 L1 O, B/ |, f9 [
/* 3 e. a% U5 i& U5 s3 S5 U& D
re enable interrupts at the end of the handler * ? R* x7 y' R8 ]& S
*/
( i. |3 N5 C8 f7 Menable(); ' @ c( y- J+ e- h, e
/* call the old routine */ 0 R0 l3 Y( Z* a$ F
oldhandler();
/ E" G- j$ ?' }- M! i2 `} </FONT></P>6 N+ [) k" N1 {
< ><FONT color=#0000ff>int main(void) + H/ r" ?3 O# V: _: G$ L/ D% _
{ ; r) b% e' ^) I# |9 O
/* save the old interrupt vector */ & q) B. b Y% }& p
oldhandler = getvect(INTR); </FONT></P>9 E+ x9 ~. N" g6 t' J7 L
< ><FONT color=#0000ff>/* install the new interrupt handler */ 7 r4 S) l( |" Z; u% p+ }8 x$ E
setvect(INTR, handler); </FONT></P>
# `$ `$ ~1 H4 Y5 E/ H< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
1 m8 L* J, l0 ^ h5 W: Dwhile (count < 20) 9 `" g2 p: h) h& x, U" [7 y
printf("count is %d\n",count); </FONT></P>
' r& s" f& C( q) t, i* u% Y/ m< ><FONT color=#0000ff>/* reset the old interrupt handler */ @2 ]1 G+ M" x c9 K
setvect(INTR, oldhandler); </FONT></P>
, d$ \5 m3 V- j; X< ><FONT color=#0000ff>return 0;
$ _/ Z; R& `& a# c8 b} </FONT>
+ q# J% ^" x6 i+ u9 X" o
- z1 F0 e# m, G$ g</P>
( o& V c5 g" j< ><FONT color=#ff0000>函数名: eof </FONT>
8 b0 h" h) d5 }9 P% E功 能: 检测文件结束
0 q' y- x$ C7 Y7 i用 法: int eof(int *handle);
# a; |: B; a3 N0 A! o* Z程序例: </P>
6 @, _" |; q3 ~) e3 H$ T) h. `, b<P><FONT color=#0000ff>#include <SYS\STAT.H>! z( ]& C% L) Q! b" u
#include <STRING.H>
/ p1 V3 C/ ]) X#include <STDIO.H>
U. L* z9 r* G8 V2 G3 j#include <FCNTL.H>
$ e9 q5 P' k; c#include <IO.H></FONT></P>
: C1 Y1 B$ w. O/ k2 u<P><FONT color=#0000ff>int main(void)
$ b- p$ j( o( [. u: k: ]9 R% o{
" ~9 M9 H$ ^7 a- s3 y( |% B# aint handle;
/ P+ H& w0 L1 n2 lchar msg[] = "This is a test";
. F+ u" f$ R1 h( t5 n. V! achar ch; </FONT></P>+ y' z2 h, L3 R) l+ b) Y+ {
<P><FONT color=#0000ff>/* create a file */ 4 y7 {% d. _; C* b
handle = open("DUMMY.FIL",
) X$ a) U: X6 v6 t QO_CREAT | O_RDWR,
( n1 C. k$ `; N2 gS_IREAD | S_IWRITE); </FONT></P>
" }# s. e: H5 A. W( G<P><FONT color=#0000ff>/* write some data to the file */ - p: o E; Z. s" U2 p
write(handle, msg, strlen(msg)); </FONT></P>% N" w- k, F+ c% R5 h3 A9 p- A1 O
<P><FONT color=#0000ff>/* seek to the beginning of the file */ 0 S5 n5 c7 D5 A
lseek(handle, 0L, SEEK_SET); </FONT></P>7 Y6 x/ m( \9 u$ B8 z
<P><FONT color=#0000ff>/*
. F, O( o( v7 D% f9 Vreads chars from the file until hit EOF
2 {& P$ I$ V- n) K% a*/ ( V5 u3 ^9 `+ ]. N {2 U% \, m( A
do
$ d2 G R3 ]3 \: v( p{
2 [- p) c; W7 u2 n# dread(handle, &ch, 1); % C! T' [( m( y' T9 I7 q7 l
printf("%c", ch); ) q3 E* K. T% U- u% A5 s5 f
} while (!eof(handle)); </FONT></P>
: w. E3 b; { o9 q<P><FONT color=#0000ff>close(handle); # Q* P9 W) b3 [! `- h
return 0;
- C+ p$ o; S( ]: |4 S9 k}
3 L3 z' u- M0 N! }" l5 r6 R</FONT>
% j4 e, D( M: e/ |2 U4 @, \: A( q</P>3 g/ l* `7 ]6 v5 r
<P><FONT color=#ff0000>函数名: exec... </FONT>: M* G% i2 H: r2 b5 C5 ~2 [6 X
功 能: 装入并运行其它程序的函数
( \6 `6 q$ i8 i3 x% C, ]; @0 w; A用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
9 n* |* Q# ~" L0 i! l5 b+ P9 Bint execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
8 a6 @/ s3 J/ {, t, c3 p/ zchar *envp[]);
2 C& m; M2 M Q, A' `int execlp(char *pathname, char *arg0, arg1, .., NULL);
_0 c7 r" h$ R# u3 H. w. Wint execple(char *pathname, char *arg0, arg1, ..., NULL, " J3 z4 h7 p( i, r
char *envp[]);
]0 H( A# k+ ~% V/ \+ _int execv(char *pathname, char *argv[]);
- l9 P0 I7 A H Y: g) Kint execve(char *pathname, char *argv[], char *envp[]);
( }5 K( A7 |) ^int execvp(char *pathname, char *argv[]); , h" l0 A/ N9 P, {# r, H
int execvpe(char *pathname, char *argv[], char *envp[]); 4 u6 S$ d) @5 w
程序例: </P>
- ?2 J" E3 B# g, X. [* \( @<P><FONT color=#0000ff>/* execv example */
3 V( P I+ F, _6 |#include <PROCESS.H> q0 P, d9 \4 K( q
#include <STDIO.H>* T5 V2 B3 [+ f g. x: Y' T
#include <ERRNO.H></FONT></P>
: ]2 {4 h& }: s* t, S# m<P><FONT color=#0000ff>void main(int argc, char *argv[]) 3 c( J( |7 T" q6 ^9 b: p9 L
{
0 r, G. R7 B( C6 u, kint i; </FONT></P>
1 c7 G" K j8 t* R4 N<P><FONT color=#0000ff>printf("Command line arguments:\n"); ( V- f( j) {+ T/ ? e
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P> q* g1 c7 G G- C! T
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); 7 a! L7 U# r; b& u: h
execv("CHILD.EXE", argv); </FONT></P>% x* z" e) X' t6 f6 e( |
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>2 P! S6 t( A, V8 C1 _+ s1 W9 l
<P><FONT color=#0000ff>exit(1);
5 Y N) d9 _6 ~" G: p6 \} # x1 q' K* ^, O9 T+ x0 i
</FONT>
3 C3 L A/ a/ u# C3 j</P>4 M# s; C7 }; _! u7 a: }
<P><FONT color=#ff0000>函数名: exit </FONT>* `* d2 S1 D2 m: j3 B& h
功 能: 终止程序 ; }5 x# U1 w8 F" X/ c# D3 |
用 法: void exit(int status); , P+ A5 G/ Y& G, q0 p2 l! ], p2 ]+ r0 S
程序例: </P>
0 u/ H5 u2 n( x3 \9 \, r+ e% o4 L<P><FONT color=#0000ff>#include <STDLIB.H>& ~9 V/ r& ^* N4 F( U- J/ [
#include <CONIO.H>
' v0 q4 b' p- _; v# C5 g#include <STDIO.H></FONT></P>
% ~' Q+ A+ a Q1 t" H<P><FONT color=#0000ff>int main(void)
; k5 W+ B- r" {# F* S* ~9 T: h, F0 E{
) M& K5 f) _" x% l8 }4 r- qint status; </FONT></P>
# X) ]/ F, W7 j& ?) d<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
" x3 R$ z! t2 { Y& `6 g( pstatus = getch(); 3 h& }; z* L9 v0 S0 c% N q
/* Sets DOS errorlevel */
L5 C; z2 c2 J& _$ fexit(status - '0'); </FONT></P>
: G% X% c4 z+ |9 [; \) Q% R* @. h" U<P><FONT color=#0000ff>/* Note: this line is never reached */
( r* W, f! i) N) R6 i9 J. ^return 0;
( U( {; e4 ~- I R3 O}
# g6 I: f& {$ ^0 w6 b</FONT>, n) E: t: E& t3 w6 Q
</P>
2 j' q. ~7 z% I<P><FONT color=#ff0000>函数名: exp </FONT>1 P2 h% Z) B7 T9 D0 G5 `
功 能: 指数函数 % L/ i2 E. u4 i) R$ v. R
用 法: double exp(double x); ; M# |4 d% ]2 b% P! K0 T, k! d
程序例: </P>
j, e) f% _ e0 c& r<P><FONT color=#0000ff>#include <STDIO.H>* l$ R. E; }" E7 d. D* `4 m
#include <MATH.H></FONT></P>
$ n) O& c5 y2 P* d$ G" u! I6 m<P><FONT color=#0000ff>int main(void) & Z, }% m2 |' h0 q( M
{ & u+ G2 C$ f; y" z1 b
double result;
2 m1 D# D W4 z: E7 Ndouble x = 4.0; </FONT></P>, s% h+ Q, Q/ ]/ a2 Z" V
<P><FONT color=#0000ff>result = exp(x);
, Z& f" i# ~& ]* z+ _9 }printf("'e' raised to the power \ * p" d' I% ~3 }* i+ a& E! ~3 F
of %lf (e ^ %lf) = %lf\n",
$ }1 K3 E! c! t5 f7 gx, x, result); </FONT></P>6 H8 z# y" v( ?
<P><FONT color=#0000ff>return 0;
+ r/ f7 @2 I, d( R t7 B3 X( G4 ] Y1 w, d& a}
7 T2 z) k8 F6 L4 @/ k, h</FONT></P> |
zan
|