QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2143|回复: 1
打印 上一主题 下一主题

函数大全(e开头)

[复制链接]
字体大小: 正常 放大
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

跳转到指定楼层
1#
发表于 2004-10-4 03:01 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(e开头)</FONT></B></FONT>* B+ Y  F; h$ V' i& {; T
</P>4 B+ `. s" U4 f" @* v7 \

, R# _# o( p, s; n
8 E1 B8 H0 F7 k6 b  I! i  H4 F<><FONT color=#ff0000>函数名: ecvt </FONT>
8 B) w& A6 Q+ U* ^: G" E9 @功 能: 把一个浮点数转换为字符串 ! F+ u% r0 X7 ~5 H2 N5 G
用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
, z" m1 n# y! O8 N' B程序例: </P>1 z! B: c9 ~2 ~3 R' l5 Y/ Y
<><FONT color=#0000ff>#include <STDLIB.H>0 v8 _4 X# }* r  l) u8 c+ \; e
#include <STDIO.H>
4 y) d& l( V$ _4 c#include <CONIO.H></FONT></P>0 _. o* w, Z" a1 N' o6 H9 U
<><FONT color=#0000ff>int main(void) 5 f0 z7 `! w1 [3 l
{ - ^1 H' @4 m& n9 `4 A
char *string; ! }5 P6 I# v; N6 }$ P- h- M
double value;
( ^& G: A+ x% F% q/ J2 j) qint dec, sign;
, v3 E2 z! m0 rint ndig = 10; </FONT></P>5 s6 V2 |  T0 |0 X9 m4 \
<><FONT color=#0000ff>clrscr(); - ~" e$ h1 ~! e1 Q3 V* ?4 ~
value = 9.876; . M/ d+ C% K( M' f- a; @( K
string = ecvt(value, ndig, &amp;dec, &amp;sign); % Y  H' u1 U! |8 s0 C/ C7 ^
printf("string = %s dec = %d \
4 ?3 f& E5 f# s& z3 e/ nsign = %d\n", string, dec, sign); </FONT></P>
+ ?3 V+ w5 t/ A9 A' i4 v<><FONT color=#0000ff>value = -123.45;
9 y) z9 [6 a3 _ndig= 15;
. S$ [( G3 H) f; ~5 A( }string = ecvt(value,ndig,&amp;dec,&amp;sign);
' _! a: |( u, ]" W9 y2 _$ P; @printf("string = %s dec = %d sign = %d\n", & h% C- i' K( w1 p" o) x& X
string, dec, sign); * c2 R4 M+ }* E$ F- V! J$ f* c
</FONT></P>
3 ~  T$ z/ G& s. Q/ ?! L8 T! P<><FONT color=#0000ff>value = 0.6789e5; /* scientific
% \$ ~- @$ H7 y! lnotation */ ' g# w0 ?9 E5 |4 {3 Y
ndig = 5;
$ K8 T8 G8 P9 @4 Ystring = ecvt(value,ndig,&amp;dec,&amp;sign);
& C5 [% w$ s1 O! s9 u* W& @printf("string = %s dec = %d\ , d9 |. x: F3 `' e+ J
sign = %d\n", string, dec, sign); </FONT></P>
; T( o, |# ?1 E! M<><FONT color=#0000ff>return 0; ) w* c) D+ J* L- e; h
} </FONT>
1 m+ q  S, J) |  o7 F3 L" `  P% g/ S" v! c) \
</P>: ?2 Z; h7 y2 O6 y9 |1 g
<><FONT color=#ff0000>函数名: ellipse </FONT>% y5 m' q+ H+ p+ m* G3 o, Y
功 能: 画一椭圆
3 Z7 L/ d7 i% A3 V用 法: void far ellipse(int x, int y, int stangle, int endangle,
2 e3 K7 W' @) j+ K/ @0 Fint xradius, int yradius); , K4 t- A7 o4 s
程序例: </P>; h0 f. \8 H/ [/ T9 o
<><FONT color=#0000ff>#include <GRAPHICS.H>
4 `8 _6 E4 u9 h9 I. ^8 W#include <STDLIB.H>
9 H6 R# w9 ?( }/ p" m& ~  ^#include <STDIO.H>$ H/ a% D' y: d! M* D; l
#include <CONIO.H></FONT></P>
& B! X; T- N) z! A7 L6 g# c; E1 Z<><FONT color=#0000ff>int main(void) 6 p' x( Q9 c, E9 Z8 D7 Z
{
; U4 g; o5 X6 H7 V, l! L/* request auto detection */
" t; m& p' M( W3 b& o- Sint gdriver = DETECT, gmode, errorcode;
, Q; t) Q' E3 L1 qint midx, midy;
2 z5 i, R' y8 x$ p( @int stangle = 0, endangle = 360; ( D3 V" Y' W1 `$ u& Q! ~
int xradius = 100, yradius = 50; </FONT></P>
+ ?& Q" j6 Q) L: [<><FONT color=#0000ff>/* initialize graphics, local variables */ 7 a; t8 H2 p1 a  y/ N* V1 x% i
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
8 b* W) _; @) ]8 w3 T% k<><FONT color=#0000ff>/* read result of initialization */
7 G! R' L9 g% `2 D9 ?. Serrorcode = graphresult();
1 m% P- d( F! G( ^, qif (errorcode != grOk) , r. l$ Y  e( Y- B
/* an error occurred */ * _$ g: J3 Y! G* x8 @
{
- [1 T# O' u+ m/ s3 I" |" Tprintf("Graphics error: %s\n",
" ?& i4 I& o8 F5 M' e& Ygrapherrormsg(errorcode)); 7 s; A; t: W5 m& \2 C' l/ c
printf("ress any key to halt:"); & j3 X2 s+ |; B+ @6 y
getch();
/ K+ d1 p' [  u" C: w& }% u/ O$ sexit(1);
$ E5 {- V: m& m3 f/* terminate with an error code */
$ B7 X" Q& v/ W& u: i: D} </FONT></P>: @1 q$ ?' j0 k+ S" ~1 w
<><FONT color=#0000ff>midx = getmaxx() / 2; $ V& I* l" H4 u
midy = getmaxy() / 2;
5 T$ p: N: U) d8 M1 @setcolor(getmaxcolor()); </FONT></P>
4 U# I$ s6 _' V& ^, a<><FONT color=#0000ff>/* draw ellipse */
# v5 u" W8 t- Y/ Hellipse(midx, midy, stangle, endangle,
* @3 \- P- C; g) Z/ Pxradius, yradius); </FONT></P>
/ `7 j2 V% L+ Y! D! m<><FONT color=#0000ff>/* clean up */ % j+ }- _9 _/ W5 u
getch(); 9 [" P! D$ z; V; J: H
closegraph();
% \7 C9 y# l' C" p. [5 \1 n$ z# Mreturn 0;
# S2 c: w  G) }7 }  I6 a} </FONT>
, S$ M( V! y* I# I/ ^3 H4 P: d2 w7 r6 m" U
</P>  w* L8 z4 c# L  a* Z; L
<><FONT color=#ff0000>函数名: enable </FONT>
* f7 V* f4 O" u. T6 H功 能: 开放硬件中断 0 C8 Q  y4 I3 f* N; B  S
用 法: void enable(void);
  I( S2 N0 u/ j6 T+ L) ^  T程序例: </P>7 ~9 C( p6 r) j- Y' i8 d
<><FONT color=#0000ff>/* ** NOTE: , c$ P% T. B; y) ]. e8 o6 _. k1 H
This is an interrupt service routine. You can NOT compile this program
0 g3 t1 c4 Y7 E9 \5 l: Y- r' T7 A1 Pwith Test Stack Overflow turned on and get an executable file which will 9 E" i. r8 u6 h- ~( z) Y9 [' M
operate correctly.
# l$ d% \3 C( q% Q*/ </FONT></P>
2 b$ r3 M0 j* V+ R9 C7 ]( y<><FONT color=#0000ff>#include <STDIO.H>
; H$ t/ C, H! R#include <DOS.H>7 \  V1 n. \5 P+ Z$ ^6 ?
#include <CONIO.H></FONT></P>
* t# S9 J! b3 b: U<><FONT color=#0000ff>/* The clock tick interrupt */ # B( e! z% F6 {) z6 W
#define INTR 0X1C </FONT></P>) t+ L* }4 b8 W
<><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>, \0 m; v. r6 b. C& ~& S2 @. s; ?
<><FONT color=#0000ff>int count=0; </FONT></P>8 Q' D" C1 x8 ^+ Z3 \
<><FONT color=#0000ff>void interrupt handler(void)
) z/ h% m9 G; m) S. W8 V{ 6 J# q% P, v8 N! D
/*
' D1 g  Y- M7 _- b: ~7 m4 Vdisable interrupts during the handling of the interrupt + D" C0 x3 Y. r+ i
*/
* i& b. t  F" n8 @) h( Udisable(); 8 H  m7 P& _* K
/* increase the global counter */
& i  g0 R) C: m$ Z0 t% |count++;
( e% s1 C- D6 ]) H6 l) Y7 i# |/*
6 |2 g1 ^% o8 S. o- f. {re enable interrupts at the end of the handler
( y* I3 Y6 o& V+ g0 C*/ 6 R# w9 r; k5 y7 P2 a* |% Q
enable();
. g; f- u0 k8 f* D7 b7 M8 l/* call the old routine */ , @1 Y; {6 a, _
oldhandler(); " O  Y" L8 h+ N- }7 d% o
} </FONT></P>! I6 Z+ _5 T1 B+ `* k; O( k
<><FONT color=#0000ff>int main(void)
5 r1 I2 [  l' T! B4 f( Q4 Y{
6 I0 t6 u7 n# _* U  h4 w/* save the old interrupt vector */
8 `+ X9 E5 T! joldhandler = getvect(INTR); </FONT></P>7 [6 T: U- d, a7 q
<><FONT color=#0000ff>/* install the new interrupt handler */ 3 t: n0 G6 b5 i; g! v
setvect(INTR, handler); </FONT></P>% ~9 t# z1 z. {5 i0 r
<><FONT color=#0000ff>/* loop until the counter exceeds 20 */
/ p0 Y# ~( v0 V% H1 swhile (count &lt; 20) " u" V  p0 A; D4 ]8 E' W! h+ j% d$ g
printf("count is %d\n",count); </FONT></P>8 |2 v2 f/ |- d1 m2 d. L0 d1 G( b
<><FONT color=#0000ff>/* reset the old interrupt handler */
; K0 B" A0 s& ^( ?/ nsetvect(INTR, oldhandler); </FONT></P>
8 o# E# o- p$ \( c<><FONT color=#0000ff>return 0; # Q, M3 c. r3 L4 V+ S3 ?
} </FONT>
1 N3 c. a7 s4 X; Y( {# Y. T7 A
% l2 ]: N! F2 {</P>
( A) G) ~! H4 Z4 b5 E3 G<><FONT color=#ff0000>函数名: eof </FONT>
& b( G/ M$ B( E' `功 能: 检测文件结束
2 N" }8 K+ T! f1 U5 \3 H用 法: int eof(int *handle); 8 E$ b% Y; ?. J* C: S1 _
程序例: </P>* ^( S# {4 o1 O% l5 i- \
<P><FONT color=#0000ff>#include <SYS\STAT.H>
5 A0 T5 a) V; z! @#include <STRING.H>; B9 x8 A' k- r0 j  u8 D0 i& ?
#include <STDIO.H>  U9 b* S' N3 C5 O9 _
#include <FCNTL.H>' _, _) }. d' m
#include <IO.H></FONT></P>5 g( p6 d% t8 z* ?' y
<P><FONT color=#0000ff>int main(void)
9 E' h3 g  c: P{
1 d. K  ]1 v6 L% F* Fint handle;
$ ?, b9 G) Z: d8 O: ~char msg[] = "This is a test";
6 F# n4 e& m( Y) L  `5 Kchar ch; </FONT></P>
; [* ^, [2 q% Z9 P5 d; ], V<P><FONT color=#0000ff>/* create a file */
7 `5 d3 X  F. F8 Ihandle = open("DUMMY.FIL",
/ W2 ]( S) o6 `- `9 K; lO_CREAT | O_RDWR, 5 [5 O6 Q. ?" [3 }# o
S_IREAD | S_IWRITE); </FONT></P>
, H0 W3 I  l8 v: E5 G2 [<P><FONT color=#0000ff>/* write some data to the file */ 9 S, h& H7 B6 D# R. c
write(handle, msg, strlen(msg)); </FONT></P>+ A: e7 H. e0 ?5 E8 U5 y# n
<P><FONT color=#0000ff>/* seek to the beginning of the file */ 8 n" P: W' @/ H) t, R' g
lseek(handle, 0L, SEEK_SET); </FONT></P>
9 q# w3 m6 ]( K; `+ O" L/ Q. j9 A" F<P><FONT color=#0000ff>/* % G. I( X/ y  Q* x0 v& A0 q
reads chars from the file until hit EOF
. E" t1 A3 N; a1 t! v*/ ) D& N9 k6 S# E! i! z; Q! h
do & W4 P6 [9 c6 {7 l+ i6 S; d% n5 W
{
+ j( S/ c; |9 d- |+ Gread(handle, &amp;ch, 1);
$ n; H9 t9 @# o4 _/ @, Yprintf("%c", ch);
& }+ H, G! Q2 h4 `- p} while (!eof(handle)); </FONT></P>
5 S3 o$ |& X1 J  v9 H' @<P><FONT color=#0000ff>close(handle); " o2 Q- P! B: b# [# L3 ~8 |2 Q
return 0;
" \  F4 m" f, e+ ]# Z}
0 `4 i6 |7 r' q! Y</FONT>/ \5 z* T. v/ O( f2 w0 ?. C! A& Y
</P>
$ K) x4 g, }7 L/ f3 D  e- I1 L<P><FONT color=#ff0000>函数名: exec... </FONT>, Z8 g+ c7 l1 X* P/ J+ }
功 能: 装入并运行其它程序的函数
4 s! w7 e! l  I: f  L* B5 X* `6 e用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL);
4 R( L: \6 O7 X1 Cint execle(char *pathname, char *arg0, arg1, ..., argn, NULL,
% S( \8 T9 Y: n/ ~. _) I4 gchar *envp[]);
% {' V! N4 u& z/ g( ^* M& h7 d0 c; z8 bint execlp(char *pathname, char *arg0, arg1, .., NULL); ! Q$ E/ N) E( y1 l  h$ \
int execple(char *pathname, char *arg0, arg1, ..., NULL,
+ e: d" b6 |* ]/ {. B- V6 Ochar *envp[]); $ G' f* Z+ T. ]3 m2 p7 N% i
int execv(char *pathname, char *argv[]); + D# ~7 b$ F! w+ ?! X
int execve(char *pathname, char *argv[], char *envp[]);
( U8 [7 s, i5 `+ b/ F5 x2 k0 c- Bint execvp(char *pathname, char *argv[]);
+ `* b7 b; x: S$ o6 oint execvpe(char *pathname, char *argv[], char *envp[]); ) P: F- ]& k$ H
程序例: </P>
- o3 J, l1 c4 X  s' L  D: ^<P><FONT color=#0000ff>/* execv example */
1 ^! M; Y% M) e1 I* g$ g% e2 \#include <PROCESS.H>
1 H% @/ V1 h; l9 R" P6 l#include <STDIO.H>, f4 z* E, z% t, y) h$ ~
#include <ERRNO.H></FONT></P>
4 Y5 q$ J1 L+ e* g# c<P><FONT color=#0000ff>void main(int argc, char *argv[])
5 W9 M4 v, ~* K& r3 F* Q4 I2 m{ ; r. S( X7 B  u8 c( L0 {0 |
int i; </FONT></P>! \5 o) H2 L6 A: d0 H
<P><FONT color=#0000ff>printf("Command line arguments:\n"); 1 i" \1 ~$ Q9 C3 t6 Y
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
* ~! {' R' R9 r: g/ x7 W8 h<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n"); + L% |' t9 ~7 j8 F% {: C; S( }* a$ T
execv("CHILD.EXE", argv); </FONT></P>3 {4 p8 x" X" J8 E2 O7 f# b
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
" L1 l7 B$ j8 ?3 S. |6 P- |3 r6 v: _<P><FONT color=#0000ff>exit(1);   Y* k( h) S. I7 F& Q: F2 y
} . X, J0 x6 Q1 t9 L+ @# S
</FONT>
/ |4 M4 b/ \5 B0 N+ o</P>4 `6 w2 r8 \+ F' b
<P><FONT color=#ff0000>函数名: exit </FONT>  X4 @; d1 D, [$ ^- F* v
功 能: 终止程序 - |1 P: D$ K# N6 h  f( X( t: T
用 法: void exit(int status); ( v4 `8 G# f, g& Q: p
程序例: </P>  I7 o2 a+ d7 [& T! C
<P><FONT color=#0000ff>#include <STDLIB.H>8 H8 L, ?& j7 g& H" I6 h
#include <CONIO.H>& ?/ S8 e2 x5 B1 I) `) x0 [
#include <STDIO.H></FONT></P>
& f) `6 X* R% d3 q6 h/ L* P% R<P><FONT color=#0000ff>int main(void)
* V) M  n) m9 T{
8 f- H( E! X6 f/ \& [/ t' oint status; </FONT></P>
% J7 ~3 X: f/ d. d- m, ?" Y+ ?; v# n<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); + W" ]9 _- Y1 E/ X% L
status = getch();
  @- Q+ R; n5 {7 R5 C% r/* Sets DOS errorlevel */ % |% j; X! D- M  j/ i; b
exit(status - '0'); </FONT></P>5 y& h+ D0 F7 r0 a  l0 j
<P><FONT color=#0000ff>/* Note: this line is never reached */
( C# I; ]& E9 l' d* f" Ureturn 0;
- U/ E  W3 ~( P) y} 5 r* a1 D# h1 [7 |- n( l
</FONT>3 I+ Z0 }$ S1 u# }" z/ N. L* \, M
</P>8 I# g/ s6 `( r2 ~0 b! M" K
<P><FONT color=#ff0000>函数名: exp </FONT>+ u! a4 w1 K  \. D4 W( Y: U2 x6 g
功 能: 指数函数 9 v3 {4 K3 D( p& P( M: ~' B4 G( r# t- \
用 法: double exp(double x);
* o& E" P/ j0 n程序例: </P>
, S& x' }& _+ I<P><FONT color=#0000ff>#include <STDIO.H>
+ ~; d2 _$ N6 @5 J3 x* ]#include <MATH.H></FONT></P>
: Y8 a& f" a* f<P><FONT color=#0000ff>int main(void) $ S0 }$ w# i6 y1 l1 ]% }
{ " R9 G, i& F: I& W' E2 R
double result;
. l* Q3 ~7 V% E* F' {! r) G! jdouble x = 4.0; </FONT></P>2 {9 ]2 m9 q& `  W3 k
<P><FONT color=#0000ff>result = exp(x); % p2 V( f. ^9 }; F! x+ L' [5 k
printf("'e' raised to the power \ 5 v2 S& ?9 S+ z( ?1 B) E( p
of %lf (e ^ %lf) = %lf\n", ( _3 J( ]$ Q+ R2 O/ G0 n, j
x, x, result); </FONT></P>* a2 {% K/ {& C4 C
<P><FONT color=#0000ff>return 0; 1 {  I7 w4 q5 }  }+ {, w6 D
}
6 J% g8 T( Q3 G, i# w, K  L8 t4 Q# z</FONT></P>
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(d开头)</FONT></B></FONT>
. k& e, i9 D* n/ n, H' b& v</P>
; C4 [! \9 S$ P; ?) B/ R1 A<p><><FONT color=#ff0000>函数名: delay </FONT>% k. c' P2 D5 P; \
功 能: 将程序的执行暂停一段时间(毫秒) ) y* `& ?7 i' Q" l* w
用 法: void delay(unsigned milliseconds);
' R( y& Y+ S  |2 `' |1 r程序例: 7 g  L. a4 T2 ~
<FONT color=#0000ff>/* Emits a 440-Hz tone for 500 milliseconds */
% o; Z6 s' M. T7 H+ {$ N- b2 y( H#include <DOS.H></FONT></P><><FONT color=#0000ff>int main(void) / B# a) Q" B8 @8 h! r1 E, u$ C
{
. }) ]1 E4 C: m8 gsound(440); 4 u5 k7 q& M+ ^% O7 n
delay(500);
% g5 B8 ?) c- M9 H! L2 X2 fnosound(); </FONT></P><><FONT color=#0000ff>return 0;
  W, V0 O9 ?. E! t# W) r: m}
% d$ ]9 |2 f/ i* T! V' e
0 M+ ^( I7 E6 L4 l# |8 h' T& y/ j</FONT></P><><FONT color=#ff0000>函数名: delline </FONT>5 ?7 _. U& N* f+ U3 G; F6 d$ H$ ]
功 能: 在文本窗口中删去一行 6 {) N* b) _' K+ I
用 法: void delline(void);
2 y7 _+ x! C  C0 ]: s- ]6 J程序例: </P><><FONT color=#0000ff>#include <CONIO.H></FONT></P><><FONT color=#0000ff>int main(void)
: ^1 ^: ~$ Q* Z& T  x{
7 S* U! n8 g/ ?, X" U7 Qclrscr(); : C& i4 S# J8 b8 D, c
cprintf("The function DELLINE deletes \
+ |* ?$ S0 d2 d! ]4 G- d* O/ tthe line containing the\r\n");
9 `* _1 Z. Q, r' F) {- E" h" Ecprintf("cursor and moves all lines \
3 j- l& h% m; Q- m& L3 v2 ~0 gbelow it one line up.\r\n");
9 n6 |0 z6 A1 }# Q) [& Scprintf("DELLINE operates within the \
- h1 P' L, v3 p4 f/ Qcurrently active text\r\n"); 2 u; V& }: ?( e% M4 T
cprintf("window. Press any key to \ ( ?3 \" V* T  ~. c1 v  S2 I
continue . . ."); ; P/ |% y, f* f2 n. M5 v
gotoxy(1,2); /* Move the cursor to the
8 d+ l" l) \7 q" \. csecond line and first column */
$ ]8 ^4 b0 o$ I' xgetch(); </FONT></P><><FONT color=#0000ff>delline();
6 G$ e& |. G: u8 f4 Qgetch(); </FONT></P><><FONT color=#0000ff>return 0; 3 k4 \3 w! m& q
} </FONT>
/ c7 v8 s/ a. Q; L2 T' t) l* N</P><><FONT color=#ff0000>函数名: detectgraph </FONT>- ~9 L- N$ m3 T" D
功 能: 通过检测硬件确定图形驱动程序和模式 " {4 T' B# I7 ~4 L" z" E
用 法: void far detectgraph(int far *graphdriver, int far *graphmode);
% {( s0 M# x* |. q程序例: </P><><FONT color=#0000ff>#include <GRAPHICS.H>
! o- u0 s( j) y5 m- _0 v#include <STDLIB.H>
! \0 k2 U4 p8 k- D4 }* c1 D#include <STDIO.H>. ~2 I# e9 t+ ~9 M" e3 Y
#include <CONIO.H></FONT></P><><FONT color=#0000ff>/* names of the various cards supported */ $ j& W; w; f  M+ ?: C
char *dname[] = { "requests detection", & J" P! b; s- J: R& ?3 z
"a CGA",
) X* D8 u- ^9 k; I3 ["an MCGA", " K7 w1 r4 b! d5 @! J+ N. @8 r5 L
"an EGA",
$ N" W4 j6 R; W* n"a 64K EGA", 2 s8 j+ k8 `9 x
"a monochrome EGA", * @) O& x  ~( T5 g
"an IBM 8514",
, d. g) c7 d( T' N"a Hercules monochrome", + `9 J/ ~! b* `: e" r# ^; _0 z6 f/ }& W
"an AT&amp;T 6300 PC",
2 x3 n0 g( Y6 A- W8 M5 O* k# ["a VGA",
9 v+ j9 B2 J7 l" l+ Z"an IBM 3270 PC"
& E5 k9 u& r( h0 \}; </FONT></P><><FONT color=#0000ff>int main(void) ' |! ~8 L+ x" ]$ u
{
8 e6 z, H2 w# F6 l& q( j% ?/* returns detected hardware info. */ 3 I  }" r% s! a$ R& y! P2 R2 I
int gdriver, gmode, errorcode; </FONT></P><><FONT color=#0000ff>/* detect graphics hardware available */
7 M8 l4 A2 S0 adetectgraph(&amp;gdriver, &amp;gmode); </FONT></P><><FONT color=#0000ff>/* read result of detectgraph call */
9 _, V0 W/ Q( Q: G7 J& herrorcode = graphresult();
, w# H: c0 ?- {: Nif (errorcode != grOk) /* an error # N4 v! }# g( ?% g9 {! H
occurred */
/ Q6 H- A5 k$ G1 T: A# h2 C; Z3 k{ 6 p" Y- ^' F' V- P
printf("Graphics error: %s\n", \
) P+ o, q2 c4 Y  Vgrapherrormsg(errorcode));
' {  _9 v: ~0 m  B+ ^+ Zprintf("ress any key to halt:"); , L, u+ O, r  j, s! x5 V7 T# z
getch();
! V3 J; y/ x) U: _8 sexit(1); /* terminate with an error 5 I* r, @- f* k% T" s
code */ - V8 d, ^' T& X
} </FONT></P><><FONT color=#0000ff>/* display the information detected */ - R& H) K. b6 v! C
clrscr();
+ u& x. |1 B+ Tprintf("You have %s video display \ + T" D; _% L1 E5 c0 \0 @3 t, _
card.\n", dname[gdriver]); ; v  F( I  a  ~/ _$ Z1 d
printf("ress any key to halt:"); . g1 O5 \% B& G  Z& W, o4 ?- r3 h5 L
getch(); & y# N8 y- t, P" }3 V& X5 T2 z
return 0;
  ^: q/ o3 N# n& j" f5 \} </FONT>( _# f* z8 ?# J8 |5 |, z( P
2 S' c# d( t) c, u4 U

5 v. g2 O7 j: y+ c2 p% ^</P><><FONT color=#ff0000>函数名: difftime </FONT>
2 r" L7 o& g5 x% [; F( d功 能: 计算两个时刻之间的时间差 5 c" S4 s0 n, ^1 b( V
用 法: double difftime(time_t time2, time_t time1);
& F0 R" s6 z& ^程序例: </P><><FONT color=#0000ff>#include <TIME.H>
/ u9 i8 Q7 L, i- E* d8 Q& ]#include <STDIO.H>
5 @& L- ^$ k, ~. o: C) |. ]#include <DOS.H>' V. d0 ]+ E/ ]! u8 ]- {3 T
#include <CONIO.H></FONT></P><><FONT color=#0000ff>int main(void) * `. D& @: B- ?; T
{
4 A- j) y8 ~" J* F# i+ w6 m+ I, jtime_t first, second; </FONT></P><><FONT color=#0000ff>clrscr();
  R' `8 X* v9 Rfirst = time(NULL); /* Gets system ' Z/ d3 V, H& Y
time */ 2 d! F, E/ P3 R0 ~& p; N' n
delay(2000); /* Waits 2 secs */ 7 R- c2 J. O. @6 `" g, l
second = time(NULL); /* Gets system time . g( s% w, @/ p
again */ </FONT></P><><FONT color=#0000ff>printf("The difference is: %f \ # ?, K! ]9 W" x/ a
seconds\n",difftime(second,first));
4 i' h3 K" |% a2 f+ ugetch(); </FONT></P><><FONT color=#0000ff>return 0; ( i- f' h; o4 B( G
}
& J0 `1 u  f9 b! T% ~! l</FONT>: J2 H' C) j# @
</P><><FONT color=#ff0000>函数名: disable </FONT>6 |8 z+ b9 M# c9 D1 x9 I6 w
功 能: 屏蔽中断
3 J( T/ r% |. K用 法: void disable(void); : t: w: s4 R. a& A4 J1 [* A' W
程序例: </P><><FONT color=#0000ff>/***NOTE: This is an interrupt service - X3 ~# G7 A: d. O: F  [7 d$ d* ~  P
routine. You cannot compile this program
) h% }5 I- F' Pwith Test Stack Overflow turned on and * X! z$ C- g8 u+ h' \! t# @$ P
get an executable file that operates 5 w$ r6 V8 T: s1 |9 U* m$ h
correctly. */ </FONT></P><><FONT color=#0000ff>#include <STDIO.H>
  m. S$ N4 v) j8 ?- ^#include <DOS.H>4 D* g+ o* L; b/ {5 l7 t
#include <CONIO.H></FONT></P><><FONT color=#0000ff>#define INTR 0X1C /* The clock tick
; j. R# d: k. j2 {0 U6 j, Xinterrupt */ </FONT></P><><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P><><FONT color=#0000ff>int count=0; </FONT></P><P><FONT color=#0000ff>void interrupt handler(void)
% |' s$ K& J& |1 V8 N{ 1 I, i/ f! V! I  i
/* disable interrupts during the handling of 6 u5 j9 t+ @3 f2 `0 B- u
the interrupt */
7 c1 T) A" |2 s% ?! Jdisable(); ) c- J" Q) U' H
/* increase the global counter */
& `6 h$ H6 e* Icount++;
: _$ |% X! q9 L+ r/* reenable interrupts at the end of the
0 Q1 k5 Y7 |! z+ e! z& K8 thandler */
9 ^8 E5 P2 ?6 o8 Eenable();
/ }4 f' T5 O: U9 a& X3 t+ }, a/* call the old routine */
' O4 F% w% r$ `" Q! Koldhandler();
! Q. o# M( x- c* H: Y6 I1 Z} </FONT></P><P><FONT color=#0000ff>int main(void)
6 R) Q) M5 q" c( H{
8 ?( g8 U+ x$ _6 H- y9 L/* save the old interrupt vector */ $ X& a! h% h  c; G/ W4 t4 F( z6 n$ q
oldhandler = getvect(INTR); </FONT></P><P><FONT color=#0000ff>/* install the new interrupt handler */ ) z( R) }. H4 G8 Z- R. w" e- ^
setvect(INTR, handler); </FONT></P><P><FONT color=#0000ff>/* loop until the counter exceeds 20 */ - R. R" n1 P+ P2 C% u( [
while (count &lt; 20)
' T% q$ L* K4 H# ]! G+ J. pprintf("count is %d\n",count); </FONT></P><P><FONT color=#0000ff>/* reset the old interrupt handler */
$ U8 r3 u6 y0 e! k! G" o3 R+ Lsetvect(INTR, oldhandler); </FONT></P><P><FONT color=#0000ff>return 0;
! n3 e: B7 f* X4 x; P5 T; T} </FONT></P><P><FONT color=#ff0000>函数名: div </FONT>4 P  W- @0 b# g- |5 X
功 能: 将两个整数相除, 返回商和余数
& \1 {5 t# r1 N- w$ ~* e, [用 法: div_t (int number, int denom);
. W; E1 h5 m( D6 H' T$ J+ y程序例: </P><P>#<FONT color=#0000ff>include <STDLIB.H>0 D- A3 U6 k( M% \. A# O
#include <STDIO.H></FONT></P><P><FONT color=#0000ff>div_t x; </FONT></P><P><FONT color=#0000ff>int main(void) 2 X% G* X! F' r; t
{
9 z& u3 g2 I; b7 B/ u& S/ H  B2 Bx = div(10,3); ; O$ a* F) S' a% Q" T; Z
printf("10 div 3 = %d remainder %d\n", x.quot, x.rem); </FONT></P><P><FONT color=#0000ff>return 0;
0 E5 _- r% s" E# K% a2 _} ( R) t, ~4 X. z
</FONT>$ d! c" A/ z/ a, s4 _
</P><P><FONT color=#ff0000>函数名: dosexterr </FONT>+ t! {& w7 Z1 i1 b
功 能: 获取扩展DOS错误信息 ( O2 M. y& F) Q$ Y2 w
用 法: int dosexterr(struct DOSERR *dblkp); 6 h( q$ U4 ?/ G/ w) _- C/ }
程序例: </P><P><FONT color=#0000ff>#include <STDIO.H>6 g  }8 u7 c5 _1 o2 z8 P+ \. b
#include <DOS.H></FONT></P><P><FONT color=#0000ff>int main(void)
8 x/ a5 a4 S& S2 N& n! ~- p{ * B. g2 a  H% p" x
FILE *fp; 8 o- ~+ t+ ]' U8 ?, c% s5 h! b( X4 u9 M
struct DOSERROR info; </FONT></P><P><FONT color=#0000ff>fp = fopen("perror.dat","r");
; R5 _/ }0 L3 ?) |/ M3 v/ ?. g  oif (!fp) perror("Unable to open file for
4 ^% `- Y8 z5 e3 C* w  k) h: ^reading");
, i1 Z; s3 c7 c) Vdosexterr(&amp;info); </FONT></P><P><FONT color=#0000ff>printf("Extended DOS error \ 7 V3 B- I4 D% h  J1 H8 |
information:\n");
: E1 f+ c$ d& z. J3 q# Iprintf(" Extended error: \
" [1 }( F, s9 y" s6 v%d\n",info.exterror);
5 @( A# H" i) _, h- f* qprintf(" Class: \
& s" O0 c- D+ l- t4 S. c: R%x\n",info.class);
+ z# g1 z, j+ W: x5 C$ y8 S7 Oprintf(" Action: \ $ u1 h* O7 b/ e! C% B* P
%x\n",info.action);
1 i0 P! W" d' d  H1 n% Wprintf(" Error Locus: \
( Y) Q. H1 ]8 D- L4 I8 f9 x%x\n",info.locus); </FONT></P><P><FONT color=#0000ff>return 0;
* F/ [" e, }# V5 T} </FONT>
7 i) e) T+ Z, v. I; l5 ^5 K' ]
! L: f7 u" N& Z</P><P><FONT color=#ff0000>函数名: dostounix </FONT>' Z7 z% Y$ a* S; ~& _* j8 d: V1 i9 A
功 能: 转换日期和时间为UNIX时间格式 0 t# ~) {4 C, m9 A
用 法: long dostounix(struct date *dateptr, struct time *timeptr);
; j  j5 E/ V% X2 b程序例: </P><P><FONT color=#0000ff>#include <TIME.H>
& a/ l$ I% i) a#include <STDDEF.H>
2 {. q- A; Q4 U/ C! w2 }' _3 A#include <DOS.H>
: H* x9 v6 P( [) T; r* U#include <STDIO.H></FONT></P><P><FONT color=#0000ff>int main(void) ' u7 A( E6 b) U' p# d
{ 4 e* z/ _5 c4 Y6 U" T
time_t t;
9 X/ }% ?, ]% R1 T$ X4 m5 A: c% Xstruct time d_time; / ]) J$ c: l& P% b! b
struct date d_date;
& p. q9 I& P# d9 Z" ustruct tm *local; </FONT></P><P><FONT color=#0000ff>getdate(&amp;d_date);
) c4 @' ^. b; m1 r( W5 ^7 a+ }$ Agettime(&amp;d_time); </FONT></P><P><FONT color=#0000ff>t = dostounix(&amp;d_date, &amp;d_time); + Y& A  B) C6 n) p' O0 H6 P
local = localtime(&amp;t); * U. x  v9 H! U5 x: x
printf("Time and Date: %s\n", \
" Y) j- c6 w: k" {$ gasctime(local)); </FONT></P><P><FONT color=#0000ff>return 0;
: S4 v  b  U) E7 q} </FONT>; ]0 A8 G5 G- C$ X

( v/ x) x( g: ?- y</P><P><FONT color=#ff0000>函数名: drawpoly </FONT>
& [; v3 r: d9 X2 I% U3 i6 Y功 能: 画多边形
0 W. Y' w  K& c! X2 a; b+ ]用 法: void far drawpoly(int numpoints, int far *polypoints);
- C+ W1 r7 u" L& S程序例: </P><P><FONT color=#0000ff>#include <GRAPHICS.H>& S! h$ z$ f; a# M$ P8 S
#include <STDLIB.H>1 I2 b, B9 [/ Q4 V0 t  h
#include <STDIO.H>' R+ H6 g- L7 `. G' o* d4 J2 o
#include <CONIO.H></FONT></P><P><FONT color=#0000ff>int main(void)
7 J0 Q0 m+ |* {* m{ 3 H/ p8 v& L6 Y% W* [6 \
/* request auto detection */
4 c% Y' P! C) i6 \) ?9 Oint gdriver = DETECT, gmode, errorcode;
3 A/ ]9 |  T- t7 j/ Q% m* Tint maxx, maxy; </FONT></P><P><FONT color=#0000ff>/* our polygon array */ 5 {% T. h2 [. Y% M2 L
int poly[10]; </FONT></P><P><FONT color=#0000ff>/* initialize graphics and local : x/ L) p$ T: I- k
variables */
- ^" c( `! c  ]6 U6 [initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P><P><FONT color=#0000ff>/* read result of initialization */
8 F7 k, f9 S: h. _errorcode = graphresult();
5 y+ s4 q+ i# nif (errorcode != grOk)
$ \; h% F9 R6 u1 s: F1 J/* an error occurred */
, m" ^8 @% F8 d$ Z( \8 ?, S& ~% m{
( j+ D" {% I4 a: ~. ~printf("Graphics error: %s\n", \ ' c! }7 [+ i' Z% O% f* Y; a1 S
grapherrormsg(errorcode));
1 o" [! o+ T1 Z* V6 {( _printf("Press any key to halt:"); ( |1 |9 b; m5 V4 h, O% }0 g- L
getch(); % Q' b, k* A* ?) H6 T/ l
/* terminate with an error code */
2 r; D- m+ v8 ?& N) Vexit(1);
3 s. V: j' K' q& c# R& j3 ]} </FONT></P><P><FONT color=#0000ff>maxx = getmaxx(); # |. t8 {/ l; o6 @5 {
maxy = getmaxy(); </FONT></P><P><FONT color=#0000ff>poly[0] = 20; /* 1st vertext */
% j3 j$ E6 I2 b3 gpoly[1] = maxy / 2; </FONT></P><P><FONT color=#0000ff>poly[2] = maxx - 20; /* 2nd */ $ g/ d2 j2 h$ k. o+ r! S$ u( {
poly[3] = 20; </FONT></P><P><FONT color=#0000ff>poly[4] = maxx - 50; /* 3rd */ ' T. X- |  Q+ S' n& F
poly[5] = maxy - 20; </FONT></P><P><FONT color=#0000ff>poly[6] = maxx / 2; /* 4th */
0 W5 v8 O7 W* Mpoly[7] = maxy / 2;
5 ^, B: A5 L7 B/* & G1 `3 `; N4 R$ {4 h9 |
drawpoly doesn't automatically close / L5 i+ \/ C. d4 t
the polygon, so we close it.
2 _. U$ B$ v0 t' O7 F9 ~3 _*/
9 |0 C* m5 Y4 l6 M: {6 _poly[8] = poly[0];
; @7 E5 v; ~7 ?4 g8 p1 P& cpoly[9] = poly[1]; </FONT></P><P><FONT color=#0000ff>/* draw the polygon */ + E4 Z* P5 r2 Q$ b% v5 v8 b
drawpoly(5, poly); </FONT></P><P><FONT color=#0000ff>/* clean up */
" U% I- a9 H2 dgetch();
/ H2 q) p  N3 @$ y  Fclosegraph(); 5 C2 G! ^( j6 N' {- x
return 0; ; d& Y' i$ @6 X, f4 p9 L' g* Y
} 5 g: @$ }% n8 y5 B
</FONT>/ W7 r8 T+ f8 G
</P><P><FONT color=#ff0000>函数名: dup </FONT>7 }7 t) R  Z. K+ w+ q9 v
功 能: 复制一个文件句柄
; C+ c/ i$ T9 R: |" i5 ?- \用 法: int dup(int handle); % `% z6 Z, S+ Z% W4 @
程序例: </P><P><FONT color=#0000ff>#include <STRING.H>
' [: g: ~, O" l# I& K#include <STDIO.H>
. Z" `( f$ b9 @7 _  f1 C8 V#include <CONIO.H>
  ]- A% I' _! X2 v- ]+ x3 \# P#include <IO.H></FONT></P><P><FONT color=#0000ff>void flush(FILE *stream); </FONT></P><P><FONT color=#0000ff>int main(void) + Z  l7 g1 L, R4 o
{ 3 A0 o4 m8 z6 c. V( `
FILE *fp;
# }; Y% A9 k  o6 n& i# c1 o5 vchar msg[] = "This is a test"; </FONT></P><P><FONT color=#0000ff>/* create a file */ 6 {7 l; H8 X: p/ g) k8 Y+ j
fp = fopen("DUMMY.FIL", "w"); </FONT></P><P><FONT color=#0000ff>/* write some data to the file */
8 g. m& y1 E/ j! |' N0 efwrite(msg, strlen(msg), 1, fp); </FONT></P><P><FONT color=#0000ff>clrscr(); 9 g/ w- O/ B1 |/ B3 f- |- j
printf("Press any key to flush \ , M/ h; O' c! w+ |
DUMMY.FIL:"); " O0 P( F& ?& Z- l% t
getch(); </FONT></P><P><FONT color=#0000ff>/* flush the data to DUMMY.FIL without
/ p# i) v3 @9 O3 Rclosing it */
3 U/ l9 b1 R6 A7 Qflush(fp); </FONT></P><P><FONT color=#0000ff>printf("\nFile was flushed, Press any \ 5 b+ t$ B* O6 O$ O
key to quit:"); " G% j! ]" q* E- E4 e
getch(); - p% M* A# O3 t
return 0;
0 \. f$ E# E$ {  x9 S0 g} </FONT></P><P><FONT color=#0000ff>void flush(FILE *stream)
' ~+ p  z8 E4 O/ V) R' {{ 1 |) |: i8 O- ^, a- p* f+ e( S
int duphandle; </FONT></P><P><FONT color=#0000ff>/* flush TC's internal buffer */
  T- h- @2 Y0 J/ g+ ?2 k9 Vfflush(stream); </FONT></P><P><FONT color=#0000ff>/* make a duplicate file handle */
% F* S  T5 ^" u/ y% D8 Hduphandle = dup(fileno(stream)); </FONT></P><P><FONT color=#0000ff>/* close the duplicate handle to flush the
' C, d& C/ y; ~" x* oDOS buffer */
- E, }% m! p" s! _4 B4 H; A" Zclose(duphandle); 4 A! K: i. \7 b8 ^/ s$ y* O" R' A
}
; Y5 N" f' A8 T' S0 _5 ]" E+ ^6 k( S& e" H1 O4 R! J& e
</FONT></P><P><FONT color=#ff0000>函数名: dup2 </FONT>
4 E' Z) ^" J5 w' I1 V: b: a, m功 能: 复制文件句柄
1 x" {( o4 ?8 {) Q用 法: int dup2(int oldhandle, int newhandle);
# F% o6 G! Q( o程序例: </P><P><FONT color=#0000ff>#include <SYS\STAT.H>  R/ C% j9 X; u* H$ P
#include <STRING.H>5 o1 ]  P9 e9 p; {  q& b
#include <FCNTL.H>6 Z/ L' u. k! Z4 u( S0 U7 e4 M2 [
#include <IO.H></FONT></P><P><FONT color=#0000ff>int main(void) : _# F/ h* `  P8 X- F
{
# @, w, |& q$ ~' v/ V#define STDOUT 1 </FONT></P><P><FONT color=#0000ff>int nul, oldstdout;
7 Y/ O1 R/ J" f0 f- f' H1 Wchar msg[] = "This is a test"; </FONT></P><P><FONT color=#0000ff>/* create a file */
( E9 ^( t% J# G" {; @; Enul = open("DUMMY.FIL", O_CREAT | O_RDWR,
$ n; F' E! {1 i! o" j# yS_IREAD | S_IWRITE); </FONT></P><P><FONT color=#0000ff>/* create a duplicate handle for standard
% [4 x! O+ W/ ~  m7 Routput */ " d& K6 i/ E3 ?1 O: G
oldstdout = dup(STDOUT); 7 n* }! N! g, ?! b7 S. a
/* + [+ X& F  o' v( e# e8 k
redirect standard output to DUMMY.FIL
4 G( w! ]# z- C( B; P& Fby duplicating the file handle onto the / B! [, ?! j/ F$ N* F
file handle for standard output.
8 `! ]/ i# D" ~/ X*/ : j5 j3 o: F, k5 W5 `* @; t
dup2(nul, STDOUT); </FONT></P><P><FONT color=#0000ff>/* close the handle for DUMMY.FIL */
) V) e* ^# B/ L6 Q" ?close(nul); </FONT></P><P><FONT color=#0000ff>/* will be redirected into DUMMY.FIL */
( r1 J( A; O# i: dwrite(STDOUT, msg, strlen(msg)); </FONT></P><P><FONT color=#0000ff>/* restore original standard output * o; ~4 T6 e$ _+ O6 F) m! v' h! Y1 ]
handle */ 2 u1 R: h! B. ]9 L$ P& Y
dup2(oldstdout, STDOUT); </FONT></P><P><FONT color=#0000ff>/* close duplicate handle for STDOUT */
' b2 a) f5 E/ D  Y# Iclose(oldstdout); </FONT></P><P><FONT color=#0000ff>return 0; + m9 D* p% a- c4 }6 d
} 0 R# y9 }! @: ?. ^2 D! V0 @4 H
</FONT></P>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085
fastpost

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2026-10-23 09:43 , Processed in 0.801407 second(s), 56 queries .

回顶部