- 在线时间
- 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>1 Q; u( n* V8 [9 e
</P>
& k: b# j z6 P5 _! `/ ^/ d2 _! d- V" u
& V' C; a2 ^ H# ~/ f0 C2 q& r5 i# r< ><FONT color=#ff0000>函数名: ecvt </FONT># K. I* f7 b/ W7 v A7 w7 Q% d
功 能: 把一个浮点数转换为字符串
& O j: ?2 Y; k% Q用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
1 F% K% l0 j: y/ h' p程序例: </P>9 p, D7 d1 ^, g1 X0 ]) W
< ><FONT color=#0000ff>#include <STDLIB.H>
7 A, Y3 L) b4 Q6 i#include <STDIO.H>( Y& _& X% c$ J+ g, v
#include <CONIO.H></FONT></P>
4 r# g% o$ i5 R/ F: @7 q1 {< ><FONT color=#0000ff>int main(void)
5 \: J% q) I* W6 Y" D- |7 N7 n{
+ W1 K, q! C8 K6 A+ Ochar *string;
* o8 v2 h5 J' Z8 P& v8 [double value; / m" _* E3 I$ |
int dec, sign;
8 i& ~ `1 T+ A' yint ndig = 10; </FONT></P>" N: z7 }/ f# `
< ><FONT color=#0000ff>clrscr();
7 J% g- W- M B5 w% y- R& jvalue = 9.876;
4 b( I" z( N3 A' `string = ecvt(value, ndig, &dec, &sign);
+ e# @7 h# C0 P* Mprintf("string = %s dec = %d \
3 U* R% z$ G9 ^' U9 ~1 Zsign = %d\n", string, dec, sign); </FONT></P>! ~8 ~) f2 c5 \) h- i
< ><FONT color=#0000ff>value = -123.45;
0 r& }2 p1 W7 Y, k+ rndig= 15;
; S9 G2 |9 L) Estring = ecvt(value,ndig,&dec,&sign); + j& S6 S' p- l7 h/ x
printf("string = %s dec = %d sign = %d\n", O7 x, e! x: Q( R3 e& w* W
string, dec, sign);
2 M# o7 w4 z, I$ Y</FONT></P>5 N& D& K6 q+ y! S/ J) q
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific ) m! G* c7 A( ^
notation */
) p0 z& u% h( l9 |- E4 l7 P' _0 ?" ]ndig = 5;
! X) H0 Y7 a- }, X# hstring = ecvt(value,ndig,&dec,&sign);
2 c3 e, E, V7 z% \# |+ Bprintf("string = %s dec = %d\
2 m' _0 }! P7 |+ c& ~; Isign = %d\n", string, dec, sign); </FONT></P>6 v; g, p/ B) K9 o! K' V# Y
< ><FONT color=#0000ff>return 0; . |2 r& h( m; B+ R5 E
} </FONT>! P4 b3 B# w8 f8 P
9 o" v! F% ]5 B6 i5 I</P>8 i& X4 v; g1 f$ a$ {
< ><FONT color=#ff0000>函数名: ellipse </FONT>2 E/ b8 @1 E; K" ^8 Y! }
功 能: 画一椭圆
/ `6 x% s8 p' M5 f% G用 法: void far ellipse(int x, int y, int stangle, int endangle,
, m8 z7 n& `/ R! z! W! rint xradius, int yradius); % Z0 G0 N* W' {' }: @: ^3 N" Z! c
程序例: </P>" P8 L7 Y( H. F
< ><FONT color=#0000ff>#include <GRAPHICS.H>8 Z! g6 I8 S) Y. d
#include <STDLIB.H>
$ W0 c* l/ h& U; d( X* I#include <STDIO.H>% Z) f: G6 h9 ?
#include <CONIO.H></FONT></P>( }' o2 j3 i- `4 R1 j0 M- t
< ><FONT color=#0000ff>int main(void)
+ i. Z4 e6 v$ B* [0 G{ " H! D) _7 \! n/ \$ U
/* request auto detection */
! a+ Q3 p) s, ]1 {! \9 Y2 ]int gdriver = DETECT, gmode, errorcode;
: `) R9 O9 L2 v7 o8 nint midx, midy; - z) a& p; Z, U w' A
int stangle = 0, endangle = 360; $ e% |0 C% E. O) _5 l) l
int xradius = 100, yradius = 50; </FONT></P>
" O/ ?+ v+ `6 r/ W N/ {< ><FONT color=#0000ff>/* initialize graphics, local variables */
7 w- F2 v8 E# O) ~: cinitgraph(&gdriver, &gmode, ""); </FONT></P>
" \1 }3 v+ R% \( ~8 v- J: a< ><FONT color=#0000ff>/* read result of initialization */
4 U% N6 C2 o, C6 Nerrorcode = graphresult(); 7 c( n( h3 g7 f' ]- G
if (errorcode != grOk) 8 y4 v, V" R5 M* L0 ~1 W5 o1 f3 X
/* an error occurred */
9 g( E2 y) ^/ v9 L5 I3 N% z{
( V+ B: R6 U+ J% P5 xprintf("Graphics error: %s\n", 9 z( D8 P) z; {' t! ]7 o8 B, Z
grapherrormsg(errorcode)); + \% O$ D# I5 j& C8 A! b
printf(" ress any key to halt:");
N+ S3 K0 m& d/ cgetch();
3 j- d0 U4 a, l; W$ v; Eexit(1); % C& ~& z5 q1 H4 ~' \- V, B
/* terminate with an error code */
: m( v9 T# t; t+ t! U1 }( y} </FONT></P>: |1 w1 A# b9 w) J7 |: d3 e7 N
< ><FONT color=#0000ff>midx = getmaxx() / 2; W8 e/ _% Q8 F) W6 B
midy = getmaxy() / 2;
0 _. I/ t" B- H- u* _* u2 Vsetcolor(getmaxcolor()); </FONT></P>% |% z) T) z- H( {7 u0 @+ ]
< ><FONT color=#0000ff>/* draw ellipse */ % D$ Q# ]+ R" \2 _" Y
ellipse(midx, midy, stangle, endangle, ) H$ L. P9 k7 z& K
xradius, yradius); </FONT></P>1 \* e1 [( ^# X9 m
< ><FONT color=#0000ff>/* clean up */ 3 V* V8 ~& o5 _; ~
getch();
, F5 \& c4 {1 R4 a7 t/ fclosegraph();
% F$ G; {. W; E' i& Treturn 0;
2 ]; q/ ^1 O, a8 {) P- h) x! l j} </FONT>5 x& Z5 F3 T* w5 E- u8 R
8 v+ V+ G7 X0 ? K3 E( H
</P>/ ?3 h( ]/ |. d& U: g6 c* F1 [% |
< ><FONT color=#ff0000>函数名: enable </FONT>
8 j8 f1 D. ^4 w( K/ |功 能: 开放硬件中断
; B* _8 k# S- c& j) z用 法: void enable(void);
* m6 H% ]5 T3 Q3 e程序例: </P>0 M1 I, X8 l Y; ]* }$ ?$ }# T
< ><FONT color=#0000ff>/* ** NOTE: 6 ]4 N* r# o* C; b9 }
This is an interrupt service routine. You can NOT compile this program
0 h/ G8 w" u- T4 E% U1 {with Test Stack Overflow turned on and get an executable file which will
4 y9 k" v k/ I6 C2 F5 a4 Noperate correctly.
5 D2 W u. w& [% z+ v*/ </FONT></P>2 W" v$ K9 p" A5 T9 z
< ><FONT color=#0000ff>#include <STDIO.H>) @% S2 q4 S+ } N' f) U
#include <DOS.H>
( N. `+ |4 L) ]4 E# A- z- |#include <CONIO.H></FONT></P>! R; Y E5 c& q- O7 N2 o5 t
< ><FONT color=#0000ff>/* The clock tick interrupt */
# T) O4 [( R! ?#define INTR 0X1C </FONT></P>- k9 M7 q) _8 P' h2 q) z
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>
8 D/ G Y4 K9 j3 O9 i7 r* m< ><FONT color=#0000ff>int count=0; </FONT></P>
" {/ |* ^1 Q# ~( `< ><FONT color=#0000ff>void interrupt handler(void)
7 W' h+ V7 |1 b{
1 x2 s9 z9 L) v8 w; ?/* 7 `7 z/ G% L- M* P6 W" W/ M. s
disable interrupts during the handling of the interrupt
) ^$ }8 p; x) b0 }! y*/
0 P. u. n! b9 P3 u& hdisable(); 6 z* ^$ v/ w- A# X% Z0 F
/* increase the global counter */ ( ?" O. }( g& x; M% T# L# c
count++; ) t1 q) j: `! ^5 N3 w* S
/*
3 }6 k4 W8 M8 z K, P/ dre enable interrupts at the end of the handler 9 u: y# v( j. Q! o* [
*/
* t+ b1 x7 d7 m( s- F2 G5 menable(); ! Z) M2 W" ]5 H6 l7 U' f
/* call the old routine */ : D% K) J& `* L+ D" L+ O2 Z
oldhandler(); ; T% G, t5 L( D1 d
} </FONT></P>. L! ]5 t5 P7 D0 u' Q3 y
< ><FONT color=#0000ff>int main(void) 7 U( L9 j1 }0 Z* E
{
' k+ J# u# c" e; \/* save the old interrupt vector */
. V/ _8 j: t: M/ Aoldhandler = getvect(INTR); </FONT></P>. G9 _. S: Q! Y2 s
< ><FONT color=#0000ff>/* install the new interrupt handler */ ' {& c8 a) q' ~5 u: g) x
setvect(INTR, handler); </FONT></P>
! _2 W5 {$ d; u8 S. n1 }) v! o< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
& h$ {" w4 Y& {% h+ m. v' Kwhile (count < 20)
+ _' N! I/ I! ~( iprintf("count is %d\n",count); </FONT></P>
; A9 z8 t' x# G* ? d< ><FONT color=#0000ff>/* reset the old interrupt handler */
1 \4 M& ?8 y6 n( t% S+ Nsetvect(INTR, oldhandler); </FONT></P>
1 ?. H4 a7 m! g( G9 l< ><FONT color=#0000ff>return 0; 3 d# d1 a- J! j5 v: s" l
} </FONT>9 }$ z& ]. ^' a1 s; Q
( R" v( M8 z. `
</P>5 O% e1 i) q6 T& C/ e7 y! C. I& `) H
< ><FONT color=#ff0000>函数名: eof </FONT>. X$ R6 z$ s5 l1 R' o& M
功 能: 检测文件结束 6 Z, y: \& Z# N$ W. Z! s; p0 g
用 法: int eof(int *handle);
1 L }: [: ?8 x2 i程序例: </P>; C3 v8 g7 `, o8 h, l
<P><FONT color=#0000ff>#include <SYS\STAT.H>
6 d* c% d _/ w" K0 u/ N8 e#include <STRING.H># U9 Z0 [# i4 e y8 J( \+ C
#include <STDIO.H>7 p3 z! R1 `+ S: ?. ~
#include <FCNTL.H>
/ \3 \" R. Q' {4 h: Q#include <IO.H></FONT></P> r4 r: @3 K: Q3 b S
<P><FONT color=#0000ff>int main(void)
9 G$ J& P" P$ K$ o{
b9 G7 R- O, V3 M! l- uint handle;
4 |4 }( A0 D9 T( }4 u- Fchar msg[] = "This is a test"; . l$ a, A" ]; K+ W0 A. K$ @
char ch; </FONT></P>
5 r# `& K7 t3 k2 L<P><FONT color=#0000ff>/* create a file */ ' | k' I. s: ?2 v$ d5 Z$ G% B6 g \4 ]
handle = open("DUMMY.FIL", ! }4 p8 O3 R) M. [9 C
O_CREAT | O_RDWR, ; p# M2 I) {1 k9 k/ J# B2 E! [) o7 C9 t
S_IREAD | S_IWRITE); </FONT></P>/ s' C8 p1 d- M" `7 ^* j3 }
<P><FONT color=#0000ff>/* write some data to the file */ " J+ N% H$ G1 X& S7 g1 l ~3 p/ O
write(handle, msg, strlen(msg)); </FONT></P>( r$ l _( g h: ^9 b* d! T& F$ Y
<P><FONT color=#0000ff>/* seek to the beginning of the file */
# X5 B( D: b+ }' e$ H9 Y1 z" N7 Nlseek(handle, 0L, SEEK_SET); </FONT></P>
6 ~4 t3 b; F0 O0 r; x<P><FONT color=#0000ff>/* ( Y& w; B: z( c- ]
reads chars from the file until hit EOF # d2 g& s$ a1 {
*/
; z3 {5 N- E% [$ G! Kdo
: A% O, R( u" o8 s{ 4 E+ ^7 b8 n- _
read(handle, &ch, 1); $ a( O$ S6 n+ L5 n$ A: H% i
printf("%c", ch); 4 n( K Y* d* R4 @; o( s
} while (!eof(handle)); </FONT></P>/ ]8 M% q' P2 J% K! q7 f9 x) F6 \* @1 J
<P><FONT color=#0000ff>close(handle);
& r* h8 b2 w; B' S" s7 F2 Q& nreturn 0;
$ u& h0 O" s: T}
% d$ ~9 R1 Q9 ]; y8 I</FONT>
4 I [' V6 ~1 b</P>
0 n* w3 I) q- z" ?<P><FONT color=#ff0000>函数名: exec... </FONT>( m( d! y5 z" U7 F& q) }, y
功 能: 装入并运行其它程序的函数
: a( r2 ^" R6 u! a6 a用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
: H! S7 H7 @& m/ I i' Rint execle(char *pathname, char *arg0, arg1, ..., argn, NULL, " C! [$ S0 X% l$ h! P1 l! P
char *envp[]); 3 [$ c- s8 x1 d M/ G
int execlp(char *pathname, char *arg0, arg1, .., NULL);
+ c3 e7 C2 A2 m0 a; M% iint execple(char *pathname, char *arg0, arg1, ..., NULL,
/ d4 B" x7 Z5 V& U, Y' {char *envp[]);
: Z) d. _% e' c vint execv(char *pathname, char *argv[]); % `$ J( |( M; u7 o2 X
int execve(char *pathname, char *argv[], char *envp[]);
0 y$ M+ B# w/ Lint execvp(char *pathname, char *argv[]); ' ^% R2 C* Y* V7 o2 i# N3 a
int execvpe(char *pathname, char *argv[], char *envp[]);
. S) n) p1 E2 I( c b" H: }( {程序例: </P>
& U8 i# Q1 d9 M" t( [<P><FONT color=#0000ff>/* execv example */ 5 @* z% |( }; p9 o( X/ ~
#include <PROCESS.H>
' w0 V1 V' N f, Y1 e7 H#include <STDIO.H>, x \" o- ?- p" S* s
#include <ERRNO.H></FONT></P>% m, x0 J% e7 l4 J1 M! J. H& V6 A
<P><FONT color=#0000ff>void main(int argc, char *argv[]) 7 A3 q9 |! S4 U- L. o* k! P. R
{ & R2 h, @: _1 L+ E N. r' F
int i; </FONT></P>' O7 P" e1 l8 L3 k% C3 k; n* _
<P><FONT color=#0000ff>printf("Command line arguments:\n");
1 O0 a' I2 F) V1 j/ c# {$ zfor (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>8 c- h! L! l; H% T% a1 D
<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); $ H" D+ L; W0 R0 k; w# k
execv("CHILD.EXE", argv); </FONT></P>- D& J1 }* g: a: H$ p% Y! j
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>- B4 |* W( }8 m4 j6 S
<P><FONT color=#0000ff>exit(1); - F0 ]6 h6 q3 s: n6 v" e) Q2 C
}
7 `2 i; [0 W8 M e' Z6 o+ f</FONT>& y+ g+ o* n" r" l5 l
</P>( {! n: |) Q6 r4 a- I# k T
<P><FONT color=#ff0000>函数名: exit </FONT>- A, [$ D0 b/ D+ ~: P
功 能: 终止程序
& w8 V/ ~# F) b8 X5 d" K0 x- T& L& I用 法: void exit(int status);
8 O T2 R# M }) ]+ @7 k) F程序例: </P>
+ ]4 Q; j+ j# j1 m9 @) Y1 @' i<P><FONT color=#0000ff>#include <STDLIB.H>% `- s4 b0 Q6 {% R2 z- a
#include <CONIO.H> b8 g I5 y( q w5 @* j
#include <STDIO.H></FONT></P>
% g9 |6 E7 X6 K7 B# F6 Y% l<P><FONT color=#0000ff>int main(void) 6 @& y y* }1 K, e! B5 t6 q
{
7 v0 d6 M0 |2 C4 Wint status; </FONT></P>
- z1 B4 u0 Q \( m9 r$ W<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); " y$ |1 E% l+ @- f$ B+ ?2 {5 @
status = getch();
/ w9 L2 G- |" \! D3 r/* Sets DOS errorlevel */
2 b2 e0 K7 |: f' Z; x! M1 _4 Oexit(status - '0'); </FONT></P>
! _! U$ w: P1 |- t2 h2 C l<P><FONT color=#0000ff>/* Note: this line is never reached */
3 Y, g, r' t3 B3 ~+ s$ d# ~0 Preturn 0; 2 p. f0 N9 L- H8 a4 I; [+ G
}
- z* T2 r9 d, Q) f3 I1 V' M# v6 `</FONT>( f6 C. w" G1 i* {8 a1 ^. }
</P>
% L: l2 |0 Y" I2 V: r- E<P><FONT color=#ff0000>函数名: exp </FONT>7 g% `) t/ ]+ q6 v4 |- L
功 能: 指数函数 3 E1 q( r# `4 K
用 法: double exp(double x);
) u! s( N( U# S程序例: </P>) k& R) T4 X7 s. R" k5 I ~* q
<P><FONT color=#0000ff>#include <STDIO.H>7 C& x% g+ v/ ?5 n6 e
#include <MATH.H></FONT></P>
+ l E9 N1 o1 K# w8 V<P><FONT color=#0000ff>int main(void) % u( H! D/ |* ] v9 U6 f$ v6 o
{
" z8 D6 L' O" _3 r; H7 kdouble result;
5 G5 b; G4 B! Z2 q% E- Idouble x = 4.0; </FONT></P>
6 u r4 x9 m* C1 | L<P><FONT color=#0000ff>result = exp(x); # t9 Y# s& s e) @
printf("'e' raised to the power \
4 D8 L9 L- s! S+ u, X8 vof %lf (e ^ %lf) = %lf\n", 0 [$ i3 U: k0 D( d* A4 W3 W A
x, x, result); </FONT></P>2 G- Q8 {' |, H' V
<P><FONT color=#0000ff>return 0; % g) h6 ^! L6 f6 A
}2 H' ~( h$ m0 [% A" u( ]' L- y" i! r/ t
</FONT></P> |
zan
|