- 在线时间
- 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>
7 v* [! m) x! S& b0 k</P>5 I8 A, f& P& I1 o# F4 {7 T
6 t5 _. L" a# Z; E- R/ b/ Y: [3 \
2 O% A2 O- c! [2 Y7 M
< ><FONT color=#ff0000>函数名: ecvt </FONT>
- M: T1 I) s% }' m y6 ]; z; d功 能: 把一个浮点数转换为字符串
1 \0 }7 j# c" t0 L8 G. s, J用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
% {6 h ~- V+ R0 m- J# A2 |, \9 y程序例: </P>- Z/ U L+ O) O- F3 J
< ><FONT color=#0000ff>#include <STDLIB.H>
I# a, Y. [7 h4 G' D#include <STDIO.H>; w& o4 b* E! R) ?' _, D
#include <CONIO.H></FONT></P>3 y& E7 |+ ]: U) G4 |
< ><FONT color=#0000ff>int main(void) ( g% I$ H! z: q, } {/ z. H
{ 0 U1 \. R3 G1 Z0 s! k5 r7 i4 |
char *string;
( \( O9 _) y8 v2 N3 z0 t5 w6 i/ Ddouble value;
) c; D- S* ~$ t* y# l/ ~; V+ hint dec, sign;
7 l1 b8 C! d# U5 P# g' [int ndig = 10; </FONT></P>. d# c- ?. r: d1 a1 T4 Z& {9 t
< ><FONT color=#0000ff>clrscr(); , V1 R6 F% A E) W
value = 9.876; / ^6 h5 W3 m9 ~, J; n
string = ecvt(value, ndig, &dec, &sign); & r8 {6 }: g9 {1 ~
printf("string = %s dec = %d \
) `$ e% u& I) F( \0 @7 U* bsign = %d\n", string, dec, sign); </FONT></P> y& }: e; W0 V7 z
< ><FONT color=#0000ff>value = -123.45;
: D* l0 S/ W1 e5 f3 T# e$ xndig= 15; ! C" n) U! D2 ~4 G" l# V
string = ecvt(value,ndig,&dec,&sign); , A# ?) v8 {1 |7 }! a) M3 t& [" c
printf("string = %s dec = %d sign = %d\n",
8 M3 p+ {' k, V) Kstring, dec, sign);
X: ~* z/ S, K</FONT></P>) T$ T, \& L( q( p% F( i
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
. J T( Y' i$ M0 |7 d, \notation */ ( t( X! B+ A8 m2 T. ^6 x
ndig = 5;
6 s9 U- j/ W3 d+ Z: y% A( ^string = ecvt(value,ndig,&dec,&sign);
8 {0 V! ]; g+ u& A) N; Qprintf("string = %s dec = %d\
2 a; z/ d2 y# Z asign = %d\n", string, dec, sign); </FONT></P>/ M5 r5 x( j- a3 R. q6 \% K
< ><FONT color=#0000ff>return 0; 6 Y6 X9 Z4 u2 X1 F
} </FONT>% f% O5 t/ w2 z" ^$ L* Q& `
' |. W8 ?3 g; {/ t
</P>
' y. ?- I) r% n# o8 M5 s< ><FONT color=#ff0000>函数名: ellipse </FONT>
" T( b/ x# I/ X$ y" S0 K功 能: 画一椭圆 / k0 I, l0 u# _7 T1 w+ ?
用 法: void far ellipse(int x, int y, int stangle, int endangle, * M+ H/ ~8 \/ g1 O
int xradius, int yradius); # T( u6 X) X4 X4 E
程序例: </P>
" C- S1 H7 L- V& ~" }2 Y< ><FONT color=#0000ff>#include <GRAPHICS.H> P) Y6 h3 X4 I0 K9 n+ W
#include <STDLIB.H>
! K! J) n: e8 g1 q( N6 d#include <STDIO.H># V2 j3 m9 v" h
#include <CONIO.H></FONT></P>- ?$ B; s! d4 ?
< ><FONT color=#0000ff>int main(void) ; N' w# y& Y7 `: S) ?
{
, N) \5 H& W# a4 ] z0 F2 t' i/* request auto detection */ * ~( O! G6 @' E5 a
int gdriver = DETECT, gmode, errorcode;
$ I# @2 b8 A5 _1 z) C' Kint midx, midy; 0 C6 X/ n) \9 ~5 S- a- E
int stangle = 0, endangle = 360; " q: I( k$ ~+ B' X3 g" V
int xradius = 100, yradius = 50; </FONT></P>7 f6 j) d; r) n$ @) f
< ><FONT color=#0000ff>/* initialize graphics, local variables */
6 Q9 g% q# k& O Z! G' J* x( Uinitgraph(&gdriver, &gmode, ""); </FONT></P>
5 G: p; i/ }" W: [; B' u1 m< ><FONT color=#0000ff>/* read result of initialization */ 6 Y. x5 c: @( k
errorcode = graphresult(); 0 z8 S. Y* i! c- v! {
if (errorcode != grOk) $ J# @: [- Q* R" g
/* an error occurred */ 8 |- N2 L* Z& h
{ 0 i- E4 f' V' K
printf("Graphics error: %s\n", 6 q/ V$ W% P: s2 c) p
grapherrormsg(errorcode));
2 q" X% h- Z" n7 r6 g& }printf(" ress any key to halt:"); 8 u2 L9 s7 |" }0 j+ g+ d, R
getch(); - ?# C6 L7 F& g5 T! k& [8 h
exit(1);
& S! g# _; R2 a8 U9 z1 f/* terminate with an error code */
: L; Y6 o) _1 N} </FONT></P>
& A2 q9 I0 {; i) m< ><FONT color=#0000ff>midx = getmaxx() / 2;
! _* M$ ]6 b. H$ Z# pmidy = getmaxy() / 2; 6 A1 ]. `! ^- E; }/ T8 ?# l5 P% b- Z
setcolor(getmaxcolor()); </FONT></P>
* n/ w% J$ d4 B! [/ i5 ~5 n< ><FONT color=#0000ff>/* draw ellipse */ - b' u6 J! F* F$ c# f
ellipse(midx, midy, stangle, endangle, ! V" b( A2 M5 v# o1 c% a
xradius, yradius); </FONT></P>6 q) f3 W+ n5 g( Q8 R! B8 M4 O
< ><FONT color=#0000ff>/* clean up */ 4 m, K( M `6 r- S; I( S
getch(); 4 J1 R: j, a; Y8 N
closegraph(); 2 b; i- a) c& `, @* |$ T7 R' b+ ~
return 0; ) f, j# V1 `6 w% x$ A$ F$ v
} </FONT>
1 t N9 I5 @4 ?+ e0 u
4 }: Y1 p' V' U0 n5 B4 e</P>
" _0 L7 ]: Z; c5 `5 ^, x" @7 I1 S< ><FONT color=#ff0000>函数名: enable </FONT>
, p/ B7 y4 ?/ @1 k4 {( K功 能: 开放硬件中断
8 k7 A5 g' z" [, u用 法: void enable(void);
' ]7 c7 o; x+ u# h6 k程序例: </P>
3 f1 b8 _7 T. C% f4 X' M< ><FONT color=#0000ff>/* ** NOTE: % P! B8 _5 W& R% o, @
This is an interrupt service routine. You can NOT compile this program ?) M8 _6 L' {( t
with Test Stack Overflow turned on and get an executable file which will
: T$ ?9 r) ]2 ?) x! |operate correctly.
/ a) \ o+ H% w9 k0 _$ ~*/ </FONT></P>( T/ ^9 c3 H, a1 S) M
< ><FONT color=#0000ff>#include <STDIO.H>
8 C. i- G: j5 k#include <DOS.H>6 \; x- ?, S) b- L& ]
#include <CONIO.H></FONT></P> _, O2 F9 K; l3 h- H* ?/ {4 x
< ><FONT color=#0000ff>/* The clock tick interrupt */
7 F6 [, k* V8 \& N: P#define INTR 0X1C </FONT></P>1 Z. V0 Q5 A& {! |, f
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>9 s- N1 y2 I6 Y0 A
< ><FONT color=#0000ff>int count=0; </FONT></P>7 e j4 j5 C+ ]3 Z" w' D- f5 X
< ><FONT color=#0000ff>void interrupt handler(void)
! G3 d/ l9 m9 l1 o( s{
z7 Y0 F& E3 {: O% \/*
) I; m2 _# P; ]5 _/ D& Edisable interrupts during the handling of the interrupt 8 U8 }' X0 l5 S# _! v, B* Z
*/ " D$ f/ V% G" `# r
disable(); ; ~/ M6 A- D9 R3 ~2 y0 W7 Q5 S' a
/* increase the global counter */ & e: S9 |, Z, }' U: ]# N3 o
count++;
9 |/ D4 b9 }8 j6 s3 D+ _* r/* ; H4 V3 w# U0 |6 X8 U3 U
re enable interrupts at the end of the handler
3 m# r' Z+ {+ Q*/ & M+ h$ \) i" m M
enable();
$ Y$ v8 O# d% X! R/* call the old routine */
* [. s# Y5 ~! V, u! q8 woldhandler(); : T: H$ ]# [; E. ]6 y3 L& P4 x
} </FONT></P>- ]0 d& I+ E% n* G0 @
< ><FONT color=#0000ff>int main(void)
! S6 ]; C% Z& @4 P1 }{
6 Q! ]/ q0 X. E& C0 W6 c/* save the old interrupt vector */ ' f. }6 T3 m! ]; b; t
oldhandler = getvect(INTR); </FONT></P>
' X( g1 a' `3 ~" A& W< ><FONT color=#0000ff>/* install the new interrupt handler */
# x, l+ P$ k6 \3 rsetvect(INTR, handler); </FONT></P># c/ e6 ~% l+ }( O
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
3 ^# m4 s( T8 B. q/ gwhile (count < 20)
7 s1 e) G% b) {0 j& c. rprintf("count is %d\n",count); </FONT></P>
9 j0 r( i$ M) Z5 f) N< ><FONT color=#0000ff>/* reset the old interrupt handler */ + h" f9 @1 v6 X$ j1 D" L
setvect(INTR, oldhandler); </FONT></P>5 |6 ~7 g3 ~# ]) t4 q! H
< ><FONT color=#0000ff>return 0;
0 o: B8 k4 `/ q/ | d} </FONT>) Y7 X8 f3 T( ~+ `; R* S
8 [* g( M. m. k; n) i t F% K5 Q1 i
</P>0 b2 d1 G# {% Z/ R# r
< ><FONT color=#ff0000>函数名: eof </FONT>2 q- Z$ F% ?/ o- \
功 能: 检测文件结束
) b- {: I' W7 K* ]& V用 法: int eof(int *handle); 2 H9 B- O# n+ r
程序例: </P>
m+ H8 \% A2 |2 W ~<P><FONT color=#0000ff>#include <SYS\STAT.H>" \" e1 R- N' k) H% } d! d
#include <STRING.H>5 U2 N/ W! K- ]9 h
#include <STDIO.H>
5 }8 b; l% O+ |. h#include <FCNTL.H>
2 Z1 u9 D1 w% ^0 W#include <IO.H></FONT></P>
' N7 W, D4 E# ?: }<P><FONT color=#0000ff>int main(void)
7 C2 F4 M1 Y: W) B& X; j{
( `+ C6 |6 r; i5 l+ _. H# Lint handle;
8 ~6 W$ U" d$ D& G8 Q0 p. Bchar msg[] = "This is a test"; : N7 B" V& u$ f+ G9 ~+ h" e4 C1 ~
char ch; </FONT></P>
( ?, m: i$ g% J) j6 w1 E* [- K) w# T<P><FONT color=#0000ff>/* create a file */ * Z: y& L9 C& g' V" D
handle = open("DUMMY.FIL", / J5 D' u$ S: b1 a5 Y8 a: a, o
O_CREAT | O_RDWR,
_7 T- B* `; M/ j% D- S( C. U, [S_IREAD | S_IWRITE); </FONT></P>+ d% F& l0 h& z4 K& j" X; d! `) z B
<P><FONT color=#0000ff>/* write some data to the file */
) f, h! B& G6 A0 k" A v- m |% u) p9 mwrite(handle, msg, strlen(msg)); </FONT></P>
- ]7 I; x( E7 j" O* b<P><FONT color=#0000ff>/* seek to the beginning of the file */
0 Z8 v/ q; y) X- |( [# b2 ^, [lseek(handle, 0L, SEEK_SET); </FONT></P>9 m" A) Q& u" @4 \& @/ l9 X& X' S
<P><FONT color=#0000ff>/*
: ?* G/ A# _9 vreads chars from the file until hit EOF ' M. S( H$ e& W8 ~: @% H. @& m# h
*/
& N+ x3 h) n' y( [9 _. T( g7 ?do + p9 I+ E3 q) W# _' k
{
4 E5 Y( s& r( Z+ j' [/ e Dread(handle, &ch, 1);
8 D( I7 m# w+ zprintf("%c", ch);
- r8 v' D% e0 \7 M* _0 q! r} while (!eof(handle)); </FONT></P>0 d- x2 A0 b" p2 b4 N2 j
<P><FONT color=#0000ff>close(handle); ! p* E4 v% E& I4 O* y, m9 V6 R% Y
return 0; - F h0 t, d+ W9 I2 A
} ! E1 H$ q F# z$ ]$ V4 @
</FONT>1 |/ @+ d+ b8 s. }# O' T+ s u: A
</P>
; e0 N s) |2 d' N/ P/ K" n4 j<P><FONT color=#ff0000>函数名: exec... </FONT>
8 u# O6 j( ]: b' ~ l& m功 能: 装入并运行其它程序的函数
( l( W% N g5 V8 ]用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); . R- V" d' o3 {" [. ^% _ r1 s
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
8 s# n5 W- S' P( t* Z& uchar *envp[]); 3 o- w2 N" n9 c D! L& v0 x9 R
int execlp(char *pathname, char *arg0, arg1, .., NULL);
: b* x8 v2 W% J; m1 }2 a$ i4 {int execple(char *pathname, char *arg0, arg1, ..., NULL, 5 R* Z3 A% n4 O) P
char *envp[]); 6 ?) K, h$ |5 H! {2 i
int execv(char *pathname, char *argv[]); 8 ]4 K% v% N" ]
int execve(char *pathname, char *argv[], char *envp[]);
9 R% I, K, A9 O4 q( `3 O. I2 L# L$ Hint execvp(char *pathname, char *argv[]);
) {6 ]0 m( y3 I2 ]7 o7 {8 ^3 ?int execvpe(char *pathname, char *argv[], char *envp[]);
& s5 A+ k% N6 K4 T$ t程序例: </P>
9 R D7 B8 w. o2 F<P><FONT color=#0000ff>/* execv example */ * I, ]7 v% v7 m3 w# \+ B
#include <PROCESS.H>
5 L$ y, T1 @( [8 t$ t#include <STDIO.H>
! X* y9 Q0 @$ v) P, J#include <ERRNO.H></FONT></P>2 |( b! y% R4 s! B: T# @) j, [* C
<P><FONT color=#0000ff>void main(int argc, char *argv[])
: w1 n7 P! d# R$ w+ {. P: H4 C1 \{ * o- r6 h; h- G1 i5 U2 g0 h
int i; </FONT></P>
9 A3 c- i$ P: K" t8 z1 a<P><FONT color=#0000ff>printf("Command line arguments:\n");
$ ?' B9 ], ]+ P5 t y5 Hfor (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>% j% ?1 M" Z+ l# Y8 m
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); ; ] A1 q0 u* M- l9 `# g# @+ U6 A6 S
execv("CHILD.EXE", argv); </FONT></P> n8 r7 q+ I6 x3 W1 o! P: }, f
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>0 X$ }4 W) F2 K1 ]
<P><FONT color=#0000ff>exit(1); . P: }- n* Z" w9 d S
}
3 z/ [1 o% X) H# V1 K</FONT>
2 l4 E" F ~7 Y- A! ~5 e0 q$ h- v</P>& t/ L/ W y2 z4 o
<P><FONT color=#ff0000>函数名: exit </FONT>0 c& ?: |! H. Q9 ]% F. t5 q
功 能: 终止程序
# L2 H2 ^1 U, _* O1 W5 U用 法: void exit(int status); 8 S. Q* r" }# t; E$ J
程序例: </P>5 q3 d( m5 {: D3 t! i5 v
<P><FONT color=#0000ff>#include <STDLIB.H>5 f5 a. s' }# e$ {
#include <CONIO.H>
% J4 [1 k: ~* }8 m& ?( s3 l# j7 z#include <STDIO.H></FONT></P>
# A: S: p$ H9 P6 A) p- L4 P+ v<P><FONT color=#0000ff>int main(void) - E" o* s, f8 H% F3 v: t0 i5 Z
{
' J1 f( U7 J) @& K9 v5 Qint status; </FONT></P>: K$ c$ |+ J- G$ u
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
! S/ }4 t& v% w1 |status = getch();
! f: A$ R1 @8 T" @- x5 _/* Sets DOS errorlevel */
+ J, ?# U# L- V1 m# ?exit(status - '0'); </FONT></P>
7 ^: }/ ?# p' L<P><FONT color=#0000ff>/* Note: this line is never reached */
( i& I0 C6 M# S+ Y9 }# areturn 0;
7 }- i. M5 m( k! Z} 2 k: y3 r& k# Z+ G& G% Z) `" R1 m
</FONT>
' n- T/ a( f& f: b</P>
! K, c u5 u- D0 S<P><FONT color=#ff0000>函数名: exp </FONT>( n5 @' t: r/ H1 a
功 能: 指数函数
& G: B7 Z7 O! ^' s9 r7 ~/ b- R用 法: double exp(double x); 3 m) r- ^& x5 A* S L
程序例: </P>
; o, G% v1 a( V" J( {<P><FONT color=#0000ff>#include <STDIO.H>
. O8 ?0 j) m/ @5 [: u( v1 r#include <MATH.H></FONT></P>
6 [8 a/ O, o# G) S- z- M<P><FONT color=#0000ff>int main(void)
; w& H. N5 k# o, b7 {) C0 ]{
! o0 p. _' F; p2 f; k adouble result; 6 n' r9 W- m" i. q
double x = 4.0; </FONT></P>
+ I3 h% l3 y" w" y; @# O<P><FONT color=#0000ff>result = exp(x);
8 D* Q/ [/ x5 W% |printf("'e' raised to the power \ 8 u3 l+ f% z. V! R
of %lf (e ^ %lf) = %lf\n",
+ z; S* x" }. \/ Q) F/ X \* Ax, x, result); </FONT></P>
8 o$ l- `, D" _9 b$ |<P><FONT color=#0000ff>return 0; a1 m% ]$ ?0 q0 z# y6 B
}
/ A9 q, D+ G- _- B& O" g</FONT></P> |
zan
|