- 在线时间
- 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>; a. v q* P, B( {2 |1 f
</P>
) Q" Q' h. `; H7 V4 E3 V$ e5 f6 J) ~; m4 H+ W
% N5 K- |0 f" j a( \
< ><FONT color=#ff0000>函数名: ecvt </FONT>4 o o% o- I2 N) N3 u
功 能: 把一个浮点数转换为字符串
d8 V Y/ X* Y" {; ]$ ^# V6 O用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
/ g g, M4 l' w5 r. N# E. s+ `0 [ `程序例: </P>
. \2 |: j' J7 {4 Z; g: _/ V< ><FONT color=#0000ff>#include <STDLIB.H>
, P7 @( W( P5 T5 T: D#include <STDIO.H>- Y! i5 {9 I/ Q1 V7 ], ~
#include <CONIO.H></FONT></P>" @- _4 s" }; o, n. ^
< ><FONT color=#0000ff>int main(void) ) H* U( U% q. J; G
{ # ]2 G" Q3 J7 E) q1 A ]5 E
char *string; 5 b) r/ P# c, l5 I' v0 j
double value;
! g. x. W, X" ?* v, i5 i1 Q: Vint dec, sign; ( ?4 r& Y: ]' W& X( j; Y
int ndig = 10; </FONT></P># V; S4 {; y% I0 X# v0 i6 \9 |% z' G
< ><FONT color=#0000ff>clrscr();
# }( }) b8 v( N8 E, A* ^* W! C6 fvalue = 9.876; / o1 _( T4 K0 A9 r1 _7 s( e! J
string = ecvt(value, ndig, &dec, &sign);
# \, f3 i0 x) G) z) w6 k9 q. ~1 ^, Uprintf("string = %s dec = %d \
0 G, o$ {7 E$ n8 Fsign = %d\n", string, dec, sign); </FONT></P>
! b& i) d' ]1 f2 E# {4 m< ><FONT color=#0000ff>value = -123.45; 2 x; I1 v# @+ P Y6 [
ndig= 15; {9 N% L! D# T
string = ecvt(value,ndig,&dec,&sign);
5 i! U, { j$ m# d+ jprintf("string = %s dec = %d sign = %d\n",
: `. v( m) b) B5 ystring, dec, sign);
8 T! m @1 m2 U6 \ U6 ~</FONT></P>0 P7 d2 | Z+ V
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
7 X* @+ G0 }* g. e9 Mnotation */ f: ]2 T1 @7 P+ o$ a* }
ndig = 5; % }4 n5 S" o8 s0 Q+ ~; D8 M# q
string = ecvt(value,ndig,&dec,&sign); - o `2 b- S" v/ }& w& T' x: S! ?
printf("string = %s dec = %d\
) D) q" D0 S2 Z: d# _% @sign = %d\n", string, dec, sign); </FONT></P>; b+ Y4 @5 O. i! I* f5 _7 n" S( N
< ><FONT color=#0000ff>return 0; 3 J3 o- M# K8 u4 p9 w( C
} </FONT>. F! E2 |5 G& j
: U6 a; V0 q& e: l</P>2 p7 O8 O- `2 o
< ><FONT color=#ff0000>函数名: ellipse </FONT>
9 T& F" z! k" k& ]6 G' F# s功 能: 画一椭圆 - n* M1 f5 [/ R! F4 x; {# D
用 法: void far ellipse(int x, int y, int stangle, int endangle,
' B1 C0 d9 e8 G+ I! d1 C q( J+ _! `int xradius, int yradius); 9 C" W, p& G( e( Y3 y
程序例: </P>
' u4 ?. ^. v. a- F< ><FONT color=#0000ff>#include <GRAPHICS.H># C: g1 C" J; m" H; k
#include <STDLIB.H>
/ D+ y. ]8 a# r# r; B/ U#include <STDIO.H>/ I8 i+ \) I8 K+ m( d& }
#include <CONIO.H></FONT></P>
7 ~0 C( M$ o5 u' E< ><FONT color=#0000ff>int main(void) + y3 ~0 x8 r- y2 h
{
@- j- P% k4 d* i/ X/ b3 S$ s* ]/* request auto detection */ 8 p4 F, _, L8 z9 L3 j
int gdriver = DETECT, gmode, errorcode; ! W/ }" l9 R3 O
int midx, midy;
! L. @# O% h' T1 ~; Eint stangle = 0, endangle = 360;
& a! k0 f% P: W% e$ s2 dint xradius = 100, yradius = 50; </FONT></P>0 z" u) f# J1 \; t
< ><FONT color=#0000ff>/* initialize graphics, local variables */
/ `# H0 w3 O% b: G6 Z4 c( Uinitgraph(&gdriver, &gmode, ""); </FONT></P>, C, H6 B T. v( i
< ><FONT color=#0000ff>/* read result of initialization */
8 Y) \# |$ M' T8 R7 derrorcode = graphresult(); 7 u" R& `( e) e& x5 q$ i2 o5 P! h
if (errorcode != grOk) 6 r+ F5 N( K) Q6 b; b# K; B1 } f. g. F
/* an error occurred */ : T$ D2 p4 b& ?
{ & }& q% `8 O% [
printf("Graphics error: %s\n",
5 {+ Z( b3 j7 L, i9 O) A4 g9 zgrapherrormsg(errorcode));
, I- }# ]4 G5 m. lprintf(" ress any key to halt:"); 4 J/ K1 R. g5 i8 f( K
getch(); 3 ^- U/ j7 R) w- `7 B' U; I4 X
exit(1); 2 B! k6 r$ M4 r/ f/ L
/* terminate with an error code */ & ^9 s5 o: A$ R9 o
} </FONT></P>
& x1 s- j4 {# S3 [* S8 D< ><FONT color=#0000ff>midx = getmaxx() / 2; & ~& p' x4 p2 p6 l$ s: M7 |
midy = getmaxy() / 2; # k5 m m% }# ?2 H. F! [6 z* w
setcolor(getmaxcolor()); </FONT></P>7 d1 X. Q& _: {* d& I
< ><FONT color=#0000ff>/* draw ellipse */ " h0 E Z8 q+ H) V( k( a
ellipse(midx, midy, stangle, endangle, - e0 ]$ c: y7 M% H6 C( C
xradius, yradius); </FONT></P>6 T7 [/ [6 _; y4 R3 R* r
< ><FONT color=#0000ff>/* clean up */
3 ^4 x0 f+ ], G5 e7 V$ k. e1 c' Kgetch(); $ a9 J- g j8 P4 w# I& r! }, N
closegraph();
: F2 h4 V" x' x! Hreturn 0;
! q% Z1 H& W# P} </FONT>3 c4 d+ r0 `8 N, C2 J
: S( E9 t, w& I$ N/ C8 g</P>% [5 K: z6 j$ N1 ]
< ><FONT color=#ff0000>函数名: enable </FONT>
1 \9 M8 l8 A1 U2 _' g- N功 能: 开放硬件中断
7 w9 k% A5 [2 |* O3 O, I+ W用 法: void enable(void); . c+ R8 h. H! M. ?3 t/ W
程序例: </P>
" c1 ?( U) ?8 ^$ Q< ><FONT color=#0000ff>/* ** NOTE: L) Y8 i7 g$ f7 y3 E8 K
This is an interrupt service routine. You can NOT compile this program
[1 L% D1 U. }+ y: qwith Test Stack Overflow turned on and get an executable file which will
: Y5 \$ G) |. c' ^+ c' `0 boperate correctly.
8 H. v4 `4 ^& E*/ </FONT></P>
- V; I, j P1 A4 ~8 d8 z) c0 U& S< ><FONT color=#0000ff>#include <STDIO.H>' G+ h) q; i' p
#include <DOS.H>: i9 P' n% ]' s, Q8 M: ?/ m
#include <CONIO.H></FONT></P>
3 M/ K) J3 v' M' Q1 C+ t& H5 c< ><FONT color=#0000ff>/* The clock tick interrupt */ 4 L; ^3 n# } X# R, P
#define INTR 0X1C </FONT></P>
. O1 I' ? a. ]7 \< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>$ i& I# ]: o/ c0 ?: {8 c
< ><FONT color=#0000ff>int count=0; </FONT></P>
& D& N6 C, N' Y) }& B. L# j i< ><FONT color=#0000ff>void interrupt handler(void) ( e# i6 z) `& T0 c
{ % Q6 C# w: e/ L% j5 J
/* 5 s: U4 ^" T1 r& O; U+ V
disable interrupts during the handling of the interrupt
9 h3 [0 G, R! _! h*/
' k; \6 F4 P3 X$ v+ P4 [disable(); * h* n; v" w% K( h; I
/* increase the global counter */
7 r o; f% E+ `5 _( E4 J- pcount++;
]6 }- W% _/ {7 y' l/* - G4 i' ~' M5 b8 ^6 E2 `' _
re enable interrupts at the end of the handler
2 \& G- X& \6 U( h+ O B*/ 2 H. K4 }8 ^3 v8 y: C
enable();
# g4 l2 `( v& ]+ n+ |& |/* call the old routine */
1 T2 w2 [" \6 _: k- @$ doldhandler(); ( c' Q3 u3 Q: J/ D" ~) e* A( s
} </FONT></P>) h9 K' Z. G& l
< ><FONT color=#0000ff>int main(void) 9 Y9 u7 v( I" q3 g7 w1 c
{
$ j% J& g# d. Y* s2 }- ~+ u/* save the old interrupt vector */ 7 h9 e; G, i5 e3 \3 S8 E
oldhandler = getvect(INTR); </FONT></P>% A& q0 Y9 O/ y. s9 q4 c; g
< ><FONT color=#0000ff>/* install the new interrupt handler */ 5 u9 }1 I% S* h6 H% a( d9 O( L
setvect(INTR, handler); </FONT></P>2 R: `, }! O8 y
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
2 n2 o( m3 }! G* @! H/ w; e2 iwhile (count < 20)
7 s3 w9 R6 l& A# Yprintf("count is %d\n",count); </FONT></P>+ h5 W0 c; W" t: B" g
< ><FONT color=#0000ff>/* reset the old interrupt handler */
0 {$ q# ?: u S, {! @setvect(INTR, oldhandler); </FONT></P>
! G4 f4 z% h" p5 i3 ?, o< ><FONT color=#0000ff>return 0; . t% ^/ ^% p' K
} </FONT>
1 Y4 @ ~& m4 i% _
2 `/ L0 K1 V/ m3 g; B4 g$ ~( y2 \</P>2 n" H6 j4 `" E' I: U
< ><FONT color=#ff0000>函数名: eof </FONT># G% P* g1 `5 v
功 能: 检测文件结束 % z3 T# q2 H, X' T1 {
用 法: int eof(int *handle); ( {4 |5 U& B( x
程序例: </P>
- K1 x! v' }: v4 g1 ]( s9 c<P><FONT color=#0000ff>#include <SYS\STAT.H># |% b3 O- Q* \/ \9 h) o
#include <STRING.H>) ]6 D6 A2 |1 N* x; _4 X3 ~
#include <STDIO.H>% i7 r9 h3 G3 G; Q" v
#include <FCNTL.H>
! n+ [" p7 f) N#include <IO.H></FONT></P>% ~( d% c, V4 k7 ~
<P><FONT color=#0000ff>int main(void)
( {( D, d" F' t, p# Q0 A* g0 `{ 1 s) W' @) g4 X
int handle;
/ i( C4 z) }+ Y% @, t/ h3 pchar msg[] = "This is a test"; + C, R( a' K( k! p
char ch; </FONT></P> _: t( x* N# H' A' B9 [' s/ \9 q
<P><FONT color=#0000ff>/* create a file */
! ]! k% g5 v Bhandle = open("DUMMY.FIL",
" D8 B- P3 H) f6 _0 \O_CREAT | O_RDWR,
7 G! e, Z2 d; Z3 d3 ?0 eS_IREAD | S_IWRITE); </FONT></P>
0 w+ D3 G+ `' H; `( ~. k<P><FONT color=#0000ff>/* write some data to the file */ 1 b8 Y) C n! D
write(handle, msg, strlen(msg)); </FONT></P>4 N3 D. c6 U# {* `; B b
<P><FONT color=#0000ff>/* seek to the beginning of the file */
: k: y# W% Y. S) } [! ^1 Jlseek(handle, 0L, SEEK_SET); </FONT></P>0 g: Q6 j6 G; j
<P><FONT color=#0000ff>/* 3 e; M, f9 g2 M, z% R6 q
reads chars from the file until hit EOF
7 A4 R9 q" L- B; X/ o, `*/ . d/ u+ }( A' n% G9 z* R6 o' [
do
0 T9 _0 @. ^. X, L2 f9 W7 N f g{
. [+ N9 R7 j' @" g* B' tread(handle, &ch, 1); # H1 x/ h- ] e5 ~0 B3 G
printf("%c", ch);
4 i" B+ B5 q) t6 h' ~} while (!eof(handle)); </FONT></P>0 V# Q" K+ B' Z+ b4 T9 ~
<P><FONT color=#0000ff>close(handle);
& q$ n( h8 v. I, Y6 Hreturn 0; / ~% y8 _( K4 o% C0 e8 Z. P! [
}
; x* Z: H y. M6 c' W+ j. o) y</FONT>
& ]; I& ] O7 d" J) T7 W</P>
$ T+ Q3 T' ]& N# \<P><FONT color=#ff0000>函数名: exec... </FONT>. G) |5 L4 k9 f, ~
功 能: 装入并运行其它程序的函数 ; Z- k; q! ^& U6 [
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); # X4 |7 v5 C! O* R5 U+ B
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL, 3 M* o; I. o+ ? [: x4 E5 g6 i& b. m i( Y
char *envp[]);
, ]8 f8 Q$ n' ]int execlp(char *pathname, char *arg0, arg1, .., NULL); t+ r. Z; D/ O' e2 N0 v' ^
int execple(char *pathname, char *arg0, arg1, ..., NULL,
$ a4 x. @! w2 M- hchar *envp[]); ! s# ~/ P# ~6 s
int execv(char *pathname, char *argv[]); ! Z/ H& ^' A& J5 B
int execve(char *pathname, char *argv[], char *envp[]); 8 q! Y9 g( s7 i7 n: L' [
int execvp(char *pathname, char *argv[]);
3 R% }- A0 {& T% H& Mint execvpe(char *pathname, char *argv[], char *envp[]); " [2 g( C) j! T/ f, ` k% ]3 q1 _1 D! `
程序例: </P>; L( P8 e9 ^- n; p% h" x7 Q
<P><FONT color=#0000ff>/* execv example */
+ Q2 S8 }5 Y5 G, Q2 f3 L7 a#include <PROCESS.H>8 @6 q& A" P9 D" g) W6 o
#include <STDIO.H>
+ d9 E" V: O9 m" H#include <ERRNO.H></FONT></P> d; c7 {& x# V1 I/ `* D$ G
<P><FONT color=#0000ff>void main(int argc, char *argv[]) ) ^; g9 y) \9 j' ~
{ 0 }, H3 {4 \1 R- ~5 I+ o
int i; </FONT></P>/ c* e7 b% o N: z. ]) P1 \: M
<P><FONT color=#0000ff>printf("Command line arguments:\n"); 3 q) r' T& @. c W: Z, J
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
$ s. a4 f @7 ]' [( F" V# q<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
3 }2 _" l& o7 L' Texecv("CHILD.EXE", argv); </FONT></P>2 S, Q& L7 l1 X2 j
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
% Y9 f i5 {8 b' M& d' r<P><FONT color=#0000ff>exit(1);
4 P( P; o& v P* K T- D} S9 S( }2 ]8 \4 F; x& Y+ a
</FONT>
$ O: O1 t8 j0 q</P>
; q* W Q; g |4 v<P><FONT color=#ff0000>函数名: exit </FONT>& ~0 B! Z2 C2 | J
功 能: 终止程序 3 F; ?1 Z1 M1 `; e! y" t
用 法: void exit(int status);
5 b' s Q- e) d: {+ X Y程序例: </P>
, ^9 a% s6 X: O, O" C1 o4 w4 r<P><FONT color=#0000ff>#include <STDLIB.H>
3 p0 ? ^) v# {& a#include <CONIO.H>- M# q( s+ g' Q7 g2 ^* @6 E" ?+ m
#include <STDIO.H></FONT></P>
% k4 `" l$ G1 z$ W<P><FONT color=#0000ff>int main(void) 9 J! u( S% n; U. K' Z% j
{ ( y) z1 z; x# M5 f9 H
int status; </FONT></P>! u, z# o& L5 X: D$ {' @% p4 ]2 ^
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); % z" Q t' ~9 h- ?- }3 Q2 ]7 h0 ?
status = getch(); ; T0 I4 C) G" s( w- r
/* Sets DOS errorlevel */ ' L4 q1 r/ d8 t. K8 W8 C# H6 ]
exit(status - '0'); </FONT></P>
, m/ h$ E2 O2 ]6 X<P><FONT color=#0000ff>/* Note: this line is never reached */ $ _- j2 a. S: E- p
return 0;
5 s6 Y+ t g4 ?1 E! E( l} ! }9 q0 ], f: m, w
</FONT>
5 y* \; b' i/ G% Q2 k</P>
; n( ~" s& S" ~5 z! p1 N6 r+ D<P><FONT color=#ff0000>函数名: exp </FONT>
8 {4 H6 e9 ^+ G: m& v Q; X功 能: 指数函数
% I8 L! Y5 y! C# a! t* g, O- G用 法: double exp(double x);
# U/ h; u. K8 b6 w" ]& G" m$ \, u程序例: </P>
( v: f# C- q, b5 O2 e6 g: Y<P><FONT color=#0000ff>#include <STDIO.H>
/ k8 \8 p4 }" @6 ]9 N#include <MATH.H></FONT></P>. ^& q: @9 m: E& t
<P><FONT color=#0000ff>int main(void)
: Z$ |" g& k m' K/ X$ o{ + g7 N/ o- ]7 |# k
double result;
3 y5 e; x5 n* w" w) D; ydouble x = 4.0; </FONT></P>" _+ W9 T/ s) z& C5 m. O5 r
<P><FONT color=#0000ff>result = exp(x);
, B" l8 N5 S y0 ?4 t- q. `, K0 Aprintf("'e' raised to the power \ 2 f6 k; c/ \$ e( F
of %lf (e ^ %lf) = %lf\n", 0 n2 g/ K- E Z- ~4 h& k7 Y$ }% `8 c% h
x, x, result); </FONT></P>
3 P) [6 a3 O: k+ Y3 v<P><FONT color=#0000ff>return 0; 3 f0 [1 U+ M' g- r5 x- P% s
}$ \+ W9 `( h. M0 |) \
</FONT></P> |
zan
|