- 在线时间
- 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>
3 ]3 i- b! ?/ ^* B2 d% P</P>
3 F$ @0 y" n# Z# p) H. F g% k" N3 Z2 D7 |! P6 [- {& S
5 q, y6 V3 x0 d/ t- m% [4 M, f< ><FONT color=#ff0000>函数名: ecvt </FONT>- k$ i& ?0 K' g/ m
功 能: 把一个浮点数转换为字符串 4 Y; j0 L0 s1 u9 K
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
* l2 ~4 v* U; N% x. J- J) X2 b程序例: </P>- Q) L5 S( i7 z) P! t, Z6 f
< ><FONT color=#0000ff>#include <STDLIB.H>6 u) B8 k' D5 O1 P$ i/ S7 q
#include <STDIO.H>( H/ J, ?8 {& n4 i6 t; u
#include <CONIO.H></FONT></P>
% J" X4 G/ U( E& I' Q7 V( C7 S( J& V< ><FONT color=#0000ff>int main(void) c8 | b5 R$ t2 O! F
{
, z* \4 f: s9 cchar *string; + R! @* C2 i6 p7 D B2 z8 a
double value; % T+ n, i7 ]" s! X6 o
int dec, sign;
9 V( j* G9 k' L3 ?% ^6 l. h4 r& m! Gint ndig = 10; </FONT></P>0 ]; F( k5 r& _2 I0 v
< ><FONT color=#0000ff>clrscr();
9 H$ G1 G( i8 Y! Vvalue = 9.876;
8 g# q9 [ d: Fstring = ecvt(value, ndig, &dec, &sign);
; Z. C- C$ k/ F$ X; ]3 C# dprintf("string = %s dec = %d \ - v0 M. p- v' }" t3 H6 {+ N
sign = %d\n", string, dec, sign); </FONT></P>) }6 b, ?9 y5 Y' @: |
< ><FONT color=#0000ff>value = -123.45; * j( ^6 G) S& U y8 l8 \
ndig= 15; 2 B- @* S! j4 X" @' R7 L8 f# o; m+ w9 v
string = ecvt(value,ndig,&dec,&sign); 1 j; P, j) l9 | d$ k2 |! O
printf("string = %s dec = %d sign = %d\n",
1 Y5 X: p3 ]5 \) ^3 b/ Q" tstring, dec, sign);
4 v: O, s6 Y) O: I</FONT></P>) M" ]8 r. R. P5 b5 V# R
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific 5 ]2 |4 p* G3 X" u& @# a" q
notation */ ' I7 L7 e6 L6 O7 U$ I w( S
ndig = 5;
, s1 G' Z- K5 b9 B G0 \: vstring = ecvt(value,ndig,&dec,&sign);
: o" C. s8 [1 \/ A5 cprintf("string = %s dec = %d\
y8 Y1 H: f9 t5 t/ c4 Wsign = %d\n", string, dec, sign); </FONT></P>- A* ~& R; ~+ Z' M
< ><FONT color=#0000ff>return 0; % I, k( _. g" Z' B
} </FONT>& ^/ ` K$ d$ a9 c9 `
/ F3 \7 ?' Y. \2 t
</P>5 n( p1 G! x: k6 L5 u
< ><FONT color=#ff0000>函数名: ellipse </FONT>
k! ^3 l t: w( Z+ e功 能: 画一椭圆 5 u8 ^3 j! b0 M& m
用 法: void far ellipse(int x, int y, int stangle, int endangle,
# \5 b" \+ s, w# ?2 Nint xradius, int yradius);
3 }" A9 m1 t) a# X5 K程序例: </P>% U# h' B) ~/ j' _3 _( F* e
< ><FONT color=#0000ff>#include <GRAPHICS.H>2 a4 I- Y/ M4 R; G
#include <STDLIB.H>
3 B& H1 r+ p5 |& i: u% X#include <STDIO.H>! o: R- B6 F6 n3 N( T8 s
#include <CONIO.H></FONT></P>, g f8 C2 N$ C$ ?' B% [
< ><FONT color=#0000ff>int main(void)
: y+ o1 K! }/ i0 f6 s/ t{
0 e) s% s& V4 A. |) i! {3 h) n/* request auto detection */ * V: i0 }8 L2 N" |. w0 [2 M
int gdriver = DETECT, gmode, errorcode;
; y6 C: y- A. d* {6 vint midx, midy;
1 e3 O& F0 p# ~7 M8 ?3 Uint stangle = 0, endangle = 360; . \/ D+ S, L) I. ?' Y8 Q
int xradius = 100, yradius = 50; </FONT></P>) ^( r/ Y8 o6 b
< ><FONT color=#0000ff>/* initialize graphics, local variables */ # }$ m6 E. \: w; ?% S2 ]
initgraph(&gdriver, &gmode, ""); </FONT></P>
% y4 M) Q) f1 z% N< ><FONT color=#0000ff>/* read result of initialization */ 7 t& U$ O- c/ ?! f3 `
errorcode = graphresult(); 6 x! j2 }' A; T
if (errorcode != grOk)
' c6 v$ i: l" _2 n8 d$ D/* an error occurred */
- I: ?" [: q7 J% z5 N{ " R s0 n$ w; [4 I) G6 V
printf("Graphics error: %s\n",
+ H% E9 B4 \2 s( Hgrapherrormsg(errorcode)); . e/ g$ s4 ]) h$ }0 S P
printf(" ress any key to halt:"); W8 V' {' [1 y$ r0 g
getch(); 5 w: L0 y6 T: m- E! v4 M
exit(1); 3 s: t8 L5 c& B* p% v/ w6 ?
/* terminate with an error code */
4 q8 i8 H- U6 B' H- |) d} </FONT></P>. N+ O1 C0 A: ]$ X8 M, }# t* O$ N' v
< ><FONT color=#0000ff>midx = getmaxx() / 2; 5 f* T y% ?3 V! Q R& m, v( M
midy = getmaxy() / 2;
4 Z; K" x$ z" msetcolor(getmaxcolor()); </FONT></P>
0 a. ]6 @* H9 t< ><FONT color=#0000ff>/* draw ellipse */ : z2 f% O# ^9 j
ellipse(midx, midy, stangle, endangle, ! I& ]8 m3 X8 v1 `: v. x
xradius, yradius); </FONT></P>
5 t8 V; {& B v< ><FONT color=#0000ff>/* clean up */
* K$ R8 _3 _$ d5 s) o, M/ M" Q5 \4 Lgetch(); 8 r% H4 p( K! m
closegraph(); / e4 d( ]2 p- J3 z5 a" q. X) B' u
return 0;
7 A& Z0 J/ }+ [1 X! N8 C3 @ t} </FONT>8 E* f: V3 \4 p# b8 o- @6 ?. Y7 n
6 r6 p3 o6 o3 N2 `" S</P>
2 t: [; r. b9 P9 L2 w: k< ><FONT color=#ff0000>函数名: enable </FONT>! d+ y+ U, `, F$ s2 A; e* E
功 能: 开放硬件中断 ; H" Z9 T; g, }% i, f% d( r! @
用 法: void enable(void); 5 x9 y2 B! D( ~' U4 F
程序例: </P>
% B: \) X/ ~' a8 }" J$ c6 I< ><FONT color=#0000ff>/* ** NOTE: 0 r' K4 V9 K8 v' P8 Z8 |
This is an interrupt service routine. You can NOT compile this program j- [; v/ P% P; U1 R$ ?) a
with Test Stack Overflow turned on and get an executable file which will + a0 g) [8 G k* \& Z( @
operate correctly.
$ L4 d. {8 o5 V- W$ {- b*/ </FONT></P>8 _' R/ y* ^+ Q
< ><FONT color=#0000ff>#include <STDIO.H>; z1 ?5 S- a/ G9 L# L
#include <DOS.H>
# ?' m3 i) B& x+ n& l; e# f#include <CONIO.H></FONT></P>5 J8 I# N. f7 H H D3 A
< ><FONT color=#0000ff>/* The clock tick interrupt */ 5 m2 f; s- E% w9 s7 c: u& i
#define INTR 0X1C </FONT></P>' [! k- D8 f3 p& ]& V% K
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>
& K! g% G/ w/ n3 r" g2 X/ I$ C< ><FONT color=#0000ff>int count=0; </FONT></P>
2 | \; e- s4 _2 m& c2 U7 X< ><FONT color=#0000ff>void interrupt handler(void) 5 m+ {9 j" h( B# w8 ]; H, e
{
; y. N! y- v) x# t/* , V: G" O. d- b7 ] E
disable interrupts during the handling of the interrupt
9 f# T" D, G$ n) |! M- u; l' O*/ / [5 l; ?/ R& |" x& O( ?
disable(); 1 @9 I- [. m9 h, n h
/* increase the global counter */ L8 ], T e" z w/ x& c5 c
count++;
0 P9 }5 K* d0 C* z) x- X; s/* 3 c3 W' | Z: n+ i. i6 |
re enable interrupts at the end of the handler * ?9 J, p6 ]" P" F- R
*/
X9 w5 s/ _, J& m* K3 b- ?2 Q* t. penable();
- s! W, ^0 n+ @; ]9 Y8 Q: i/* call the old routine */ 8 e5 F1 f' t5 H) i' ~' |+ m7 x# a
oldhandler(); : H1 v/ C6 r2 U6 ?1 W% c
} </FONT></P>
9 W. |* M8 S6 T5 V< ><FONT color=#0000ff>int main(void) % a4 ~4 {, c2 e, ~
{
. O: g0 j" B" _/* save the old interrupt vector */ " h* z+ e1 r8 b
oldhandler = getvect(INTR); </FONT></P>: w. x* H* E" m( V" K" e0 h
< ><FONT color=#0000ff>/* install the new interrupt handler */ ; q4 Z; ]' x. W$ r+ S% K! @4 p
setvect(INTR, handler); </FONT></P>* ~, A( I7 V8 Q1 @3 F$ x
< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
1 h! y6 k/ v& ?( f+ p" Nwhile (count < 20)
& T" g' l9 |9 ]% d0 C9 E6 }. }printf("count is %d\n",count); </FONT></P>6 @5 d) d. ]- B
< ><FONT color=#0000ff>/* reset the old interrupt handler */ 3 A! R4 C" `1 j9 p d+ x; N
setvect(INTR, oldhandler); </FONT></P>4 L$ t, z0 M3 P1 b( K3 T4 u
< ><FONT color=#0000ff>return 0; 7 [* k8 y7 x2 v: ?: r9 a$ v
} </FONT> L' w7 ]# A! r- O
7 W/ D! _% k( t5 A% E4 a
</P>/ G- r5 I0 [0 C t+ l
< ><FONT color=#ff0000>函数名: eof </FONT>
4 n# g3 j7 {# C1 k+ \0 X7 V+ _功 能: 检测文件结束
0 h `3 m9 Z* ?! Z) M, F, q用 法: int eof(int *handle); + X% K* H) p+ W6 z; g. V
程序例: </P>
+ d% x2 I/ m5 B' E# l9 g& p8 W<P><FONT color=#0000ff>#include <SYS\STAT.H>. c4 R1 o5 m3 x3 m! O8 S* n& ^
#include <STRING.H>$ } c# s* K0 }& b& R# w5 c# @# ~
#include <STDIO.H>
& _: q7 Z& ^4 D% L4 P) V/ l#include <FCNTL.H>3 y" n* m9 E$ |) E9 B$ Z0 h
#include <IO.H></FONT></P>9 H' [) l) C$ Y0 Q$ V2 I
<P><FONT color=#0000ff>int main(void)
) `. m" F9 n7 M, Y! t: g{
# E" ]% \( S0 n n# eint handle; M3 n Y5 l: l
char msg[] = "This is a test"; 0 Z Y; `7 v. m/ Z& z
char ch; </FONT></P>
1 L! K8 x, A, E$ Z' e5 ^6 F<P><FONT color=#0000ff>/* create a file */ $ e4 i* X+ w# Z" {4 X1 }9 H
handle = open("DUMMY.FIL",
) T! s# s! y6 _* Y0 ], K, V0 }+ MO_CREAT | O_RDWR,
5 ]; c: G6 ~; {# LS_IREAD | S_IWRITE); </FONT></P>4 y r" C. q# k. @+ s2 w, A3 d5 C, ?
<P><FONT color=#0000ff>/* write some data to the file */ 8 p+ c ?5 i2 D7 n! I
write(handle, msg, strlen(msg)); </FONT></P>
# k8 r# E+ G- K# o/ {+ Y/ \<P><FONT color=#0000ff>/* seek to the beginning of the file */
# n; `' \/ p1 u* Vlseek(handle, 0L, SEEK_SET); </FONT></P>8 k" F1 l; f8 {1 O
<P><FONT color=#0000ff>/*
3 }' F9 X* C. ] Freads chars from the file until hit EOF
! g2 t) d1 [$ _1 q* p2 l. }*/
: c8 ~9 O" H3 v4 fdo
+ i; N6 d( {$ X+ _% A4 Z. D{
# m: B) N+ P% w( [0 fread(handle, &ch, 1);
0 e# ^$ k# K4 j! Oprintf("%c", ch);
3 p& _. I" H* i2 A} while (!eof(handle)); </FONT></P>6 u% v0 q1 A( x; d
<P><FONT color=#0000ff>close(handle);
, e: u @7 h; G( ] I6 o7 v2 yreturn 0; 5 b: H$ _; Q3 D9 Z8 m* K
} 1 S9 g9 k8 `& G7 @
</FONT> K5 s. S5 g8 J
</P>' @0 Y( A! W4 T) @
<P><FONT color=#ff0000>函数名: exec... </FONT>
0 t( H' X9 U/ B& [* S6 W, [功 能: 装入并运行其它程序的函数
4 _9 e. _8 j6 X5 y$ b# @! F% C# f$ C用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
. [; x5 d7 p# }& K$ lint execle(char *pathname, char *arg0, arg1, ..., argn, NULL, , d; o0 M8 U: w8 {$ L$ e
char *envp[]);
" B- A: N: L8 i4 bint execlp(char *pathname, char *arg0, arg1, .., NULL); 9 C: a! z# l7 l" m) Z
int execple(char *pathname, char *arg0, arg1, ..., NULL, 1 g5 d! h! v Q/ l7 c
char *envp[]); Y8 r4 j- V' s- r% Q# J
int execv(char *pathname, char *argv[]);
; n( o: B# |4 \8 d- i/ f" Tint execve(char *pathname, char *argv[], char *envp[]); / ]- P( ` D$ J( X% ^8 I
int execvp(char *pathname, char *argv[]);
9 b& w8 A( e" f. `int execvpe(char *pathname, char *argv[], char *envp[]); a4 p9 h' n, R$ m
程序例: </P>
! F, `/ ~7 o8 R3 S! s8 t<P><FONT color=#0000ff>/* execv example */
3 C5 W5 R" v! |8 V. [#include <PROCESS.H># _! O7 V% W: B: \1 S5 i
#include <STDIO.H>
2 X7 _7 Y U; N8 }5 w#include <ERRNO.H></FONT></P>) x f. [" ^8 ?# q' H
<P><FONT color=#0000ff>void main(int argc, char *argv[]) " n- `' _+ B/ g1 l
{ / e5 Z7 {7 \, n' `
int i; </FONT></P>7 g" o: [( ]5 y; s5 _* u$ Q6 b
<P><FONT color=#0000ff>printf("Command line arguments:\n"); $ D+ R. X4 w) ^6 m8 w8 s8 Q
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
9 B2 d: [2 X. V4 g) f<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
, a- H7 C+ o- b' K& Rexecv("CHILD.EXE", argv); </FONT></P>
0 Y ^6 T' [& J* Y0 T<P><FONT color=#0000ff>perror("exec error"); </FONT></P>& f; ?$ F+ N/ s H: ?, f" m
<P><FONT color=#0000ff>exit(1); & g1 J9 @3 g& U2 R
} 4 L# l+ v v: k" `8 U( x
</FONT># k1 P, b+ P: h9 G2 [
</P>& [/ S: f& v; G) z
<P><FONT color=#ff0000>函数名: exit </FONT> E, g# N. V' ]
功 能: 终止程序
* C- O& X9 v, C8 j$ {+ U; l% x用 法: void exit(int status);
( |) s5 M1 z' \$ m( @& m程序例: </P>
, y' d% e8 ?4 j<P><FONT color=#0000ff>#include <STDLIB.H>
# n- b$ N; y5 c: |- E6 b _, a1 q& Q#include <CONIO.H>
4 |, X9 h8 T) i: S4 ]. L#include <STDIO.H></FONT></P>
( w& G# p0 ?1 w* I, ^<P><FONT color=#0000ff>int main(void) 8 u/ O7 \$ o" [! ?# P
{
+ h( i5 l# G% J# w+ Nint status; </FONT></P>! Q( R* }6 H+ T- T+ o4 V" E, W. v
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
9 K0 l8 z, e- w5 I3 {, ostatus = getch(); : Z# G) v- P# e9 ^- I+ ^
/* Sets DOS errorlevel */
8 I" Z5 g- M8 Mexit(status - '0'); </FONT></P>/ A8 X# X2 G- b4 O# v
<P><FONT color=#0000ff>/* Note: this line is never reached */
6 [; B) l0 L- i+ _% X; L% c4 {return 0;
( d# E& D$ b j2 {$ M- c# _5 A7 {} " s, r8 a& e# g, _% T B! n
</FONT>: m3 f- e; c1 O
</P>
: M2 X( U5 l0 T8 ?2 @/ B" q8 Z<P><FONT color=#ff0000>函数名: exp </FONT>
/ \% z! S5 N) z5 ?功 能: 指数函数
8 l. Y0 }9 B; U& a" V1 C; S用 法: double exp(double x);
; l- Y* ?+ `. p; W/ y3 B' [程序例: </P>
/ `" T6 c" e1 I# @8 _% y<P><FONT color=#0000ff>#include <STDIO.H>
( `1 P& n* [1 r$ l# o, K# {#include <MATH.H></FONT></P>
$ @- @+ j5 {; w<P><FONT color=#0000ff>int main(void)
; m- }; `8 z4 ~. K! P: {{ 4 ]3 I, s8 w" X" e5 a1 ^3 }
double result;
8 ]$ |3 y; U) g' Idouble x = 4.0; </FONT></P>, ^2 b; Z5 Y, `/ s! H' b* u
<P><FONT color=#0000ff>result = exp(x); ' I4 R9 J* [6 I9 O6 a
printf("'e' raised to the power \ }' C" w3 T1 |4 l
of %lf (e ^ %lf) = %lf\n",
( u2 \+ ], P, u$ L% Wx, x, result); </FONT></P>
. u, t) B7 S9 U' u<P><FONT color=#0000ff>return 0;
1 ]; G3 a( ^' m5 u0 A}, W2 G0 j/ N0 ]$ i$ B$ P
</FONT></P> |
zan
|