- 在线时间
- 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>* B+ Y F; h$ V' i& {; T
</P>4 B+ `. s" U4 f" @* v7 \
, R# _# o( p, s; n
8 E1 B8 H0 F7 k6 b I! i H4 F< ><FONT color=#ff0000>函数名: ecvt </FONT>
8 B) w& A6 Q+ U* ^: G" E9 @功 能: 把一个浮点数转换为字符串 ! F+ u% r0 X7 ~5 H2 N5 G
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
, z" m1 n# y! O8 N' B程序例: </P>1 z! B: c9 ~2 ~3 R' l5 Y/ Y
< ><FONT color=#0000ff>#include <STDLIB.H>0 v8 _4 X# }* r l) u8 c+ \; e
#include <STDIO.H>
4 y) d& l( V$ _4 c#include <CONIO.H></FONT></P>0 _. o* w, Z" a1 N' o6 H9 U
< ><FONT color=#0000ff>int main(void) 5 f0 z7 `! w1 [3 l
{ - ^1 H' @4 m& n9 `4 A
char *string; ! }5 P6 I# v; N6 }$ P- h- M
double value;
( ^& G: A+ x% F% q/ J2 j) qint dec, sign;
, v3 E2 z! m0 rint ndig = 10; </FONT></P>5 s6 V2 | T0 |0 X9 m4 \
< ><FONT color=#0000ff>clrscr(); - ~" e$ h1 ~! e1 Q3 V* ?4 ~
value = 9.876; . M/ d+ C% K( M' f- a; @( K
string = ecvt(value, ndig, &dec, &sign); % Y H' u1 U! |8 s0 C/ C7 ^
printf("string = %s dec = %d \
4 ?3 f& E5 f# s& z3 e/ nsign = %d\n", string, dec, sign); </FONT></P>
+ ?3 V+ w5 t/ A9 A' i4 v< ><FONT color=#0000ff>value = -123.45;
9 y) z9 [6 a3 _ndig= 15;
. S$ [( G3 H) f; ~5 A( }string = ecvt(value,ndig,&dec,&sign);
' _! a: |( u, ]" W9 y2 _$ P; @printf("string = %s dec = %d sign = %d\n", & h% C- i' K( w1 p" o) x& X
string, dec, sign); * c2 R4 M+ }* E$ F- V! J$ f* c
</FONT></P>
3 ~ T$ z/ G& s. Q/ ?! L8 T! P< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
% \$ ~- @$ H7 y! lnotation */ ' g# w0 ?9 E5 |4 {3 Y
ndig = 5;
$ K8 T8 G8 P9 @4 Ystring = ecvt(value,ndig,&dec,&sign);
& C5 [% w$ s1 O! s9 u* W& @printf("string = %s dec = %d\ , d9 |. x: F3 `' e+ J
sign = %d\n", string, dec, sign); </FONT></P>
; T( o, |# ?1 E! M< ><FONT color=#0000ff>return 0; ) w* c) D+ J* L- e; h
} </FONT>
1 m+ q S, J) | o7 F3 L" ` P% g/ S" v! c) \
</P>: ?2 Z; h7 y2 O6 y9 |1 g
< ><FONT color=#ff0000>函数名: ellipse </FONT>% y5 m' q+ H+ p+ m* G3 o, Y
功 能: 画一椭圆
3 Z7 L/ d7 i% A3 V用 法: void far ellipse(int x, int y, int stangle, int endangle,
2 e3 K7 W' @) j+ K/ @0 Fint xradius, int yradius); , K4 t- A7 o4 s
程序例: </P>; h0 f. \8 H/ [/ T9 o
< ><FONT color=#0000ff>#include <GRAPHICS.H>
4 `8 _6 E4 u9 h9 I. ^8 W#include <STDLIB.H>
9 H6 R# w9 ?( }/ p" m& ~ ^#include <STDIO.H>$ H/ a% D' y: d! M* D; l
#include <CONIO.H></FONT></P>
& B! X; T- N) z! A7 L6 g# c; E1 Z< ><FONT color=#0000ff>int main(void) 6 p' x( Q9 c, E9 Z8 D7 Z
{
; U4 g; o5 X6 H7 V, l! L/* request auto detection */
" t; m& p' M( W3 b& o- Sint gdriver = DETECT, gmode, errorcode;
, Q; t) Q' E3 L1 qint midx, midy;
2 z5 i, R' y8 x$ p( @int stangle = 0, endangle = 360; ( D3 V" Y' W1 `$ u& Q! ~
int xradius = 100, yradius = 50; </FONT></P>
+ ?& Q" j6 Q) L: [< ><FONT color=#0000ff>/* initialize graphics, local variables */ 7 a; t8 H2 p1 a y/ N* V1 x% i
initgraph(&gdriver, &gmode, ""); </FONT></P>
8 b* W) _; @) ]8 w3 T% k< ><FONT color=#0000ff>/* read result of initialization */
7 G! R' L9 g% `2 D9 ?. Serrorcode = graphresult();
1 m% P- d( F! G( ^, qif (errorcode != grOk) , r. l$ Y e( Y- B
/* an error occurred */ * _$ g: J3 Y! G* x8 @
{
- [1 T# O' u+ m/ s3 I" |" Tprintf("Graphics error: %s\n",
" ?& i4 I& o8 F5 M' e& Ygrapherrormsg(errorcode)); 7 s; A; t: W5 m& \2 C' l/ c
printf(" ress any key to halt:"); & j3 X2 s+ |; B+ @6 y
getch();
/ K+ d1 p' [ u" C: w& }% u/ O$ sexit(1);
$ E5 {- V: m& m3 f/* terminate with an error code */
$ B7 X" Q& v/ W& u: i: D} </FONT></P>: @1 q$ ?' j0 k+ S" ~1 w
< ><FONT color=#0000ff>midx = getmaxx() / 2; $ V& I* l" H4 u
midy = getmaxy() / 2;
5 T$ p: N: U) d8 M1 @setcolor(getmaxcolor()); </FONT></P>
4 U# I$ s6 _' V& ^, a< ><FONT color=#0000ff>/* draw ellipse */
# v5 u" W8 t- Y/ Hellipse(midx, midy, stangle, endangle,
* @3 \- P- C; g) Z/ Pxradius, yradius); </FONT></P>
/ `7 j2 V% L+ Y! D! m< ><FONT color=#0000ff>/* clean up */ % j+ }- _9 _/ W5 u
getch(); 9 [" P! D$ z; V; J: H
closegraph();
% \7 C9 y# l' C" p. [5 \1 n$ z# Mreturn 0;
# S2 c: w G) }7 } I6 a} </FONT>
, S$ M( V! y* I# I/ ^3 H4 P: d2 w7 r6 m" U
</P> w* L8 z4 c# L a* Z; L
< ><FONT color=#ff0000>函数名: enable </FONT>
* f7 V* f4 O" u. T6 H功 能: 开放硬件中断 0 C8 Q y4 I3 f* N; B S
用 法: void enable(void);
I( S2 N0 u/ j6 T+ L) ^ T程序例: </P>7 ~9 C( p6 r) j- Y' i8 d
< ><FONT color=#0000ff>/* ** NOTE: , c$ P% T. B; y) ]. e8 o6 _. k1 H
This is an interrupt service routine. You can NOT compile this program
0 g3 t1 c4 Y7 E9 \5 l: Y- r' T7 A1 Pwith Test Stack Overflow turned on and get an executable file which will 9 E" i. r8 u6 h- ~( z) Y9 [' M
operate correctly.
# l$ d% \3 C( q% Q*/ </FONT></P>
2 b$ r3 M0 j* V+ R9 C7 ]( y< ><FONT color=#0000ff>#include <STDIO.H>
; H$ t/ C, H! R#include <DOS.H>7 \ V1 n. \5 P+ Z$ ^6 ?
#include <CONIO.H></FONT></P>
* t# S9 J! b3 b: U< ><FONT color=#0000ff>/* The clock tick interrupt */ # B( e! z% F6 {) z6 W
#define INTR 0X1C </FONT></P>) t+ L* }4 b8 W
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>, \0 m; v. r6 b. C& ~& S2 @. s; ?
< ><FONT color=#0000ff>int count=0; </FONT></P>8 Q' D" C1 x8 ^+ Z3 \
< ><FONT color=#0000ff>void interrupt handler(void)
) z/ h% m9 G; m) S. W8 V{ 6 J# q% P, v8 N! D
/*
' D1 g Y- M7 _- b: ~7 m4 Vdisable interrupts during the handling of the interrupt + D" C0 x3 Y. r+ i
*/
* i& b. t F" n8 @) h( Udisable(); 8 H m7 P& _* K
/* increase the global counter */
& i g0 R) C: m$ Z0 t% |count++;
( e% s1 C- D6 ]) H6 l) Y7 i# |/*
6 |2 g1 ^% o8 S. o- f. {re enable interrupts at the end of the handler
( y* I3 Y6 o& V+ g0 C*/ 6 R# w9 r; k5 y7 P2 a* |% Q
enable();
. g; f- u0 k8 f* D7 b7 M8 l/* call the old routine */ , @1 Y; {6 a, _
oldhandler(); " O Y" L8 h+ N- }7 d% o
} </FONT></P>! I6 Z+ _5 T1 B+ `* k; O( k
< ><FONT color=#0000ff>int main(void)
5 r1 I2 [ l' T! B4 f( Q4 Y{
6 I0 t6 u7 n# _* U h4 w/* save the old interrupt vector */
8 `+ X9 E5 T! joldhandler = getvect(INTR); </FONT></P>7 [6 T: U- d, a7 q
< ><FONT color=#0000ff>/* install the new interrupt handler */ 3 t: n0 G6 b5 i; g! v
setvect(INTR, handler); </FONT></P>% ~9 t# z1 z. {5 i0 r
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
/ p0 Y# ~( v0 V% H1 swhile (count < 20) " u" V p0 A; D4 ]8 E' W! h+ j% d$ g
printf("count is %d\n",count); </FONT></P>8 |2 v2 f/ |- d1 m2 d. L0 d1 G( b
< ><FONT color=#0000ff>/* reset the old interrupt handler */
; K0 B" A0 s& ^( ?/ nsetvect(INTR, oldhandler); </FONT></P>
8 o# E# o- p$ \( c< ><FONT color=#0000ff>return 0; # Q, M3 c. r3 L4 V+ S3 ?
} </FONT>
1 N3 c. a7 s4 X; Y( {# Y. T7 A
% l2 ]: N! F2 {</P>
( A) G) ~! H4 Z4 b5 E3 G< ><FONT color=#ff0000>函数名: eof </FONT>
& b( G/ M$ B( E' `功 能: 检测文件结束
2 N" }8 K+ T! f1 U5 \3 H用 法: int eof(int *handle); 8 E$ b% Y; ?. J* C: S1 _
程序例: </P>* ^( S# {4 o1 O% l5 i- \
<P><FONT color=#0000ff>#include <SYS\STAT.H>
5 A0 T5 a) V; z! @#include <STRING.H>; B9 x8 A' k- r0 j u8 D0 i& ?
#include <STDIO.H> U9 b* S' N3 C5 O9 _
#include <FCNTL.H>' _, _) }. d' m
#include <IO.H></FONT></P>5 g( p6 d% t8 z* ?' y
<P><FONT color=#0000ff>int main(void)
9 E' h3 g c: P{
1 d. K ]1 v6 L% F* Fint handle;
$ ?, b9 G) Z: d8 O: ~char msg[] = "This is a test";
6 F# n4 e& m( Y) L `5 Kchar ch; </FONT></P>
; [* ^, [2 q% Z9 P5 d; ], V<P><FONT color=#0000ff>/* create a file */
7 `5 d3 X F. F8 Ihandle = open("DUMMY.FIL",
/ W2 ]( S) o6 `- `9 K; lO_CREAT | O_RDWR, 5 [5 O6 Q. ?" [3 }# o
S_IREAD | S_IWRITE); </FONT></P>
, H0 W3 I l8 v: E5 G2 [<P><FONT color=#0000ff>/* write some data to the file */ 9 S, h& H7 B6 D# R. c
write(handle, msg, strlen(msg)); </FONT></P>+ A: e7 H. e0 ?5 E8 U5 y# n
<P><FONT color=#0000ff>/* seek to the beginning of the file */ 8 n" P: W' @/ H) t, R' g
lseek(handle, 0L, SEEK_SET); </FONT></P>
9 q# w3 m6 ]( K; `+ O" L/ Q. j9 A" F<P><FONT color=#0000ff>/* % G. I( X/ y Q* x0 v& A0 q
reads chars from the file until hit EOF
. E" t1 A3 N; a1 t! v*/ ) D& N9 k6 S# E! i! z; Q! h
do & W4 P6 [9 c6 {7 l+ i6 S; d% n5 W
{
+ j( S/ c; |9 d- |+ Gread(handle, &ch, 1);
$ n; H9 t9 @# o4 _/ @, Yprintf("%c", ch);
& }+ H, G! Q2 h4 `- p} while (!eof(handle)); </FONT></P>
5 S3 o$ |& X1 J v9 H' @<P><FONT color=#0000ff>close(handle); " o2 Q- P! B: b# [# L3 ~8 |2 Q
return 0;
" \ F4 m" f, e+ ]# Z}
0 `4 i6 |7 r' q! Y</FONT>/ \5 z* T. v/ O( f2 w0 ?. C! A& Y
</P>
$ K) x4 g, }7 L/ f3 D e- I1 L<P><FONT color=#ff0000>函数名: exec... </FONT>, Z8 g+ c7 l1 X* P/ J+ }
功 能: 装入并运行其它程序的函数
4 s! w7 e! l I: f L* B5 X* `6 e用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
4 R( L: \6 O7 X1 Cint execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
% S( \8 T9 Y: n/ ~. _) I4 gchar *envp[]);
% {' V! N4 u& z/ g( ^* M& h7 d0 c; z8 bint execlp(char *pathname, char *arg0, arg1, .., NULL); ! Q$ E/ N) E( y1 l h$ \
int execple(char *pathname, char *arg0, arg1, ..., NULL,
+ e: d" b6 |* ]/ {. B- V6 Ochar *envp[]); $ G' f* Z+ T. ]3 m2 p7 N% i
int execv(char *pathname, char *argv[]); + D# ~7 b$ F! w+ ?! X
int execve(char *pathname, char *argv[], char *envp[]);
( U8 [7 s, i5 `+ b/ F5 x2 k0 c- Bint execvp(char *pathname, char *argv[]);
+ `* b7 b; x: S$ o6 oint execvpe(char *pathname, char *argv[], char *envp[]); ) P: F- ]& k$ H
程序例: </P>
- o3 J, l1 c4 X s' L D: ^<P><FONT color=#0000ff>/* execv example */
1 ^! M; Y% M) e1 I* g$ g% e2 \#include <PROCESS.H>
1 H% @/ V1 h; l9 R" P6 l#include <STDIO.H>, f4 z* E, z% t, y) h$ ~
#include <ERRNO.H></FONT></P>
4 Y5 q$ J1 L+ e* g# c<P><FONT color=#0000ff>void main(int argc, char *argv[])
5 W9 M4 v, ~* K& r3 F* Q4 I2 m{ ; r. S( X7 B u8 c( L0 {0 |
int i; </FONT></P>! \5 o) H2 L6 A: d0 H
<P><FONT color=#0000ff>printf("Command line arguments:\n"); 1 i" \1 ~$ Q9 C3 t6 Y
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
* ~! {' R' R9 r: g/ x7 W8 h<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); + L% |' t9 ~7 j8 F% {: C; S( }* a$ T
execv("CHILD.EXE", argv); </FONT></P>3 {4 p8 x" X" J8 E2 O7 f# b
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
" L1 l7 B$ j8 ?3 S. |6 P- |3 r6 v: _<P><FONT color=#0000ff>exit(1); Y* k( h) S. I7 F& Q: F2 y
} . X, J0 x6 Q1 t9 L+ @# S
</FONT>
/ |4 M4 b/ \5 B0 N+ o</P>4 `6 w2 r8 \+ F' b
<P><FONT color=#ff0000>函数名: exit </FONT> X4 @; d1 D, [$ ^- F* v
功 能: 终止程序 - |1 P: D$ K# N6 h f( X( t: T
用 法: void exit(int status); ( v4 `8 G# f, g& Q: p
程序例: </P> I7 o2 a+ d7 [& T! C
<P><FONT color=#0000ff>#include <STDLIB.H>8 H8 L, ?& j7 g& H" I6 h
#include <CONIO.H>& ?/ S8 e2 x5 B1 I) `) x0 [
#include <STDIO.H></FONT></P>
& f) `6 X* R% d3 q6 h/ L* P% R<P><FONT color=#0000ff>int main(void)
* V) M n) m9 T{
8 f- H( E! X6 f/ \& [/ t' oint status; </FONT></P>
% J7 ~3 X: f/ d. d- m, ?" Y+ ?; v# n<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); + W" ]9 _- Y1 E/ X% L
status = getch();
@- Q+ R; n5 {7 R5 C% r/* Sets DOS errorlevel */ % |% j; X! D- M j/ i; b
exit(status - '0'); </FONT></P>5 y& h+ D0 F7 r0 a l0 j
<P><FONT color=#0000ff>/* Note: this line is never reached */
( C# I; ]& E9 l' d* f" Ureturn 0;
- U/ E W3 ~( P) y} 5 r* a1 D# h1 [7 |- n( l
</FONT>3 I+ Z0 }$ S1 u# }" z/ N. L* \, M
</P>8 I# g/ s6 `( r2 ~0 b! M" K
<P><FONT color=#ff0000>函数名: exp </FONT>+ u! a4 w1 K \. D4 W( Y: U2 x6 g
功 能: 指数函数 9 v3 {4 K3 D( p& P( M: ~' B4 G( r# t- \
用 法: double exp(double x);
* o& E" P/ j0 n程序例: </P>
, S& x' }& _+ I<P><FONT color=#0000ff>#include <STDIO.H>
+ ~; d2 _$ N6 @5 J3 x* ]#include <MATH.H></FONT></P>
: Y8 a& f" a* f<P><FONT color=#0000ff>int main(void) $ S0 }$ w# i6 y1 l1 ]% }
{ " R9 G, i& F: I& W' E2 R
double result;
. l* Q3 ~7 V% E* F' {! r) G! jdouble x = 4.0; </FONT></P>2 {9 ]2 m9 q& ` W3 k
<P><FONT color=#0000ff>result = exp(x); % p2 V( f. ^9 }; F! x+ L' [5 k
printf("'e' raised to the power \ 5 v2 S& ?9 S+ z( ?1 B) E( p
of %lf (e ^ %lf) = %lf\n", ( _3 J( ]$ Q+ R2 O/ G0 n, j
x, x, result); </FONT></P>* a2 {% K/ {& C4 C
<P><FONT color=#0000ff>return 0; 1 { I7 w4 q5 } }+ {, w6 D
}
6 J% g8 T( Q3 G, i# w, K L8 t4 Q# z</FONT></P> |
zan
|