- 在线时间
- 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>0 m% r6 B) K8 R/ b0 ?6 ^
</P>
- B1 ~( x" S" ~ S" @- f$ D, r) F# @6 G$ }% d2 V) F
0 k" G; f8 b2 I' S+ r< ><FONT color=#ff0000>函数名: ecvt </FONT>
d8 A" b4 F, }. L, @4 ^) _功 能: 把一个浮点数转换为字符串 ( L1 f s0 v, p* h" v+ H W
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); ' F' [1 `% E5 @# t" m
程序例: </P>
" K% O) v6 F0 }< ><FONT color=#0000ff>#include <STDLIB.H>5 E/ V& v* L5 S6 _$ L
#include <STDIO.H>
0 Z1 L8 ]; D# ^+ H) D. i#include <CONIO.H></FONT></P>6 o: W1 J; B0 L$ _" Z: G
< ><FONT color=#0000ff>int main(void) * R& O% c3 X/ O" {- ]1 K
{ $ P1 y8 p9 Y3 l6 Z* Q# F
char *string;
, E, q( n2 R6 e: }double value; 6 A j+ z. ]1 x" Z
int dec, sign;
, ~( o% a3 L2 K/ r; P" H! ^ C! pint ndig = 10; </FONT></P>
. T3 v9 V$ u6 }< ><FONT color=#0000ff>clrscr(); 0 L* W- @' W' b: U! W- O1 w
value = 9.876; 4 o0 L- w8 j. q% z: d
string = ecvt(value, ndig, &dec, &sign); - \& _+ h0 ?. w1 V; q: e+ K$ T+ K
printf("string = %s dec = %d \
2 ], g% Y- ~( C6 i5 M2 t$ n1 Lsign = %d\n", string, dec, sign); </FONT></P>7 l' U; n3 |6 m7 A
< ><FONT color=#0000ff>value = -123.45; ) ?: W/ w% A3 W* z( s% q
ndig= 15;
+ _2 u+ e8 G* O' |string = ecvt(value,ndig,&dec,&sign);
" |7 k4 f$ J0 k: mprintf("string = %s dec = %d sign = %d\n",
, Y) J [6 Z- K% D1 n) V5 H- Xstring, dec, sign); * B; Y0 Q N( ~
</FONT></P>& `3 @# Y2 a) c3 R3 }) B
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
9 @5 \) b5 W% w/ \4 Z0 @notation */
% |- v, H# ~4 m6 s. q7 j# m, Q. Qndig = 5; # T k) I0 h V7 _' W
string = ecvt(value,ndig,&dec,&sign);
; c; C: ~) h4 r3 t: Y* L$ M% wprintf("string = %s dec = %d\
3 C: x' l5 F Q1 @sign = %d\n", string, dec, sign); </FONT></P>
0 C% b6 a7 A4 ?# v- |< ><FONT color=#0000ff>return 0; $ R! P/ @2 B3 t7 R2 |, T1 Z7 r/ D
} </FONT>& i9 h8 p$ i0 S$ e: |- z. I4 Q
3 s9 k% B* | N0 S( x8 Y+ K% f6 H# `* H
</P>
) H6 `0 C0 ?) u6 k< ><FONT color=#ff0000>函数名: ellipse </FONT>. B3 b p# t5 q6 R0 ^5 c8 W
功 能: 画一椭圆
) ^2 z$ O6 M. \9 c$ R用 法: void far ellipse(int x, int y, int stangle, int endangle,
4 V I3 [3 Q- `: ~) n) nint xradius, int yradius); $ }8 P; M3 q, g& Z6 t
程序例: </P>
: b8 @ o5 Y( \2 G< ><FONT color=#0000ff>#include <GRAPHICS.H>
4 p# Z4 q1 M3 N#include <STDLIB.H>
! {1 N. o+ F) I. D. ?#include <STDIO.H>
/ G' A5 S3 K$ D$ ?3 i9 d#include <CONIO.H></FONT></P>
# y5 d- b# I* y< ><FONT color=#0000ff>int main(void) 8 E3 Z* Q% c, V O2 H/ n
{ , ?; r* w4 m9 {5 R
/* request auto detection */
) n$ E) s! X/ Y8 Y4 j: F: O7 [int gdriver = DETECT, gmode, errorcode; & F# z5 l0 C" Z1 `
int midx, midy; $ J, r5 y' \ a; L1 U0 I6 X' p
int stangle = 0, endangle = 360; ! I0 F" k0 Z) U( O8 U
int xradius = 100, yradius = 50; </FONT></P>' `# f& Y9 A$ J$ [9 p
< ><FONT color=#0000ff>/* initialize graphics, local variables */ # C% y G" F( T) z9 c5 N
initgraph(&gdriver, &gmode, ""); </FONT></P>6 T% P L( B5 K' ^& ]5 c/ X4 P3 k
< ><FONT color=#0000ff>/* read result of initialization */ ( M% z* t7 g' {& ~: w- h( y
errorcode = graphresult(); ( Q: _6 S g' c) ]; R
if (errorcode != grOk) ' I+ H% F+ o+ U- ~9 J+ c
/* an error occurred */ / B" X/ `/ M- j0 C3 i# x7 E+ r( Y
{
$ ]$ r* G& `5 z! hprintf("Graphics error: %s\n",
" e8 j7 z4 z* q& P* O6 X4 dgrapherrormsg(errorcode)); o, J, ^9 ]) `9 B' L% |7 u4 ~
printf(" ress any key to halt:"); 1 v" V: G: a' v+ m( l5 q
getch();
& R1 W1 V9 S: L6 Kexit(1); . \# r, C, G& p* \
/* terminate with an error code */
. [ H) n" ^7 E$ R7 U. R& V} </FONT></P>
$ v' B+ K: ]+ ?; t< ><FONT color=#0000ff>midx = getmaxx() / 2;
1 X* k5 m7 i) \" G% A& omidy = getmaxy() / 2; 7 c6 B- N6 {2 ~# |- G0 p5 m
setcolor(getmaxcolor()); </FONT></P>
$ A( \# t5 L& f+ e4 i. [' i b) ~$ ^2 A< ><FONT color=#0000ff>/* draw ellipse */ & }# R% g. @+ C& _3 A9 Q* C
ellipse(midx, midy, stangle, endangle, 4 F6 n. X# z4 E, f; O
xradius, yradius); </FONT></P>! t" o5 G- |$ r. @- b
< ><FONT color=#0000ff>/* clean up */
% e ?7 _3 p, W. l' s" cgetch(); : \; [$ ~5 Y: R# x" r/ [
closegraph(); 3 B% }5 i" f( r3 d; X! R
return 0; + T: c' U5 ?' Y* @4 k a: D
} </FONT>
. i4 Z6 Z# k2 g" _% w/ A+ c/ ]; h, y! ~3 V+ x: [0 B
</P>
2 e+ u' }. v; R8 y- e< ><FONT color=#ff0000>函数名: enable </FONT>( F5 E+ a% ]8 J: B' W+ O
功 能: 开放硬件中断 7 `$ H, f0 u" {8 V2 \
用 法: void enable(void);
9 G! d% r4 S- b7 m" G程序例: </P>* t. I1 d7 Q2 z4 ^$ u+ X6 z. r- b
< ><FONT color=#0000ff>/* ** NOTE:
; e, b& h1 z! g8 n% TThis is an interrupt service routine. You can NOT compile this program , Q* p* e( z! ]* I* r) ]# U
with Test Stack Overflow turned on and get an executable file which will
" D4 I- L7 _" T9 D' }9 n' Toperate correctly. ( T% x$ v' p! D. Z+ a
*/ </FONT></P>
0 _; ?+ L& t( R6 D i+ q# A< ><FONT color=#0000ff>#include <STDIO.H>) B/ ?+ {( D3 K; N$ o' R
#include <DOS.H>9 m) Z3 P1 |: k1 }6 f
#include <CONIO.H></FONT></P>
6 Q5 R5 i+ @4 D0 n+ c0 V; w< ><FONT color=#0000ff>/* The clock tick interrupt */ ; S5 l' m5 x3 b! X* o6 u
#define INTR 0X1C </FONT></P>, h" i" Q( K, e2 t* R: ^2 G& R
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>+ o, v) d: [/ T
< ><FONT color=#0000ff>int count=0; </FONT></P>2 r" c. G5 g ~4 f6 I7 I
< ><FONT color=#0000ff>void interrupt handler(void) 1 ]8 i& I5 {; ^+ U, N8 D6 m2 \
{
% N. O. E! L9 A* s$ o7 w3 b$ O% r/*
' a Y- |/ N d/ ? E; T7 T" c8 Udisable interrupts during the handling of the interrupt u) K' _ }$ D! l' U2 ]
*/ : g. b& A7 m5 @) S
disable(); 1 k' \& z0 f* g8 k8 c3 N
/* increase the global counter */
' ?3 \% s8 g0 ]6 W) H+ d9 Acount++;
" k2 `8 }( x- P/* 4 Z+ ?+ H- q) r$ [: m
re enable interrupts at the end of the handler 9 p; g1 B& O% x
*/
" F& a1 o. B ?$ w$ Nenable();
; x# v- T( u% H+ Q% ~. X( g/* call the old routine */ & ~; P8 }( r0 N9 T: Q
oldhandler(); 2 A1 u8 l& M$ k% _/ L* l
} </FONT></P>
9 ` c0 [8 n1 b5 e6 `* c; S) u6 t& \< ><FONT color=#0000ff>int main(void) 6 X3 g5 M& H: L9 `' V9 g: W
{
( s/ k% ~3 @, b/* save the old interrupt vector */ ; H% ?7 t- L6 ]3 z9 U
oldhandler = getvect(INTR); </FONT></P>" b$ X5 g6 L1 ^7 [% D
< ><FONT color=#0000ff>/* install the new interrupt handler */ 7 l4 \2 S1 T2 o
setvect(INTR, handler); </FONT></P>
* N- y: b+ m3 \8 m) U7 p; Q< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */ 3 p9 V2 z) c/ q' M5 S
while (count < 20)
2 p( g# `9 o8 O% U7 ]; D1 g. J* Q; B7 jprintf("count is %d\n",count); </FONT></P>% f' f4 i2 t* n; @# l: Y: c1 n
< ><FONT color=#0000ff>/* reset the old interrupt handler */ 1 O/ d J' S% J8 J' h2 ?
setvect(INTR, oldhandler); </FONT></P>7 c. p2 `* m7 L7 m N- n5 |* M
< ><FONT color=#0000ff>return 0; 7 ?, E3 k2 D+ k# j. L9 Q0 h
} </FONT>
, U1 r: Q4 L% F% Z) P# O3 @: K
8 u) A q$ O# k6 C1 f8 t a6 [</P>
2 y" r0 d0 y6 z# @1 Z4 D< ><FONT color=#ff0000>函数名: eof </FONT>2 ?6 `# C7 W4 M7 K
功 能: 检测文件结束
" L! A o7 \3 N4 u用 法: int eof(int *handle);
% _8 e5 L8 b) A' X/ t9 F程序例: </P>9 _5 `# x1 i# W' ]
<P><FONT color=#0000ff>#include <SYS\STAT.H>: p5 {/ V7 {$ P3 G" {2 ^: T& O2 m* ^
#include <STRING.H>5 B$ z7 h7 c- R6 R' N
#include <STDIO.H>
* o& a, c( B/ Y$ n( |* K; T#include <FCNTL.H>
- B$ k) Z% V+ R v7 ]3 \#include <IO.H></FONT></P>' Q# P& h$ ]' n
<P><FONT color=#0000ff>int main(void) 3 E; z/ ~6 r, N* Q( u9 `) v1 b
{
$ ?: o9 u; H/ _0 I- i! }, `8 yint handle; ( N. L$ y: C" s! R. O& H/ c. ]
char msg[] = "This is a test"; 7 w; `4 Y6 p2 D% p: Z0 K9 [
char ch; </FONT></P>
$ R7 w3 r. g+ s& d<P><FONT color=#0000ff>/* create a file */
. p! h+ E2 c) j: U1 W/ `+ G e. chandle = open("DUMMY.FIL", j, d* o- ~3 }$ m0 S
O_CREAT | O_RDWR,
3 L$ L/ K7 W, f+ T8 US_IREAD | S_IWRITE); </FONT></P>
4 x) E7 z- E2 A2 i4 V( @<P><FONT color=#0000ff>/* write some data to the file */ * {% Z2 J( m& L" g) |% d6 B
write(handle, msg, strlen(msg)); </FONT></P>
+ D9 [, E9 b! S) @+ `5 [<P><FONT color=#0000ff>/* seek to the beginning of the file */
4 R* I' e; t0 ?4 z! B" E, H3 Y: ilseek(handle, 0L, SEEK_SET); </FONT></P>
- U9 _$ k# l! W! |9 A<P><FONT color=#0000ff>/* % |7 u. u; J% S( O3 l9 l- M
reads chars from the file until hit EOF
9 k6 E) N6 F8 m*/
, k; N, M$ P0 V# T: ^# E7 ldo ( O3 K% X' P+ y4 t
{ & f- o3 d+ O. W9 O" A
read(handle, &ch, 1); - J- L& L2 V% w
printf("%c", ch); * _+ o" V" J( N% V. s; v+ ~
} while (!eof(handle)); </FONT></P>
* ?% D; x6 m, I<P><FONT color=#0000ff>close(handle);
) d; Q5 _0 k% i3 h6 R& p1 Preturn 0; * C8 E" q7 L, x, K/ O- ?& ~2 |
} : a$ `$ s6 H* m: b
</FONT>
1 a; n& |; m& g/ d</P>- q! o- G* G7 f% K9 I" J0 k" W
<P><FONT color=#ff0000>函数名: exec... </FONT>
7 g2 R) T! A8 B! g, ?功 能: 装入并运行其它程序的函数 0 w& e5 ?7 O, ~; d# V4 B
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
- U% I. A3 j' M7 G2 I9 Nint execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
4 U! d6 E5 N+ Y1 u" Mchar *envp[]); 0 }' d) f8 A' z( j
int execlp(char *pathname, char *arg0, arg1, .., NULL); - x. A/ ~1 u2 X" V9 R
int execple(char *pathname, char *arg0, arg1, ..., NULL,
7 U9 J' y9 ]& v, k7 l. A- {char *envp[]);
3 T( D4 A3 d" f0 ~4 b4 ?int execv(char *pathname, char *argv[]);
" p K0 Q/ q; W- f3 ]1 [" P* sint execve(char *pathname, char *argv[], char *envp[]);
: m) j$ o9 Q0 ^int execvp(char *pathname, char *argv[]); 9 D2 u/ ]$ D. N, ^/ J2 L* I3 X
int execvpe(char *pathname, char *argv[], char *envp[]);
4 X3 l: o# I4 {程序例: </P>
3 o" j7 Y; b! m" S5 R( y" v<P><FONT color=#0000ff>/* execv example */ + i4 d" m- ^5 S* ]. p/ w5 k5 b
#include <PROCESS.H>
# M2 n; a3 @9 S3 Y1 r6 V#include <STDIO.H>3 |* q: E! b. U
#include <ERRNO.H></FONT></P>
2 p' p( J2 ^2 u! R2 o/ ^2 {<P><FONT color=#0000ff>void main(int argc, char *argv[]) $ m9 i( n7 j, ~( G( k% n6 Z
{ 6 D3 F+ V' y! j
int i; </FONT></P>+ N' a+ }9 }3 t5 i. a/ x
<P><FONT color=#0000ff>printf("Command line arguments:\n");
. Q5 _, S. x. W3 L; [+ Z8 kfor (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>- l5 j7 B2 v- { z# I9 K8 P8 T
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); 8 `/ Z( H8 q. U9 a$ h9 l
execv("CHILD.EXE", argv); </FONT></P>
* b6 I7 r: P" d<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
5 p0 z3 d6 j4 l<P><FONT color=#0000ff>exit(1);
- d S: i! x. g. ~* i} 5 _+ s& N; K% E
</FONT>
1 I2 n; P/ j3 K# \/ ~</P>
+ Q! l# D+ s2 S$ ?0 W" y4 N1 m' t* E<P><FONT color=#ff0000>函数名: exit </FONT>
7 H; P4 ]* F: v8 {2 r7 }功 能: 终止程序
; |4 c8 c- r5 l: p用 法: void exit(int status);
1 n/ b6 }, C" |: p0 q! v% S% q程序例: </P>
. M: \4 u( _$ v" E6 f+ u<P><FONT color=#0000ff>#include <STDLIB.H>
/ ^1 Q+ _3 }) h5 D3 V0 d: c5 r#include <CONIO.H>) g& o8 S- \1 A8 j' v" Y5 j
#include <STDIO.H></FONT></P>& h( [* |. @1 V9 b9 F
<P><FONT color=#0000ff>int main(void) $ I: s0 s9 Z' i% d' M, Y/ N
{
; [7 R. }4 \. _: aint status; </FONT></P>" L9 B+ j/ ]9 `! M" E
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n");
! Q. {9 \+ n i! Vstatus = getch(); $ r8 e7 z3 ]8 F" W" g/ m; _
/* Sets DOS errorlevel */
! S7 F- ^7 g( {exit(status - '0'); </FONT></P>) w/ K# |) G# s! K
<P><FONT color=#0000ff>/* Note: this line is never reached */
$ B0 J( {/ z$ {) L4 Zreturn 0;
! p: B% E7 {- V# N% O R( f) {! J}
^7 |# }: d0 D |, a: W# Q& a</FONT>! m; W) l y* ?, j9 F
</P>
) {! Z1 |, [8 H! ?$ m: X. m<P><FONT color=#ff0000>函数名: exp </FONT>
[4 W5 v" e6 f/ \功 能: 指数函数
' l+ v4 a3 o) E# r. @用 法: double exp(double x);
# x& J* ?5 p' W. I @0 ~% U1 `程序例: </P>
4 i1 Y% x4 r% P$ ]% U<P><FONT color=#0000ff>#include <STDIO.H>0 p2 I( T( G6 ^
#include <MATH.H></FONT></P>! k0 a9 n- n$ O, ?
<P><FONT color=#0000ff>int main(void)
6 B; {& t+ Z8 V, i, L# p, ]{ 9 P7 N, F2 J3 N4 y& N
double result; 6 z- W ?3 N) O- ^2 l
double x = 4.0; </FONT></P>% k) G$ X* |( G7 `2 G: ^. z% v0 p
<P><FONT color=#0000ff>result = exp(x);
% n3 e. k6 E9 e6 C* \printf("'e' raised to the power \ 5 j! v( W! ^$ i. }/ |2 H
of %lf (e ^ %lf) = %lf\n", 6 T E2 q+ o) }2 m8 z% t
x, x, result); </FONT></P>
* ^ w4 u7 y& y# Q6 _1 h<P><FONT color=#0000ff>return 0;
4 m* \; w% h$ l& Q4 D7 [}
9 R$ m* ]$ }/ }; s1 S% i</FONT></P> |
zan
|