- 在线时间
- 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>, Y- C1 H2 D6 S- t3 {# ?: ~
</P>. B3 ]& @' |" g
3 K: Z& D' B% }" L) ?+ i. A, W
' p4 A7 s5 ?# |# m1 [/ o' k/ g& m< ><FONT color=#ff0000>函数名: ecvt </FONT>: b5 w% m# E6 ]+ D7 `
功 能: 把一个浮点数转换为字符串 ! l& w# s% A; o+ q# @
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); ) h6 L+ ~, s* b4 ^
程序例: </P>
; _( t9 H% X8 G( H5 }< ><FONT color=#0000ff>#include <STDLIB.H>, Y4 |# h7 c8 n3 F: \/ v( e- m$ X! B
#include <STDIO.H>
. Z1 Q6 }* u! d1 {" T% R6 U6 K, V#include <CONIO.H></FONT></P>6 ^# w" z/ `0 y, w S; }
< ><FONT color=#0000ff>int main(void) ; [ p0 y$ X! u( F1 [) R% k/ S
{
# V. @6 R/ i; j2 r& u$ }8 Dchar *string; _& E1 K' e+ J1 [
double value; " v* ?$ C3 v7 t
int dec, sign;
( p$ x) B& v1 V: n( V% M7 ]2 ]1 _0 Vint ndig = 10; </FONT></P>
5 [, L9 q* f9 n* y* J1 V+ p< ><FONT color=#0000ff>clrscr();
6 S3 E* u3 V# r% }8 }value = 9.876; ! e4 W, b8 t/ G
string = ecvt(value, ndig, &dec, &sign);
$ h4 c" B9 i0 @9 Vprintf("string = %s dec = %d \ , k1 b- E, T! Z% l' A+ @+ p
sign = %d\n", string, dec, sign); </FONT></P>( {* e" v3 [& t# R1 v e
< ><FONT color=#0000ff>value = -123.45; 4 k' M) O$ R7 e0 l; ]
ndig= 15; 6 i# \- T3 M$ w# E' T
string = ecvt(value,ndig,&dec,&sign);
) |8 B: ^ l- Y( kprintf("string = %s dec = %d sign = %d\n", % l+ v& j6 T3 H; i$ w. h% A8 u( @
string, dec, sign);
4 x, L" z) y& k* @</FONT></P>
3 G c5 p8 C( _! I) Y< ><FONT color=#0000ff>value = 0.6789e5; /* scientific
2 Q8 _% [& L/ p6 \1 E+ a: h* _notation */
) v0 n! _1 q. ^! t) w. _ndig = 5; * q1 j7 p( s% F. p/ ]
string = ecvt(value,ndig,&dec,&sign);
" Q l& } }: a" |+ v, `' z4 Q7 Kprintf("string = %s dec = %d\ ; c# X; R" o" I/ J
sign = %d\n", string, dec, sign); </FONT></P>
( P, J# Q, h! {3 i% L/ ^" T< ><FONT color=#0000ff>return 0; ( r0 f) g2 I6 h4 B% W% x: P
} </FONT>* n9 o& K* v# S* w5 _& [
7 P: ~9 e: j, o8 `/ E* ~5 N
</P>
! X8 Q8 r: F6 i7 a& H< ><FONT color=#ff0000>函数名: ellipse </FONT>" J" s$ w8 C6 R9 h* i# U" V# z' \
功 能: 画一椭圆 * I& F- E0 p- f
用 法: void far ellipse(int x, int y, int stangle, int endangle,
" E8 c$ i9 Q" a* p: Hint xradius, int yradius);
# N( U! p5 F8 p7 b# t% L; d程序例: </P>+ ]8 E" x% S+ ^( |2 B
< ><FONT color=#0000ff>#include <GRAPHICS.H>
+ j- K! h7 Z# @" J#include <STDLIB.H>
7 e+ v5 \4 l* C#include <STDIO.H>
. Z; W/ N! A6 {6 W+ n#include <CONIO.H></FONT></P>+ I/ }4 _/ I1 c* u; B, D0 p! m
< ><FONT color=#0000ff>int main(void)
+ C( H7 H2 N6 J$ \* K$ i% u{ 0 \6 j6 Y+ |3 H1 j6 @! Z
/* request auto detection */
' Z) k6 u) n/ i$ F6 b/ J7 }int gdriver = DETECT, gmode, errorcode; 8 }$ `+ B- \8 Y& I. q6 D1 j
int midx, midy;
- d8 u; {1 E$ a! ^5 ]; A: i6 a& Lint stangle = 0, endangle = 360; 3 M8 t& \+ [8 n/ S% m' f" U
int xradius = 100, yradius = 50; </FONT></P>
0 z+ I9 S- a4 A1 v) i& O8 Z< ><FONT color=#0000ff>/* initialize graphics, local variables */ & ^8 c! c5 X# T1 K8 k$ R, _
initgraph(&gdriver, &gmode, ""); </FONT></P>
% p+ X" ~7 F) L< ><FONT color=#0000ff>/* read result of initialization */
Y& A# z, g' perrorcode = graphresult();
/ [; u& s, F7 ? }# Qif (errorcode != grOk) + p1 V. n7 y1 R) G
/* an error occurred */
* r& f c% g; d! l/ O{ & c B V% ~3 t; F
printf("Graphics error: %s\n", # E9 V; w: L* T( l* p& t0 M
grapherrormsg(errorcode)); 8 n% T M3 s G( x1 j7 V
printf(" ress any key to halt:");
, R2 p* [, M" ^( J' rgetch();
6 R0 l/ O( J3 B/ q% L5 j( S9 o/ w" texit(1);
; D% n0 N4 H5 R3 W; Y k/* terminate with an error code */ R+ O; D/ g6 U& T# R
} </FONT></P>5 T1 w9 p( q/ B$ `- s
< ><FONT color=#0000ff>midx = getmaxx() / 2;
) |% c, a5 o7 C3 \; Y* Pmidy = getmaxy() / 2;
) u* }& {: E8 R8 nsetcolor(getmaxcolor()); </FONT></P>9 I, W6 o4 `/ \0 l
< ><FONT color=#0000ff>/* draw ellipse */
/ w# a) }% K# \ellipse(midx, midy, stangle, endangle, 2 p2 y+ W, s2 U. u
xradius, yradius); </FONT></P>4 G; Z/ J/ p+ @
< ><FONT color=#0000ff>/* clean up */
1 x o3 G8 d+ M8 w; i5 k: Vgetch();
' P) W* `; o5 Tclosegraph();
8 V1 X; H& n- G8 Sreturn 0; ! @* w, F* S5 n/ F8 i( X
} </FONT>1 d7 P0 I8 W$ f( r& j" ]
6 z! M; S: ]1 J5 ]+ Y& v5 G* {</P>6 g1 w5 f* b; o! E( V5 g# U% c
< ><FONT color=#ff0000>函数名: enable </FONT> b, A6 u* y9 A. H1 G" `9 J
功 能: 开放硬件中断 ( Z/ v5 i i: _
用 法: void enable(void); / J( p8 h- ]6 k
程序例: </P>" \; ]6 J( t2 K9 w5 J! K
< ><FONT color=#0000ff>/* ** NOTE: % J! _% Y0 w6 A. c# N+ q
This is an interrupt service routine. You can NOT compile this program
- h+ k2 B( y8 @% W. L- Swith Test Stack Overflow turned on and get an executable file which will
! u6 ~! Y' o& f% I& L4 hoperate correctly.
; n+ r. r. Y, g i( D1 n+ M3 F I4 V*/ </FONT></P># Y/ V8 i6 r9 z
< ><FONT color=#0000ff>#include <STDIO.H>6 n8 \9 [/ U$ Z5 o: [! `
#include <DOS.H>
2 T# r/ l- y2 N) s; U$ v6 _#include <CONIO.H></FONT></P>
* V, }) B( s7 w( s Q+ Y$ _< ><FONT color=#0000ff>/* The clock tick interrupt */
3 k# c) g, R5 C! j' ^#define INTR 0X1C </FONT></P>* W) X! ^# O J7 r* k
< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>
3 O, s6 l8 l( y$ Q- I< ><FONT color=#0000ff>int count=0; </FONT></P>7 m/ x" G& y9 k6 I! n
< ><FONT color=#0000ff>void interrupt handler(void)
3 m9 x, f+ ?. p' Q/ R1 y2 x{
, l. @8 R$ @; b" i: M2 p! ^ [/* * p9 @7 T6 |4 W6 B7 T
disable interrupts during the handling of the interrupt
- B" J* y+ {3 b( ?*/ # w: t. M; X4 D
disable();
& j/ j7 n: S/ D0 Q! H/* increase the global counter */
- J2 j% Q) a6 w: w- y4 w/ c$ w* dcount++;
: P2 a( M$ f9 J4 _* n. j; T# ~4 {/* 8 ^4 O3 B/ K3 b; B0 C
re enable interrupts at the end of the handler 7 F* c" [, [8 X. k
*/
9 e1 p6 y8 M. ^enable(); ( z, t( n, r$ M+ p# ^! N: l
/* call the old routine */ 1 g9 r" X+ h2 S5 U* j' B& J P+ P
oldhandler(); 6 p7 ~6 V8 h9 v1 O
} </FONT></P>
$ t% v& h; t7 q- k0 Q< ><FONT color=#0000ff>int main(void) ; w4 [3 B* w7 d. i& b# @* y! T M
{ # S9 R" w% d5 a! U9 F+ b
/* save the old interrupt vector */
5 B' Y: B# G4 {0 E$ M7 }/ [oldhandler = getvect(INTR); </FONT></P>
) u4 u, m1 q$ u( V& ?( z& }< ><FONT color=#0000ff>/* install the new interrupt handler */ . D% T) \! v, Q, k9 v7 V
setvect(INTR, handler); </FONT></P>
3 ~) |7 C# n) K2 O8 V< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
& \8 g) {) r- K& |5 @+ cwhile (count < 20)
3 B( _4 X7 a- R& v9 Oprintf("count is %d\n",count); </FONT></P>8 {0 L" I& ^1 L! t, `; |
< ><FONT color=#0000ff>/* reset the old interrupt handler */ : ~5 k: Q$ V Z; }9 ?
setvect(INTR, oldhandler); </FONT></P>6 p r; }" T$ u- Q2 u: O8 `
< ><FONT color=#0000ff>return 0;
( e! }$ F4 j3 ?7 ^5 s' c. \! [} </FONT> z- m" `# F1 j ]5 c
$ ^9 N! g/ s8 O7 ~- z</P>
- _( |6 h5 x% J# h* F8 O4 u< ><FONT color=#ff0000>函数名: eof </FONT>
$ D8 P' h# X& r$ T9 o' Q* e功 能: 检测文件结束
( C6 f$ ~, X' U- r用 法: int eof(int *handle);
9 D* h% y. k8 n9 T7 j6 ]程序例: </P>$ L8 O" v8 m0 G9 t. h
<P><FONT color=#0000ff>#include <SYS\STAT.H>
- R- w! H d5 _# L#include <STRING.H>7 t2 f9 u' r. `% v( k
#include <STDIO.H>
+ _ D& h+ k, H# @#include <FCNTL.H>. \; x* X$ e! y, j" B, [2 s
#include <IO.H></FONT></P>
/ {( h4 r, B) j! ~, ]* t7 G<P><FONT color=#0000ff>int main(void) + B8 U9 u% N, C8 t* R4 W6 X% j9 C
{ ! x2 c8 W$ P% Q/ J4 l3 R
int handle;
6 x0 e: a; t8 b$ [7 wchar msg[] = "This is a test"; ; a0 J0 q7 I& D e" W; r8 J
char ch; </FONT></P>
7 w" Q+ b B7 u, G0 D<P><FONT color=#0000ff>/* create a file */ " w& U3 K d' i! U! G S0 k6 X
handle = open("DUMMY.FIL",
: [: a, R, v5 |O_CREAT | O_RDWR,
" r' I2 n. I! Y- t. HS_IREAD | S_IWRITE); </FONT></P>
/ L, b0 [, Q1 |( @0 V; ~<P><FONT color=#0000ff>/* write some data to the file */ - ^' U: F$ q- `3 V" n
write(handle, msg, strlen(msg)); </FONT></P>0 t/ Z' }& k9 o& \$ h6 m3 ]
<P><FONT color=#0000ff>/* seek to the beginning of the file */ 5 s1 n' h9 _' `! W P% E
lseek(handle, 0L, SEEK_SET); </FONT></P>
3 @- I$ B' C$ S k M<P><FONT color=#0000ff>/*
! v' r$ \& Q+ g% t# M+ B5 Ireads chars from the file until hit EOF
7 ^- [: @' Z( b9 @*/ 6 c+ v2 r: q6 d1 O/ B
do ! [1 D) U# W8 ]1 T/ }
{
; n8 }$ t) `6 y2 S" tread(handle, &ch, 1); ! L2 r9 G e* \9 k3 W& R% E
printf("%c", ch);
! s8 Z( K) D( J2 T4 N} while (!eof(handle)); </FONT></P>$ g. [. x1 \5 _/ {; T) g# U3 I
<P><FONT color=#0000ff>close(handle); * j# G% ~' @+ E" L- |+ Y0 ~
return 0;
& |+ Y2 Z1 m X* [7 \3 u& x}
- ~# M1 c7 F) i1 m</FONT>: `0 d2 S* q) N& \3 W/ T
</P>
d2 Z3 c: K+ Z. _, r7 u<P><FONT color=#ff0000>函数名: exec... </FONT>9 {- L0 } v% E2 D9 Q( o7 C! C% k
功 能: 装入并运行其它程序的函数
7 a2 Q# [5 f$ e( p7 K; f用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); , _1 u' J' U P6 v
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL, ; n" d) C- I% {4 @: J
char *envp[]);
3 i x8 z' H% H1 d* Rint execlp(char *pathname, char *arg0, arg1, .., NULL); ' ^; b8 d( s" n
int execple(char *pathname, char *arg0, arg1, ..., NULL, " g" z9 s- T8 X, g% ^; M
char *envp[]); ! v+ k$ j2 o$ t- D9 U
int execv(char *pathname, char *argv[]); % A8 h) p7 H. ?4 @
int execve(char *pathname, char *argv[], char *envp[]);
( R5 `% q! Y- eint execvp(char *pathname, char *argv[]);
( Z" A( U5 Y# K) fint execvpe(char *pathname, char *argv[], char *envp[]);
3 f: p/ V$ c" U( x; b9 x+ H* Y. o程序例: </P>
6 h F0 {5 T6 B1 w8 M* i/ |<P><FONT color=#0000ff>/* execv example */
* q* F% O2 _3 W0 Y9 v- _# V#include <PROCESS.H>
, r: B* f9 r+ M( l; c#include <STDIO.H>
, b& s! K5 E1 `: p#include <ERRNO.H></FONT></P>8 z. _- {! c& B$ @" r
<P><FONT color=#0000ff>void main(int argc, char *argv[]) 6 A8 s0 O0 y2 @0 V3 h
{
) Z! A6 W* z2 O0 c$ Jint i; </FONT></P>
1 e: |6 B/ S3 N- z<P><FONT color=#0000ff>printf("Command line arguments:\n"); + s& Y0 D8 d9 ]4 x* f
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
6 ]3 H0 ~5 {5 E- m5 e3 y" W<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
: n0 t2 B3 }' C9 R- vexecv("CHILD.EXE", argv); </FONT></P>1 R( l% s' U b
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
4 n7 c4 ]1 k2 u& e4 P<P><FONT color=#0000ff>exit(1); ! Y3 M9 y, q8 c! Z0 V) @
} # V0 Q4 _' w' Z/ v% r/ ~
</FONT>
8 j9 s2 b2 P+ C4 \8 ~ J5 C0 _</P>
& N; {7 ?5 @4 F/ U<P><FONT color=#ff0000>函数名: exit </FONT>+ w- Y1 q3 }2 t2 U. [6 _2 e ?
功 能: 终止程序 3 {- M6 |% y6 l5 k- k' _4 J1 J }
用 法: void exit(int status);
; t: I) ~8 A9 b$ O+ s; R程序例: </P>
9 K2 Y- V4 [7 ~/ W' p6 p0 j6 T<P><FONT color=#0000ff>#include <STDLIB.H>/ W, @# G9 G; A0 I, s2 Y# Z+ Z
#include <CONIO.H>
3 s5 v1 }5 y# C: C; B- o#include <STDIO.H></FONT></P>9 ~9 U6 P. C- `' b G; b
<P><FONT color=#0000ff>int main(void) $ J6 R* m' y, i
{
7 n3 V0 n. w1 a3 k5 r. zint status; </FONT></P>: }/ Z6 I! c+ I9 a8 i8 _6 V( M
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); ( S+ D, r/ R0 r
status = getch();
) _/ r9 u2 ^; q8 n* c/* Sets DOS errorlevel */
' c% l6 {1 w) r$ Rexit(status - '0'); </FONT></P>
1 V A, s B+ w7 P<P><FONT color=#0000ff>/* Note: this line is never reached */ ( M# t6 t+ S1 A8 o
return 0; / C% @8 S" m" g3 k, F2 J; H
} ; Q' A- q- o, L2 D5 f
</FONT>; p' ]; P& W; p: a1 t1 w
</P> [- `+ j; p. ~4 ^: a
<P><FONT color=#ff0000>函数名: exp </FONT># t: `5 {, x- X% L
功 能: 指数函数
! V& x, f2 m! C+ q& I用 法: double exp(double x);
6 M! h( h4 C2 Q, @2 b* h程序例: </P>7 @$ w7 Z8 O! _, D
<P><FONT color=#0000ff>#include <STDIO.H>7 s7 a- N# d0 ]- }
#include <MATH.H></FONT></P>1 k' X A9 o) n2 L3 c
<P><FONT color=#0000ff>int main(void) 4 V8 d; G4 I4 k0 a3 `. b' D: y
{
# _; H4 ^5 `' ~1 V: |9 ]5 H+ n @double result;
' c0 K. v2 g- t* p& ~% ^double x = 4.0; </FONT></P>1 b, @% o* [$ ?# J+ X: q" |7 s
<P><FONT color=#0000ff>result = exp(x);
7 e2 {3 J& ]( W/ N$ T: Eprintf("'e' raised to the power \
/ K5 K) l% ^0 \, sof %lf (e ^ %lf) = %lf\n", " A8 e7 q% J, O9 p
x, x, result); </FONT></P>9 e9 x% {: D7 w
<P><FONT color=#0000ff>return 0;
5 A+ ?, ]$ n8 h}% \' h) @. h) {: W9 L1 W
</FONT></P> |
zan
|