- 在线时间
- 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>
. V* v' g) g9 T. k1 w</P>
( h1 A, L8 t& D) Y& R8 V: e! Z9 p% A
/ _! L0 j+ ?$ z- h) K# s8 {& k< ><FONT color=#ff0000>函数名: ecvt </FONT>% K) y3 i, ?$ N; T
功 能: 把一个浮点数转换为字符串
3 E' I, D- ~4 b0 H5 \; B. u( B; Q用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); " A3 Z5 }( \) L* R/ O+ Z9 v" G
程序例: </P>
! }5 v# V$ F- n+ ^< ><FONT color=#0000ff>#include <STDLIB.H>
6 J6 C+ g- k& G9 e: }4 _6 A! Y! K#include <STDIO.H>
9 K) g' W" v" X& d6 [. y! T- N" _#include <CONIO.H></FONT></P>, G0 [; B% `4 n. l, j8 M3 ^- H: ]
< ><FONT color=#0000ff>int main(void) . J9 r' u% d8 a# W
{
2 B. a6 Y8 \3 Y) U7 wchar *string; 5 o' `2 s& H Q( X. f6 e( U9 w4 W
double value; 1 z) I, ], q# g9 n1 [
int dec, sign;
, b- e* U( n) v; ~8 U! Iint ndig = 10; </FONT></P>1 L( o/ U/ F. [8 s
< ><FONT color=#0000ff>clrscr();
2 J" @* y/ x: m) T3 s3 avalue = 9.876; . m1 C# Q& ^, q- y$ `8 ~( v5 d# \- x
string = ecvt(value, ndig, &dec, &sign);
& b4 p1 A* y3 dprintf("string = %s dec = %d \
) W, A) x: t$ isign = %d\n", string, dec, sign); </FONT></P>! v( Q8 s; a2 z0 G
< ><FONT color=#0000ff>value = -123.45;
% X# E7 J; Z8 [ndig= 15; 1 e( n8 a2 E( y; D5 `
string = ecvt(value,ndig,&dec,&sign); 7 y' _. s! o0 j1 H
printf("string = %s dec = %d sign = %d\n",
5 h) e1 M: u! i: M. c0 lstring, dec, sign);
( a3 A3 X5 T! g5 b% @4 ]. N( `0 u</FONT></P>
! N; `* M( P6 O ^* ]4 H< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
+ r+ g0 I6 `0 F7 A" W3 n9 Q+ [notation */ 8 a \) q i( p. Q5 F
ndig = 5;
" I/ ^# M3 }- J: M+ B1 n Istring = ecvt(value,ndig,&dec,&sign);
. w) `+ K" x5 k$ I6 I- ~. Bprintf("string = %s dec = %d\
8 B. I3 i( ]7 c" V4 qsign = %d\n", string, dec, sign); </FONT></P>8 e1 Y+ g8 t' E4 V4 i+ `0 _# g! K
< ><FONT color=#0000ff>return 0; & d3 G! K; R8 Q- ?2 ^
} </FONT>4 ?7 U* K4 ]' I G. L2 A5 e
" D% T) Y! Z2 S" M$ _$ }9 r</P>5 m: b6 x' a. K+ A; Z9 h, D; S3 c1 e7 p
< ><FONT color=#ff0000>函数名: ellipse </FONT>' s3 L% J% X- o4 W
功 能: 画一椭圆 : S3 x" D9 d( g& j& F8 i) {% L
用 法: void far ellipse(int x, int y, int stangle, int endangle, # v0 l( E8 [8 }# [8 Q
int xradius, int yradius);
+ o0 U' b9 h+ N$ [% M3 m程序例: </P>7 w' ^) s F" o6 F; c" m) x
< ><FONT color=#0000ff>#include <GRAPHICS.H>
- {% F9 q) |: ~# x% u" v. g ?- v* W#include <STDLIB.H>) o& S, _$ _+ `" E: I0 V
#include <STDIO.H>: ?% `3 G! ~4 y- |( l! _
#include <CONIO.H></FONT></P>. G m k7 x+ B+ n/ X% n
< ><FONT color=#0000ff>int main(void) 0 M4 C+ {- C9 T3 n# N
{
9 _, m1 K- t6 j/* request auto detection */
# l: r( V G; D3 l* Jint gdriver = DETECT, gmode, errorcode;
* j! G" F- |2 W; n0 Y, eint midx, midy;
! q' P% x7 E& D aint stangle = 0, endangle = 360;
f* A6 {: [' a+ pint xradius = 100, yradius = 50; </FONT></P>
$ C5 C% Z4 a( L8 k; |< ><FONT color=#0000ff>/* initialize graphics, local variables */
7 ~% x1 ~$ T' E5 F! I J: einitgraph(&gdriver, &gmode, ""); </FONT></P>
1 k# o9 o; \8 _. f- s< ><FONT color=#0000ff>/* read result of initialization */ ' l, [8 l+ r: k) T- j
errorcode = graphresult();
, N6 p. h8 y/ w) A1 J- l+ H1 s4 wif (errorcode != grOk) % n$ D% H' _, u8 S. i( Z
/* an error occurred */ ) m" R5 m {. W& U! {7 ?/ ?
{
\4 a8 M/ ~* w, F% Eprintf("Graphics error: %s\n",
/ B& A5 N9 @. }grapherrormsg(errorcode)); & I0 o' S2 a! T! A4 v1 w
printf(" ress any key to halt:");
1 l* s8 P. N1 Z0 Q9 ?getch();
& i5 S5 G6 {$ P" _% Vexit(1);
9 | H6 Z1 M8 q3 Y/* terminate with an error code */
# g* w0 Z! g# u( E} </FONT></P>) a, U0 a: x Y1 y4 L. j" y! h
< ><FONT color=#0000ff>midx = getmaxx() / 2; ' b: ^- Q d9 H9 v9 l3 Y) _
midy = getmaxy() / 2;
, P0 A4 p7 r3 _: lsetcolor(getmaxcolor()); </FONT></P>
! c; \/ J8 n. Z- g9 {< ><FONT color=#0000ff>/* draw ellipse */
. A/ t" R" V* B3 Q: r/ O7 \ellipse(midx, midy, stangle, endangle,
! `! |2 b1 \2 l3 l0 vxradius, yradius); </FONT></P>$ N4 A X8 u' e# _- d
< ><FONT color=#0000ff>/* clean up */ ! k% o1 e) x1 X( ~" \) t
getch(); # E, V1 S! Z0 k: L# U! Z; I
closegraph();
0 g1 S! |& `1 B( W) U2 L/ Ireturn 0; 2 y! G+ r7 k9 L# u& t, \" |/ h+ x- l
} </FONT>1 z# p# j# V" \8 q
8 d7 Q* j6 \: M5 J
</P>% A8 ]" ]% p, N- ]
< ><FONT color=#ff0000>函数名: enable </FONT>& d/ ]4 K8 T6 ~5 Y
功 能: 开放硬件中断
p) W" Z1 ]$ T, u W用 法: void enable(void); 1 `5 _# Y1 X+ \! i& Q( P
程序例: </P>( \! ^ p1 J( i) w; A0 i
< ><FONT color=#0000ff>/* ** NOTE:
! ?' Y u, ]9 H& iThis is an interrupt service routine. You can NOT compile this program
3 h# h$ }. m4 gwith Test Stack Overflow turned on and get an executable file which will s. z! [6 h2 z1 t$ W! ~
operate correctly. / i$ p1 [! k4 n2 e2 _7 ?
*/ </FONT></P>, `0 m& n+ ^: h Q# B& V
< ><FONT color=#0000ff>#include <STDIO.H> P# J& Y2 z* H" B* X
#include <DOS.H>
/ x$ B' _( T& V" O#include <CONIO.H></FONT></P>5 ~5 g) w) @& M
< ><FONT color=#0000ff>/* The clock tick interrupt */
9 |5 v; U" n# u#define INTR 0X1C </FONT></P>
% w# k5 e4 j# P8 X- i+ p< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>. {3 P+ p6 u9 Z& U; @
< ><FONT color=#0000ff>int count=0; </FONT></P>1 n* ^, v# a; B) q; m; P4 `7 t
< ><FONT color=#0000ff>void interrupt handler(void) " L! { C5 t h8 r0 J2 I; s: V" `) J
{
. `: V8 r v$ G+ R/*
0 a- Q6 s" b& L, pdisable interrupts during the handling of the interrupt 2 F# f0 u; `) ]& E {/ v8 M) f6 `) d
*/
/ e5 U$ P) E Z4 u' fdisable(); 6 r; x" w: h0 [- O! q+ d
/* increase the global counter */ # |, a/ _% {, Q( k5 |5 z
count++;
3 r& b' c, L4 o/ T3 z& f/*
7 o3 e- N8 ^: @7 rre enable interrupts at the end of the handler 3 J1 z" a2 j! W
*/
) G1 P' b- u& {" L6 S# Y* |9 `enable(); : J2 U( Z# h T4 [+ V* @, D4 w# P
/* call the old routine */
9 O V9 |$ I& t1 D% u* Noldhandler();
7 |% _/ Y! l! k" R" }9 v3 x} </FONT></P>
# b) W1 c: L8 K$ y, Q8 Z- Q< ><FONT color=#0000ff>int main(void) 6 e, `3 ~8 o- s8 D8 g7 O
{ @; s8 Z; Q3 a/ A+ B# c. h- U
/* save the old interrupt vector */
8 h% M9 P# n0 G! \" \: ^oldhandler = getvect(INTR); </FONT></P>
* P% \3 n( x( n" y< ><FONT color=#0000ff>/* install the new interrupt handler */
* D8 {( ^: ^3 Q! N" _6 Q* Esetvect(INTR, handler); </FONT></P>
5 C$ H7 \# q& |1 T3 t< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */ " Q( M6 m9 |- q3 Z) G
while (count < 20)
3 s3 m: k1 O; @+ Y1 u/ Y3 _+ {, Dprintf("count is %d\n",count); </FONT></P>
. \5 _! q9 r. s7 `< ><FONT color=#0000ff>/* reset the old interrupt handler */
( P6 Q+ |. A V0 w) X [setvect(INTR, oldhandler); </FONT></P>
. [- ?% f5 l: D( t< ><FONT color=#0000ff>return 0;
9 N3 B. Q* l; @9 @} </FONT>
! c$ J6 [0 ?2 L0 G% W
/ m7 E. `: y) [# R$ G$ w</P>
2 Z* u( {/ ~9 N8 r< ><FONT color=#ff0000>函数名: eof </FONT>" m1 L, h, s0 n9 |3 i+ f
功 能: 检测文件结束
6 Z. ^) x) C8 b5 C' ~; [2 |/ \用 法: int eof(int *handle);
' R+ @2 w5 H3 J. s8 D程序例: </P>
* x) z1 p: C6 c8 U$ |9 s( l# K<P><FONT color=#0000ff>#include <SYS\STAT.H>5 m+ F+ ]7 J$ \) Q
#include <STRING.H>/ }/ a2 X! P* A; K' g
#include <STDIO.H>: d" p' H0 Y+ \3 R/ Y* W4 S) G
#include <FCNTL.H>7 k( C- |0 f6 `& `
#include <IO.H></FONT></P>
2 n4 \3 N8 E: Z6 Q4 u<P><FONT color=#0000ff>int main(void)
0 H" F' R r( }" |{
+ I D& @: w% hint handle;
4 ~7 d; G# D% g& X- ichar msg[] = "This is a test"; , s) }! I8 W! ^7 B9 H) M0 z1 q
char ch; </FONT></P>
- j# Q) h) a6 B2 D5 Z0 ~<P><FONT color=#0000ff>/* create a file */ ) D: J' z+ B& W- Z$ c3 J5 k
handle = open("DUMMY.FIL", 6 @* z5 E- [4 |* z
O_CREAT | O_RDWR, 9 p2 ?7 Y" F( V e+ I9 t7 k
S_IREAD | S_IWRITE); </FONT></P>
! O1 I% E3 p4 x. m/ x% X2 w- e# w( m<P><FONT color=#0000ff>/* write some data to the file */ 4 g' V- S. ]) D
write(handle, msg, strlen(msg)); </FONT></P>
7 m2 A" }$ E5 O0 ]# M' ^5 t<P><FONT color=#0000ff>/* seek to the beginning of the file */
- y! t' \9 T0 t4 Z7 }lseek(handle, 0L, SEEK_SET); </FONT></P>
, v. M! d+ ]0 o<P><FONT color=#0000ff>/*
5 C+ V2 u8 [! ?# U9 h- k, O" dreads chars from the file until hit EOF + a7 P: z4 R& ?: i- r% \
*/
' \5 m, B o% sdo 3 I% o6 A$ d# G$ V( w! _; Z; u
{
$ ~4 ^# M0 B5 d/ Q8 y* U3 U+ I- vread(handle, &ch, 1);
; u0 q2 o+ b8 ]# Pprintf("%c", ch);
# m0 V& O a' C& i1 Y# J+ _1 T} while (!eof(handle)); </FONT></P>1 s1 A5 P- r4 P- S( n
<P><FONT color=#0000ff>close(handle);
/ |( O5 [' Q0 W& dreturn 0; / {; ?# z( [5 P* U x: v$ e
} $ y" ~$ s( I4 p% o7 L/ Z
</FONT>
/ a/ |4 C1 ?6 o/ ^</P>5 g6 F7 L. X1 M! X1 F4 `
<P><FONT color=#ff0000>函数名: exec... </FONT>
, ^1 l" k& T3 F5 E3 D0 x功 能: 装入并运行其它程序的函数 + A: C% n- s- p" u, Y6 ^. }
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); 4 J# L* o* b) }
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
/ {5 x- @5 K* O$ l kchar *envp[]);
4 B$ u# q3 I3 ]& k- N- |int execlp(char *pathname, char *arg0, arg1, .., NULL);
6 b: r* h" l4 Eint execple(char *pathname, char *arg0, arg1, ..., NULL,
$ `: l1 q5 q! D0 M/ v1 Lchar *envp[]); # g% {' M8 y- I5 m* o% d
int execv(char *pathname, char *argv[]);
+ a2 E; v. @. bint execve(char *pathname, char *argv[], char *envp[]);
9 V* ~1 F: P- ~% b/ f6 T1 zint execvp(char *pathname, char *argv[]); $ y5 A1 l8 U4 t8 o+ E* o
int execvpe(char *pathname, char *argv[], char *envp[]);
0 m3 j5 w5 w4 Z; p程序例: </P>
1 i, v( e7 }0 D& A<P><FONT color=#0000ff>/* execv example */
2 k$ p t L- r#include <PROCESS.H>
) Q1 O( a+ w) S/ R' R. v7 ?4 q#include <STDIO.H>4 l9 Q! {; y1 n2 `. `% i) [
#include <ERRNO.H></FONT></P>" K1 J* y/ ^5 p. k$ L" _ C' O
<P><FONT color=#0000ff>void main(int argc, char *argv[])
; K3 _) ]/ ^( S/ k$ J0 L2 J$ U; s$ F$ W{
" T' D/ l: n- L* [" Jint i; </FONT></P>7 }( R7 J/ v( X6 w$ a/ k
<P><FONT color=#0000ff>printf("Command line arguments:\n"); 1 c2 ?' ~% Z( X* d
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
6 L( s* G% i$ Y1 `1 B/ ?<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
, o# J5 E5 v% O5 d% n; w* |execv("CHILD.EXE", argv); </FONT></P>
( F5 _) I$ a. G- R4 g7 |3 ^# b8 g<P><FONT color=#0000ff>perror("exec error"); </FONT></P>3 _9 o. U7 K, p) z0 U
<P><FONT color=#0000ff>exit(1); 5 }8 S- m; h; F) E& A
} / b; A6 k* [9 @9 }4 D
</FONT>& n. K, A8 V6 q: l
</P># `: V. I9 u2 I4 p3 Q3 |
<P><FONT color=#ff0000>函数名: exit </FONT>0 U2 y: ?$ S3 g* N. d- F* ]* t) R
功 能: 终止程序 ' U6 C" a2 b: L( O* }* O8 s7 z0 p
用 法: void exit(int status);
1 H. C* m6 P; i0 M程序例: </P>2 {" x/ O0 p; Z9 ?% ? u
<P><FONT color=#0000ff>#include <STDLIB.H>
/ C* g, Y) n0 q9 t8 L% f7 R#include <CONIO.H> \& q, H) p" {
#include <STDIO.H></FONT></P>4 W7 C1 s2 G" g4 h" F
<P><FONT color=#0000ff>int main(void)
) v! `4 a& m# w3 ^& P{
A2 O/ R' A# F/ a' Zint status; </FONT></P>
( @6 y8 i4 r, V }/ p, g8 ~<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); + w3 }+ h0 x% R
status = getch();
/ ^6 H) x# x6 o; |6 ~: A/* Sets DOS errorlevel */
0 D; T2 c' T$ R/ v8 W3 y# Oexit(status - '0'); </FONT></P>
# R$ @, z2 F/ m8 q5 `4 z) i! ~<P><FONT color=#0000ff>/* Note: this line is never reached */ ^, [$ L, K; n
return 0;
4 n8 v* _8 R5 J, e+ _: G} 6 j5 t8 F: ?) \# Q* Z# a+ _# S
</FONT>! ?! p8 Q9 w5 a% H: m5 v
</P>
4 i: q9 u4 D* s; a- X& o<P><FONT color=#ff0000>函数名: exp </FONT>/ M' \5 @1 [4 |) v. U
功 能: 指数函数
[1 Z3 K" R# l8 T* I用 法: double exp(double x); $ h0 G. p6 E$ }$ t' g; d
程序例: </P># t6 {+ c N4 o% o( K1 |+ L
<P><FONT color=#0000ff>#include <STDIO.H>
) d5 ^$ u* [1 M1 y#include <MATH.H></FONT></P>2 s) F" r8 A! H
<P><FONT color=#0000ff>int main(void)
' \# y5 K" B/ Z4 b4 F! m{
- ]2 X- X5 G/ X4 `. Tdouble result;
/ i [1 {7 f' u [# W7 B3 H+ @double x = 4.0; </FONT></P>% b7 R0 J1 m Y: K0 _% r
<P><FONT color=#0000ff>result = exp(x); " I+ W q3 Z# `+ O. X. P) c, q
printf("'e' raised to the power \ # n+ g% E" M8 Q% p+ K
of %lf (e ^ %lf) = %lf\n", 4 Q# z1 O7 W& O; L
x, x, result); </FONT></P>' w ~3 m% S/ G% y' Z7 K' X- k( ^
<P><FONT color=#0000ff>return 0; 5 g+ x7 Z: ^3 e3 H& Z# [
}
% @" c' `5 `4 ~, _7 S</FONT></P> |
zan
|