- 在线时间
- 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>: U# H, B2 _7 v; E# O
</P>
! U* L1 _; }; ^) N& P( {3 x
/ g& N; b0 X, H( |$ }9 o5 ~' q" g
5 p' _2 ]) W4 x% C* {, u< ><FONT color=#ff0000>函数名: ecvt </FONT>" _7 ~/ o/ J1 z- m8 s! x
功 能: 把一个浮点数转换为字符串
8 Y. l; N" Y, s0 l1 R用 法: char ecvt(double value, int ndigit, int *decpt, int *sign); : p1 k7 ^0 m( d
程序例: </P>& j5 ]! X1 W& u6 s
< ><FONT color=#0000ff>#include <STDLIB.H>
" K; `0 [& x$ P' q#include <STDIO.H>2 ~- z* i; y! Z* M# L
#include <CONIO.H></FONT></P>9 ?* z/ e3 `3 j7 v+ y, A
< ><FONT color=#0000ff>int main(void)
/ B2 N; j+ I+ `$ r; u0 k{ ( V) M% G j- V1 F& b9 d
char *string; 9 D1 B# y8 e; n* x" r
double value; ; _5 x& |% d1 k; Q: O5 B
int dec, sign;
% K! D% e% M) L+ H' Lint ndig = 10; </FONT></P>
7 C' b, L4 Y# y, }1 {" w: p5 j< ><FONT color=#0000ff>clrscr(); 1 j) j5 J& o/ M& C' \' y# p
value = 9.876;
# t U0 g2 v# sstring = ecvt(value, ndig, &dec, &sign); ' t& a, ^, S+ }% M$ Q8 Z# v
printf("string = %s dec = %d \
^- Y- q) s$ {" \sign = %d\n", string, dec, sign); </FONT></P>
4 ]* V- ?& w6 S( Z* B< ><FONT color=#0000ff>value = -123.45; * x- [- h) F9 Y
ndig= 15; ' Q3 m. k# `" A, A0 R) Z9 Z
string = ecvt(value,ndig,&dec,&sign);
7 `5 ^% }2 S$ c, n8 N6 [printf("string = %s dec = %d sign = %d\n", 6 A s6 d) s1 p# @
string, dec, sign); - A* D& t' v" k1 Z4 i3 m
</FONT></P>1 P4 r1 B; U0 ~: y$ o6 n) D
< ><FONT color=#0000ff>value = 0.6789e5; /* scientific # }6 D) t( d$ E c0 M
notation */ 0 [% O: ~ s! ^/ r
ndig = 5;
4 e4 N/ m& e7 f2 {* N Xstring = ecvt(value,ndig,&dec,&sign); 1 }" M+ w) s6 N
printf("string = %s dec = %d\
% z3 H! X8 ^/ S( jsign = %d\n", string, dec, sign); </FONT></P>8 {2 W7 [! @) i& ^( l
< ><FONT color=#0000ff>return 0; 4 t, M# {2 k+ ~% O# q, f3 z
} </FONT>8 z/ P$ B6 R' W& }& y
( z- T9 ^. p( M+ `</P>
3 H; k. r- s' w5 h; W' I< ><FONT color=#ff0000>函数名: ellipse </FONT>
' D3 q. B( p9 L9 e, F功 能: 画一椭圆
8 B: O; r, B! }! p1 q5 ^$ H用 法: void far ellipse(int x, int y, int stangle, int endangle,
2 u% G- E! i3 P- hint xradius, int yradius);
, j1 ~+ _- z3 S; @4 H程序例: </P>. l' _1 f( q/ g9 \# i4 @6 i* Y( m
< ><FONT color=#0000ff>#include <GRAPHICS.H>1 R- @, M U3 o2 l, i' w! r j
#include <STDLIB.H>3 d0 W' P* e2 M- z
#include <STDIO.H>
( h* a' P. N/ i; B9 v#include <CONIO.H></FONT></P>
6 t1 e- f' k$ d% S7 I+ w< ><FONT color=#0000ff>int main(void)
7 L2 K2 @% Q' G' s{ . G) e9 h) T& N k
/* request auto detection */ . f& ?2 r6 U4 |7 {$ r; W
int gdriver = DETECT, gmode, errorcode;
$ E. N2 ~- e! g1 eint midx, midy; 8 Q" K! ^& v2 Q0 p! j: S' r
int stangle = 0, endangle = 360; 8 \/ n, N# B+ L( ?' n1 m
int xradius = 100, yradius = 50; </FONT></P>* Y: m$ i6 J/ H8 k' U
< ><FONT color=#0000ff>/* initialize graphics, local variables */
7 F; m+ d0 \0 A/ P, b+ \/ sinitgraph(&gdriver, &gmode, ""); </FONT></P>. n; B$ z* t* D& e- W# O) s
< ><FONT color=#0000ff>/* read result of initialization */
7 R- F2 W5 q8 p5 c; u+ l$ U! N- ^- [errorcode = graphresult();
% |! }7 G( ]! Xif (errorcode != grOk)
) ]: E! [ W& z J! x/* an error occurred */ & c3 j7 u0 i. J% q6 k4 B/ ? k) M
{
0 W$ ?6 c2 u5 g; P& \printf("Graphics error: %s\n", 5 e7 `: I( t! y6 Q9 I' G7 Q/ C! e
grapherrormsg(errorcode)); ' \- u! Q( P* {( `
printf(" ress any key to halt:");
4 w8 f: i: v2 Tgetch();
9 V) s. o% X+ Z$ M0 x9 a: c( Vexit(1);
l1 {9 l4 N, j! Y0 L/* terminate with an error code */
; ?( `! w2 v* O5 g3 Z/ U9 V} </FONT></P>- v" |0 t3 ]+ O- d7 | C0 y
< ><FONT color=#0000ff>midx = getmaxx() / 2;
+ B8 k% m% {- @# _3 ~& {5 K# ^0 Lmidy = getmaxy() / 2;
; W, `7 U. R' Z1 J; zsetcolor(getmaxcolor()); </FONT></P>$ H: `% A. J: d8 {! N
< ><FONT color=#0000ff>/* draw ellipse */
# |. k0 n8 q' Y! g7 P. xellipse(midx, midy, stangle, endangle, * q$ c3 r; V8 r. g2 p. d: x- f1 e2 `
xradius, yradius); </FONT></P>+ R( k* S& M9 a4 x+ ~. O/ b# h
< ><FONT color=#0000ff>/* clean up */ 7 {% G9 K/ r: Z7 B5 j
getch();
* e0 Y f( w4 O# vclosegraph();
8 _; s- z, s/ ?( w. Y) z) Preturn 0;
7 w& D* _$ @7 W8 p- d} </FONT>& T3 s, `- j" _/ d9 c; r$ e
1 Z4 I1 }! T' L; x4 e. S" H</P>( P. W7 m( ?" c' i$ L0 J
< ><FONT color=#ff0000>函数名: enable </FONT>
; Z1 |: P# h2 [5 V5 w# c0 G* X功 能: 开放硬件中断
M# ] z/ F. S用 法: void enable(void); % [) }' D- n" }6 v4 h- q U4 e
程序例: </P>
s3 X2 C" A# c, T7 \" ~5 c ]< ><FONT color=#0000ff>/* ** NOTE:
" R; }3 [# ]; M$ ~7 hThis is an interrupt service routine. You can NOT compile this program
2 b. n' m" @' pwith Test Stack Overflow turned on and get an executable file which will
?) Z8 Y/ X& G! _ Q3 noperate correctly.
4 d% Q+ N. I- x! H: m% G*/ </FONT></P>. ~' r1 o# [( n$ `
< ><FONT color=#0000ff>#include <STDIO.H>
2 C$ A1 Z- ~& `& D' m e( s; D#include <DOS.H>8 e3 c* u9 ?4 s5 r: E6 x! Z, |
#include <CONIO.H></FONT></P>+ d5 z8 D! W' w7 R8 s% N8 t6 v
< ><FONT color=#0000ff>/* The clock tick interrupt */
. E) U7 a( Y( k! a, _! v7 ?#define INTR 0X1C </FONT></P>
& U; S( T* S9 q3 [/ r* Q& ~< ><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>1 ]3 e. w& c9 v$ ?5 E& U. c
< ><FONT color=#0000ff>int count=0; </FONT></P> B5 o: {' I; d/ Q
< ><FONT color=#0000ff>void interrupt handler(void) ; t3 c1 } {4 e" z3 e! _# F
{ ! q/ T; `1 j6 P7 m# k* C
/*
3 m5 P8 p8 V. C0 [1 t3 _disable interrupts during the handling of the interrupt t3 ^+ ~4 M: }5 ^
*/ 7 I+ W* w0 Z) G2 ?2 a' V
disable(); 3 }. s0 [0 ~6 k/ | K; n
/* increase the global counter */ 4 o. o5 Z5 K# [+ U! l6 y( h2 W) A
count++; 2 j$ f6 s6 G# U" A x
/*
' O1 X5 O3 w: l6 U' m: o! [re enable interrupts at the end of the handler
2 [! ~5 p, ?9 S' q- a) n*/ " J* ~$ t# J6 I6 [$ d4 y% G! D
enable();
# x8 Z2 r; I3 ]/* call the old routine */ 6 [9 ?! X$ Y9 q! b5 U/ k/ O
oldhandler();
' N2 |8 q# V; s3 |} </FONT></P>( B# `/ f$ b+ Y
< ><FONT color=#0000ff>int main(void) ( e% Z; q! r: _! G# K* e2 y" q3 s; n
{ 6 P4 ^" _' ^$ y/ r8 ^# V! g
/* save the old interrupt vector */ - Q, ]8 j. _$ V! y" q
oldhandler = getvect(INTR); </FONT></P>
: F3 W' j6 _1 }' H3 M< ><FONT color=#0000ff>/* install the new interrupt handler */ , T+ u7 C. T' P5 f3 V/ d
setvect(INTR, handler); </FONT></P>
: B* L8 J4 Y9 K' K3 ?6 _; Q< ><FONT color=#0000ff>/* loop until the counter exceeds 20 */
! u' k9 j/ N1 i S- U" xwhile (count < 20) 0 }' L+ u" G+ j! d3 _; f7 [6 [. Y2 k2 s
printf("count is %d\n",count); </FONT></P>
1 [: F- m( B5 ^! u0 ~< ><FONT color=#0000ff>/* reset the old interrupt handler */
" a+ X7 D& O$ I# Q$ @7 Qsetvect(INTR, oldhandler); </FONT></P>2 u; q0 B- N6 f, ~$ G
< ><FONT color=#0000ff>return 0;
: ~' L8 h, P7 _4 E/ {$ n4 N} </FONT>
% s1 a9 z. p0 p+ C
9 a- P) F. q) A. N</P>
: z+ o- O7 U, _# c< ><FONT color=#ff0000>函数名: eof </FONT>
' d& \# R* F8 m. f功 能: 检测文件结束 % V3 {* b' K2 O$ T
用 法: int eof(int *handle);
, n2 F3 B- _) r8 h% W* F" V6 ~3 I程序例: </P>
, t' p; p, ?3 q3 P% f<P><FONT color=#0000ff>#include <SYS\STAT.H>/ V' y3 D2 m ~7 {) v& O
#include <STRING.H>8 {/ u- z2 d% |8 ~# I+ G# Y/ A y
#include <STDIO.H>
3 J! N) Y% R9 l#include <FCNTL.H>6 V/ Z' [! U& \
#include <IO.H></FONT></P>
/ l" N7 w( v/ u2 |6 I0 }<P><FONT color=#0000ff>int main(void)
6 O, v0 S2 B- r4 m5 I+ `{
8 I4 I+ b0 h% }int handle;
9 f0 R$ t9 M2 L/ @ \7 H# T( rchar msg[] = "This is a test"; 9 U% b* j2 o2 t
char ch; </FONT></P>
. W! @$ H; K& y# [<P><FONT color=#0000ff>/* create a file */ 1 r1 u) x1 \% `
handle = open("DUMMY.FIL",
W/ M; Y1 O( l6 Q5 ~, [! M6 SO_CREAT | O_RDWR,
; v6 F* |/ L+ O# m8 ^9 rS_IREAD | S_IWRITE); </FONT></P>9 t: p! F; s. I8 Y
<P><FONT color=#0000ff>/* write some data to the file */
/ r0 P$ G* d1 e* O1 C0 ?write(handle, msg, strlen(msg)); </FONT></P>
3 N* `4 t% ~8 F; O9 D<P><FONT color=#0000ff>/* seek to the beginning of the file */ 7 s+ f( v5 R- n% N
lseek(handle, 0L, SEEK_SET); </FONT></P>
1 U& u2 ]$ k3 n' r5 c5 x<P><FONT color=#0000ff>/* 5 R5 a0 t/ v9 J+ N. r! M
reads chars from the file until hit EOF ) p, b/ H( X- s# y0 Z+ C
*/
4 Y, @9 Q! w* Y) Z! H4 F9 Ndo % V C0 L( f4 c4 D
{ 3 w( `; H/ s/ Y0 `5 C
read(handle, &ch, 1);
$ l6 |8 C9 \8 s& j- N1 jprintf("%c", ch); 2 L9 m& f# M- L7 {) |* z
} while (!eof(handle)); </FONT></P>: ]$ j$ _) K/ S" D( o
<P><FONT color=#0000ff>close(handle);
9 i! l7 f0 E" ireturn 0; / G0 m$ B) n1 h5 F( ^ w. F
}
0 T* w. |1 ?! o; `2 w</FONT>5 ]: _, K8 c$ P
</P>
7 z, L$ G) o6 z6 P0 Z; {<P><FONT color=#ff0000>函数名: exec... </FONT>9 J: x) F# u0 U2 J1 k1 H# h% L3 o
功 能: 装入并运行其它程序的函数
+ h! Q5 j$ g/ U* z+ H用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); ! D4 I- u% `5 L- z! u
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL, 0 H& t7 r: @5 H, p; ~
char *envp[]);
+ M1 ~( f# c1 Rint execlp(char *pathname, char *arg0, arg1, .., NULL);
m# z6 ~' s& ]; h1 lint execple(char *pathname, char *arg0, arg1, ..., NULL,
7 ?7 _9 _* K3 s, p( y4 mchar *envp[]); . r% {1 H6 c8 T9 h! r5 p# Y
int execv(char *pathname, char *argv[]); 2 f Q4 Z- e" ~9 A& d( R/ ]
int execve(char *pathname, char *argv[], char *envp[]); ; P: T! X4 k. X& R7 C1 V. U7 y
int execvp(char *pathname, char *argv[]);
8 A5 |) e( q9 Z* K+ Uint execvpe(char *pathname, char *argv[], char *envp[]); ; W- _ F1 u+ e5 g/ Q( i: ]
程序例: </P>! d) W q! ] r- ^$ r/ n, Y
<P><FONT color=#0000ff>/* execv example */ 9 {0 B t9 d& a2 @6 ^) Y
#include <PROCESS.H>5 B5 p* _7 A, q8 Y0 ~. M4 H
#include <STDIO.H>+ r+ ?5 U, ^1 G5 G+ q; T6 m( [' M
#include <ERRNO.H></FONT></P>
R- }( u1 W1 e4 P: E, c! e. s; s<P><FONT color=#0000ff>void main(int argc, char *argv[]) ; \: c* l" C3 S" F+ Z4 C" w, _/ d
{ 3 ~* y4 i4 K" L5 D- y2 ~
int i; </FONT></P>" E0 l5 ?' p! |, j* L3 V+ j
<P><FONT color=#0000ff>printf("Command line arguments:\n"); # |# a& N0 U8 P4 B5 L
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
+ h: v& u4 X) L$ t# Z9 @$ X: F4 E<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
9 q5 e, O; ~9 l; s, x! vexecv("CHILD.EXE", argv); </FONT></P>
% |, P. P1 b v' A! w! n<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
9 y- N! y8 E7 y* \. s' \<P><FONT color=#0000ff>exit(1);
6 h. l# E# O5 k" m/ @, k7 N8 ~) S} ; \2 g1 G, }/ v1 W+ |
</FONT>/ l* k N) l) w
</P>6 ]* c; l6 _) i; y. {1 u
<P><FONT color=#ff0000>函数名: exit </FONT>
( |- G! x/ i( p% }: w- M) p6 ]功 能: 终止程序
) b ]- ]7 e# p7 |1 Q- |( i用 法: void exit(int status); J0 S" I" O& V8 {/ }2 Y8 t. y
程序例: </P>
/ f: L; K' O4 Y- ?5 K6 ]0 [' } }<P><FONT color=#0000ff>#include <STDLIB.H>- K E/ X1 i# \& l
#include <CONIO.H>0 {4 ]& F* ?7 C% ]( o& s+ D/ g* s; g
#include <STDIO.H></FONT></P>' |9 y% l: k E+ r B
<P><FONT color=#0000ff>int main(void)
& [/ h8 p7 n7 m2 \$ O9 Q{ , |6 u/ }- {& w+ @7 n' N
int status; </FONT></P>
" f% _: @4 i: Q) w<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); 6 L- Z% W8 K9 Q" e
status = getch();
5 T0 ]; q ]3 n1 |3 x! Y$ U/* Sets DOS errorlevel */ + F/ _* C# n* ^5 ?' C; N
exit(status - '0'); </FONT></P>5 x) d) E* p' W/ j1 O6 P: v( r& P
<P><FONT color=#0000ff>/* Note: this line is never reached */
5 p1 G3 u) K6 ~4 G% E. }( sreturn 0; 4 I* g h2 k& G5 E/ Z
} 1 T7 y: [) I1 p9 L) U
</FONT>. S: T# ]+ f2 {9 F: W
</P>
8 |, E$ U# t- o& s4 @<P><FONT color=#ff0000>函数名: exp </FONT>6 U1 x g( G( p( e B2 w
功 能: 指数函数
2 d7 Z& P7 s) t8 }6 S6 s用 法: double exp(double x); : N, H5 `( A- Y7 N
程序例: </P>- P J0 Z. q: G3 W S$ D9 p6 u6 t
<P><FONT color=#0000ff>#include <STDIO.H>; ^% b/ ]9 D& L/ o3 N9 L
#include <MATH.H></FONT></P>
$ e; ]5 H, B) `$ w# {$ x<P><FONT color=#0000ff>int main(void) * t2 h C. p" z0 v+ l/ V* m
{
( Z# }% E* `) bdouble result;
& Y7 f; c3 S. N* d. M8 Pdouble x = 4.0; </FONT></P>
l) N! c& j X" j5 Q<P><FONT color=#0000ff>result = exp(x);
5 L5 f0 K9 D' b) T& f" Jprintf("'e' raised to the power \ 9 |7 n! i" @8 n5 [
of %lf (e ^ %lf) = %lf\n", ! F( m+ T1 U* q5 h( Y9 @4 b
x, x, result); </FONT></P>6 C! ?% i% I+ x
<P><FONT color=#0000ff>return 0;
0 A7 ?# C. \- }5 ?7 X( Y}
- Y- w3 l8 k5 o" k7 w</FONT></P> |
zan
|