- 在线时间
- 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$ X0 y3 \' O5 y
</P>5 |+ ^' I& y; S/ y7 o
" L- M& T3 y+ X8 n
4 f5 o' \2 ^/ N< ><FONT color=#ff0000>函数名: ecvt </FONT>, p9 {1 u9 e0 p. A: w5 y% O
功 能: 把一个浮点数转换为字符串 & h" O; \) _7 G. ?! I& Z
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
/ Q. ~1 t I9 a6 B/ a1 X9 X6 m程序例: </P>, I+ z! K% v& D2 c4 e
< ><FONT color=#0000ff>#include <STDLIB.H> W3 @2 F* d5 P5 }& V9 F N' {/ R
#include <STDIO.H>
3 F0 K% u H4 x k0 N5 v) ]#include <CONIO.H></FONT></P>
- ~' H( w) [# R6 `* `' R8 g! D< ><FONT color=#0000ff>int main(void)
. C8 s0 r. _9 L6 O2 a( o) d{ 7 P9 w# G2 i% l( r4 s
char *string; ) ~7 v5 y% E2 h0 m9 Q
double value; ) q1 h9 h; m9 Y( Q9 A6 J
int dec, sign; $ R* C' W3 b2 l4 X, m
int ndig = 10; </FONT></P>( s# ]. Z* @" E$ N/ m7 i3 E: [
< ><FONT color=#0000ff>clrscr(); $ {. R8 O( p- o- [
value = 9.876;
& q% a) i3 A" D& h1 v$ k/ Ostring = ecvt(value, ndig, &dec, &sign);
1 t9 a. ^5 d! g) ]2 X- G# Zprintf("string = %s dec = %d \
# g( g6 z1 P7 g, Hsign = %d\n", string, dec, sign); </FONT></P>
( n6 i3 z1 a% n< ><FONT color=#0000ff>value = -123.45;
7 f8 F2 w, t( Y7 X6 mndig= 15;
. X$ o4 X" A7 {5 ]8 B9 \string = ecvt(value,ndig,&dec,&sign); % P% G1 W3 L8 e% g0 ]- l) [
printf("string = %s dec = %d sign = %d\n", 5 U( e& O& I, C! p' t+ I
string, dec, sign);
/ g x! T% {. R+ s/ G. s</FONT></P>2 N" A/ j- Z/ r
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific ! b0 I( \" n: H8 F, G
notation */
3 w* p9 V7 G4 z' mndig = 5;
" a" _+ _; `8 ~# F+ z6 ?8 Tstring = ecvt(value,ndig,&dec,&sign); 9 s" d% L! Z9 a1 Y# j3 d
printf("string = %s dec = %d\ * ~7 P$ i/ h; R$ A$ Z" ~
sign = %d\n", string, dec, sign); </FONT></P>$ [- t0 F' _$ g& m
< ><FONT color=#0000ff>return 0;
! F7 ^9 X# t7 _! P} </FONT>4 ]- N6 o. S% Q* N0 e" z9 i
% e& b9 s3 c( V1 K# G, Y+ ^</P>
$ w9 e6 A; @# S5 S% \3 ^. x- Z% K$ g< ><FONT color=#ff0000>函数名: ellipse </FONT>
1 U) a, M$ I- T6 u' p$ \4 u功 能: 画一椭圆 " H1 N2 ~$ b8 w4 C' C
用 法: void far ellipse(int x, int y, int stangle, int endangle,
' Q) Z! N3 h+ l+ M' P, h% \- uint xradius, int yradius); 2 a5 S( E5 K2 Z) c9 Y. g
程序例: </P>
& U1 c; r6 K8 r! L! j< ><FONT color=#0000ff>#include <GRAPHICS.H>
" H3 L' h) r2 s1 d; W6 k#include <STDLIB.H>
6 Z/ _3 \- ?; P, p. K2 Y/ {1 [#include <STDIO.H>! {: t% }+ Y6 X2 w# ]4 K6 ]8 t
#include <CONIO.H></FONT></P>
5 u% f2 z- V5 \' {" ^; |< ><FONT color=#0000ff>int main(void) ) f- W- g1 Q4 h
{
5 E" @6 K9 C* c: |% N8 P; b/* request auto detection */
0 p- q" W2 y; y) b7 H" Q& @6 jint gdriver = DETECT, gmode, errorcode; " ]# K; w: K, J" d& {3 N( }0 c* K; Q
int midx, midy; ' ~" C# i- c1 d% E) n- ^. A4 a
int stangle = 0, endangle = 360;
( Z: |# X1 r, L5 l9 Lint xradius = 100, yradius = 50; </FONT></P>
8 @# J, F3 g( {) W) C4 ?< ><FONT color=#0000ff>/* initialize graphics, local variables */ 5 m$ a9 M: [6 \3 _; q5 H% ^, b
initgraph(&gdriver, &gmode, ""); </FONT></P>1 ]* I _4 E2 D" G
< ><FONT color=#0000ff>/* read result of initialization */
% e) _" J; e7 a% c& s! Rerrorcode = graphresult(); . q5 F( F/ }6 x3 h
if (errorcode != grOk)
0 l, m9 o+ E2 A+ Q/* an error occurred */
$ c0 g, P- Z/ Y8 I) Z% A{ $ |* g7 D/ r" a8 y* l8 O) V
printf("Graphics error: %s\n", & D. }/ ^ ?2 Z0 ^
grapherrormsg(errorcode)); X0 \+ Y5 j+ A! i* f5 o# u8 k
printf(" ress any key to halt:"); 7 M' s- R, F* ?( \: V" B( `
getch(); , }2 G* A4 q+ @# H
exit(1);
* ?1 h, X+ @! w. {0 Y4 N/* terminate with an error code */ % l8 U) U5 B8 M) f1 X4 W
} </FONT></P>
7 `. @: [7 w' @/ ^+ U; C0 Y( L< ><FONT color=#0000ff>midx = getmaxx() / 2; 5 U2 g3 ?5 i! d- E; Q# a" ^, l
midy = getmaxy() / 2; % y& O6 F8 x) e+ a9 d* ~
setcolor(getmaxcolor()); </FONT></P>
0 L! D& T8 P3 W4 S4 M3 c< ><FONT color=#0000ff>/* draw ellipse */
1 k6 q1 S$ {1 oellipse(midx, midy, stangle, endangle,
0 ^3 u% r+ P8 L: W( Gxradius, yradius); </FONT></P>
- M& Z% K: I6 O2 Z& Q7 X8 ?< ><FONT color=#0000ff>/* clean up */ # i" {3 @$ v! n5 c: I
getch();
^' I) l; E3 X0 K8 K' L Oclosegraph();
8 ?* H! M& `* |6 W+ n- x9 W1 j( zreturn 0;
& i9 c4 h& o8 g0 X, l1 S0 N+ Z} </FONT>
- t2 [! v# U, W! m3 [6 I% x6 Z
$ {- |* r2 y/ p6 a! J. f5 J</P>
( E( ~+ R! ?* ^8 \8 k< ><FONT color=#ff0000>函数名: enable </FONT>, V& Y# b& k/ ^6 K& ~' D) j
功 能: 开放硬件中断 * I# c/ {+ z1 T+ D) U
用 法: void enable(void); , {+ @5 }' o. u8 Q* v
程序例: </P>
1 Q0 w6 \$ P* m% e1 P7 t< ><FONT color=#0000ff>/* ** NOTE:
, A* V/ k1 D: f+ P. FThis is an interrupt service routine. You can NOT compile this program ) ]3 f% Y7 @2 d
with Test Stack Overflow turned on and get an executable file which will 4 A4 o. Y- }* ~* n5 d
operate correctly.
6 `0 L2 o+ Y2 W0 v% R*/ </FONT></P>4 z7 Q$ Z+ e) E) {6 W* j0 M
< ><FONT color=#0000ff>#include <STDIO.H>4 _# W8 r. x$ ^0 q! O7 V- G: c H
#include <DOS.H>8 J& |, L; x5 F, E+ s0 c4 L# |/ |- b
#include <CONIO.H></FONT></P>8 @, P% ?& z( k6 L$ m8 N- c8 W
< ><FONT color=#0000ff>/* The clock tick interrupt */
5 t# Z5 H( `+ j/ S' z9 @/ ^3 l#define INTR 0X1C </FONT></P>: D5 I% G) V( M: j0 U
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>, C5 J) I- ~. L& D/ d( B( m6 o
< ><FONT color=#0000ff>int count=0; </FONT></P>% _2 W' j( Q; \; k w P
< ><FONT color=#0000ff>void interrupt handler(void)
@' N& J4 d) N7 [) Y: k7 r6 x{ 2 V5 x+ U4 w: D
/*
( b& \0 |# J& }9 Kdisable interrupts during the handling of the interrupt
: e5 Q/ ~/ v4 y9 R7 |- `7 D5 m& {*/
7 [ p0 a ^0 zdisable();
- p# j" S8 ?* U2 P! b8 l/* increase the global counter */
8 t. ?' I- |# g2 V- T/ `9 _count++;
3 [) ]! k, a; D* M& E8 T( K/* - b) E! X8 o1 x* g
re enable interrupts at the end of the handler 3 [, U& C' s5 z) K( H7 ~
*/
" P7 _/ ~8 y1 Penable();
& z6 j! l7 z6 ~4 O; s% I/* call the old routine */ 7 F- @' m4 S; S
oldhandler();
+ P: A. Q3 V# M} </FONT></P>
$ R0 c" V( ^6 G7 r$ a( H6 B< ><FONT color=#0000ff>int main(void)
$ n( N% P8 u! i/ }3 w" _{ " z. S( P' f6 z1 \
/* save the old interrupt vector */ - ^' u( L& Q$ `, @! \
oldhandler = getvect(INTR); </FONT></P>, L; }# J" p: H4 l
< ><FONT color=#0000ff>/* install the new interrupt handler */ 4 x9 q1 r0 ^$ d3 |( N6 R' \5 \0 J
setvect(INTR, handler); </FONT></P>
! H8 U/ z. a. o) X< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */ 9 c: E2 t. c Z! V- v$ U7 X9 T
while (count < 20) 7 a: v$ Y% `( {; i
printf("count is %d\n",count); </FONT></P>9 |3 a6 p5 D! F8 k
< ><FONT color=#0000ff>/* reset the old interrupt handler */
7 v! \9 W9 Z4 U+ y# p* ksetvect(INTR, oldhandler); </FONT></P>8 k6 c' S( G1 N1 n# z
< ><FONT color=#0000ff>return 0;
D& A& z6 B {# }} </FONT>8 `+ a6 @8 }! A9 M1 o' _5 @- b
8 q! w5 {, p5 d8 x( x. u
</P>
0 H7 l" P$ m" i" q5 _< ><FONT color=#ff0000>函数名: eof </FONT>
* P! M# v4 F. g0 |功 能: 检测文件结束 * w; I* d1 R0 X5 ~
用 法: int eof(int *handle); # E4 ?, e, t7 Z' q$ I5 d
程序例: </P>
5 t& y, e& _! d* h7 q6 b7 b<P><FONT color=#0000ff>#include <SYS\STAT.H>
8 R c% Q" c' q$ r3 V4 T' i4 w#include <STRING.H>
$ h8 `0 p2 w* {3 t#include <STDIO.H>8 Q5 W. C& E1 x$ S# o. U X1 y/ u
#include <FCNTL.H>
6 ?0 N9 d$ J2 K( W* g; x#include <IO.H></FONT></P>
9 W% n/ {' I% l' \<P><FONT color=#0000ff>int main(void) 9 j0 M" P! G& A6 a3 L
{ / A* B( A) N+ m$ S8 r9 J
int handle;
6 j$ F7 _. R& O1 k7 D3 j4 wchar msg[] = "This is a test";
2 K: `2 n1 `; z2 G* m8 r3 n# Ochar ch; </FONT></P>
$ l; W2 p; S5 s5 r* [/ \<P><FONT color=#0000ff>/* create a file */
. u9 q: h7 E& q+ g# ahandle = open("DUMMY.FIL",
$ c2 d! f# x, B* U' dO_CREAT | O_RDWR, + l/ z0 ^( V K& Z* f- f& N- Y
S_IREAD | S_IWRITE); </FONT></P>
' v' T6 `, P* N: p& D<P><FONT color=#0000ff>/* write some data to the file */ , S1 k$ f3 V" N! {, z0 ^; b
write(handle, msg, strlen(msg)); </FONT></P>
; }9 _4 F. m; d" V) ?9 e4 [<P><FONT color=#0000ff>/* seek to the beginning of the file */
2 Y1 ], ]0 @4 m: s+ Alseek(handle, 0L, SEEK_SET); </FONT></P>/ x# S: |# l# ]/ W/ v+ P8 `
<P><FONT color=#0000ff>/* / w5 [" w; s' `5 s7 ~( `7 o
reads chars from the file until hit EOF
0 y3 W7 E4 ^2 ]3 N6 F; N*/ 2 g6 I4 ]( A) V
do * |3 }1 ^: y# \! ]
{
7 F5 ~% O6 K& Z4 y7 _2 B% I9 C! Dread(handle, &ch, 1); ! t; z# l5 x! e# k d: i
printf("%c", ch); , m: V: L; `3 z% C' r% D
} while (!eof(handle)); </FONT></P>, n6 h2 M) t' w$ s8 o- T/ }4 s
<P><FONT color=#0000ff>close(handle);
) b, S! W! j% j* J. U% Creturn 0;
. r) p" L6 D6 S0 \& o6 U- a}
5 d1 ?# B1 }: U' y. r. O</FONT>
3 p3 o4 Q/ Y; a9 g& m6 r, a</P>( p5 ]( {4 | N9 X: F3 C8 o
<P><FONT color=#ff0000>函数名: exec... </FONT>
4 w. Y; H# c' z" W% {9 q/ N" m& o功 能: 装入并运行其它程序的函数
- L X/ x8 [, |9 v: E用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); : a' _8 \, Q; O! m
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
. V7 F1 l% ?5 p6 f, `char *envp[]);
4 S. f& e) L7 z7 [9 _int execlp(char *pathname, char *arg0, arg1, .., NULL);
* Y+ e2 D+ P$ h9 o6 fint execple(char *pathname, char *arg0, arg1, ..., NULL, ; U% }, i4 A$ \/ G/ e$ j
char *envp[]);
3 B- Y( p0 D. y9 h; I" p9 F8 fint execv(char *pathname, char *argv[]); 3 y1 z% y$ \* i+ Z7 _+ N
int execve(char *pathname, char *argv[], char *envp[]); 5 ^& k" M$ d1 \# P# d- H/ l" d
int execvp(char *pathname, char *argv[]); # L# [# D# G ^
int execvpe(char *pathname, char *argv[], char *envp[]); , v) \/ i! p: n9 I) P
程序例: </P>
1 x V+ `: M2 ^: U<P><FONT color=#0000ff>/* execv example */ 8 ]% v4 u' @! |" u: f- l. D, }' L
#include <PROCESS.H>
, \( S; H6 e0 W: A4 B#include <STDIO.H>
! x* F, Q \+ ^: j" l#include <ERRNO.H></FONT></P>; y+ i" A2 x8 X) h K" K& J6 ?
<P><FONT color=#0000ff>void main(int argc, char *argv[])
3 I8 Y# A$ ]2 T2 w( M# _8 [{
5 X7 X8 z, I4 }3 T5 Qint i; </FONT></P>
0 | N* y3 n2 Z. W( W+ b- o<P><FONT color=#0000ff>printf("Command line arguments:\n"); 1 w. ~4 C6 c1 x; M1 B1 X( E
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>. H; A/ ~) y+ e& y0 Y
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); & O, ^+ F! i0 I
execv("CHILD.EXE", argv); </FONT></P>
5 a' ]* @3 m% M3 E/ Z<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
6 }! z: k0 p3 `1 e l: g<P><FONT color=#0000ff>exit(1); o! U2 t2 \; _8 ^$ A# ]+ X
} + N% P8 h: z# e5 ?: _2 T S
</FONT>
% n! |, }9 ?, ^( M- u- Z5 g</P>
- g* j/ n4 l6 E8 n! Z<P><FONT color=#ff0000>函数名: exit </FONT>5 ~8 q. \+ G% [3 b4 T2 f# {" N0 r" k
功 能: 终止程序
) s3 w6 z x( A+ E z! ^' D用 法: void exit(int status);
$ R3 t% _: Y9 g9 H9 P- m+ D; g程序例: </P>
& ~. v# D* V' L5 x5 O/ W& ]<P><FONT color=#0000ff>#include <STDLIB.H>6 `1 g$ T" `, u3 N, X
#include <CONIO.H>
2 L' p8 r9 G8 c1 j#include <STDIO.H></FONT></P>
( \9 Y3 c# b& u/ b: s<P><FONT color=#0000ff>int main(void)
/ V# S# _/ p+ m- V& n7 R! W# R9 K{ * Y L: ]8 Z2 l5 E
int status; </FONT></P>
) A, C; Q- z% P<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
7 ~( J! Q8 R4 }5 y0 j9 Y f( k5 Qstatus = getch(); 3 A, @4 k, _/ N9 J0 _- q5 n
/* Sets DOS errorlevel */
) g: h T0 K( y5 [ u5 vexit(status - '0'); </FONT></P>
0 N" W. h5 p, x1 X2 d e<P><FONT color=#0000ff>/* Note: this line is never reached */ ) [" e; g' a6 |6 r9 V# q( C
return 0; ( F1 u+ g# p5 ^+ I3 o6 c e& Y
}
3 X2 c- i. F7 Y</FONT>; v- O/ F: ~) ~# n7 ^" H# ~! A
</P>: l4 H3 x h" r [# Z
<P><FONT color=#ff0000>函数名: exp </FONT>. Y; o6 z1 B, L8 X8 z
功 能: 指数函数
3 ?9 \8 m; p: f7 u3 t. Y; \用 法: double exp(double x);
, K# D: N8 I- G1 N8 f6 Y程序例: </P>$ o* P0 k/ z; K; k* p2 Z! r
<P><FONT color=#0000ff>#include <STDIO.H># m( u( s1 c# B9 \) v& b
#include <MATH.H></FONT></P>' w8 W5 P8 f2 Z- e& e; H F. W
<P><FONT color=#0000ff>int main(void)
$ U6 k U, V H{ ( u) X+ w+ X7 |: U9 S( O- ~+ i2 R! X" P
double result; 6 h9 L/ Z/ b M$ E- _% i
double x = 4.0; </FONT></P>
% V; ~; C; K8 Y t u2 s/ f<P><FONT color=#0000ff>result = exp(x); . e1 Q9 {$ f+ G" ]( o) ^7 l4 t
printf("'e' raised to the power \ " ]0 h5 W& S* C0 A" B/ H5 R6 {
of %lf (e ^ %lf) = %lf\n", + l Y6 X e9 X" K, U2 w
x, x, result); </FONT></P>" O( d' m' Z& Z3 }* }$ y
<P><FONT color=#0000ff>return 0; ! Z9 X" D& C- k
}
' g% B* g2 D/ A9 q# d: t. \5 E</FONT></P> |
zan
|