数学建模社区-数学中国

标题: 函数大全(g开头) [打印本页]

作者: 韩冰    时间: 2004-10-4 03:00
标题: 函数大全(g开头)
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(g开头)</FONT></B></FONT></P>
3 c, D- a. |, m5 Q2 g
4 @# n& ?- V+ b' a! g$ w( |& E' r: s: l0 g8 V
<p>
8 f: i6 n6 c7 `' ?4 T<><FONT color=#ff0000>函数名: gcvt </FONT>' h( U8 r: K) u9 E
功 能: 把浮点数转换成字符串
4 u3 r- K4 e+ c& T- e+ ]  U. _用 法: char *gcvt(double value, int ndigit, char *buf);
  \2 G. V0 J. Q" h程序例: </P>9 C# X' K# P/ f( V
<><FONT color=#0000ff>#include <STDLIB.H>
& ?: z# X) K+ ]; @0 ~#include <STDIO.H></FONT></P>
7 ?5 w% S0 V  U<><FONT color=#0000ff>int main(void) # e5 |; ]+ [4 ^! _
{
6 b2 v. S0 i+ o* Bchar str[25]; 3 S7 Z  ~1 k" _# ^( Y2 n& z3 ?" h
double num;
' l1 U7 y' s. _int sig = 5; /* significant digits */ </FONT></P>
: H3 Z4 n) J& ^% T+ g<><FONT color=#0000ff>/* a regular number */ % j( k) l) k  _6 ]
num = 9.876;
" n) _- L" P) [, s0 V8 fgcvt(num, sig, str); ; U. ?; i3 H$ i- K7 E
printf("string = %s\n", str); </FONT></P>8 Q; g0 T! n+ W& S0 Q% U( ^# `0 P
<><FONT color=#0000ff>/* a negative number */ & S1 g$ D% U" `
num = -123.4567;
+ @+ s8 m# q4 ?: G  `gcvt(num, sig, str);
3 `1 V* Y" M! l# X, gprintf("string = %s\n", str); </FONT></P>
& {6 O( C1 L0 O: I. y+ k" D<><FONT color=#0000ff>/* scientific notation */ * X; Q( ?- N3 p0 o' F2 \7 b$ v2 a
num = 0.678e5; 7 p6 ^6 T  p% F- ]+ _' ?6 E5 E
gcvt(num, sig, str); 9 [# E. I+ Z; R+ s% G, ]5 D, v! \3 ]2 [) v
printf("string = %s\n", str); </FONT></P>, i, M2 C$ q& K2 f2 o6 y
<><FONT color=#0000ff>return(0);
( n9 M& U+ z  q} ) ?6 o: ~! w0 ^* i
3 m" W1 ^2 Q1 H2 G
</FONT>1 N7 `2 ]+ c7 S
</P>3 D3 ^1 k% V& B7 X: \2 K
<><FONT color=#ff0000>函数名: geninterrupt </FONT>
2 @) }& ^8 [2 b* d. i- S# h功 能: 产生一个软中断
- d  _- J& _$ O* L用 法: void geninterrupt(int intr_num); 0 f- q5 d% ^+ F6 w
程序例: </P>
$ M1 f& p& Z7 g, D3 v  Z( [<><FONT color=#0000ff>#include <CONIO.H>- b; n  P2 x' i$ i
#include <DOS.H></FONT></P>
! l4 ~' V6 s. p) y3 x<><FONT color=#0000ff>/* function prototype */
/ o( o5 D$ Q& N6 Cvoid writechar(char ch); </FONT></P>% E1 ~. o- k' a& P& I8 O' |/ e1 |
<><FONT color=#0000ff>int main(void)
, a; G9 ]; E' X% X  H$ r- U{
2 r6 r$ L4 {( X5 s9 eclrscr(); - w4 M, X: _3 ?: n  L
gotoxy(80,25); + D2 @& D+ U. O5 w; K
writechar('*'); & m7 A+ d$ G" y' y: F' `
getch(); 4 Z4 v8 J6 e. i6 \4 X- J
return 0;
5 M3 W' ?/ e2 D: i} </FONT></P>1 _. r  Z! @: i: E" d* @8 I  ]
<><FONT color=#0000ff>/*
4 U) L4 g8 x) t: v; e, W$ ?outputs a character at the current cursor " Q; q0 G; T! H2 j8 i& g
position using the video BIOS to avoid the % d' @; h' U4 |/ P! p; X
scrolling of the screen when writing to
6 _& y- g" A( p% U& u2 C2 K% Llocation (80,25).   q8 w( E$ p: {+ ^0 o9 b0 H$ f
*/ </FONT></P>
5 A) J- V% D1 W) o<><FONT color=#0000ff>void writechar(char ch)
' V  `( Z& N, }6 A% b/ O- Z, [{
' a% g9 V7 J6 I6 h, N. g# q! l# \struct text_info ti; 6 q1 F3 F' P% A% }
/* grab current text settings */ * B7 T; R7 z; n0 |
gettextinfo(&amp;ti); 8 b. l% y) a" v9 `+ y! @+ u
/* interrupt 0x10 sub-function 9 */   t6 A4 L  c# c2 `( X8 s0 I
_AH = 9; , ~. g' l2 I) @! C8 I0 M# R. ^
/* character to be output */
0 }8 j. J1 B+ T' F1 q) ]: n_AL = ch;
+ G. k$ U% G: t) l$ \_BH = 0; /* video page */
9 N! ~9 ?& L; D  F4 E* U_BL = ti.attribute; /* video attribute */ : Z* S! g; x! g) }
_CX = 1; /* repetition factor */ ( t1 a6 K. F5 Y2 q4 o! h4 r' e, V
geninterrupt(0x10); /* output the char */ ( J' w& O& z% D: g: l* v. X# z
}
1 x: R( Y% B3 V1 i, i. x  n1 U" {2 D</FONT>4 {# m2 {2 O! }9 o. u2 z
</P>
1 ]0 R$ V  F5 q<><FONT color=#ff0000>函数名: getarccoords </FONT>
+ q& C' B6 O& c: @7 p6 p功 能: 取得最后一次调用arc的坐标   B1 e7 O/ c5 }* R! w; y
用 法: void far getarccoords(struct arccoordstype far *arccoords);
, O" u* R2 s5 L( _2 i! W( i5 e  j! f程序例: </P>6 h4 M! w/ ^4 i+ ?& b- B/ e
<><FONT color=#0000ff>#include <GRAPHICS.H>" B; Z" d) i" G* e4 o
#include <STDLIB.H>
5 A. L" D3 I. Z- C  P) D( q" j5 Z#include <STDIO.H>
0 P; _! L5 f$ H$ h#include <CONIO.H></FONT></P>, S' ?  _4 t! g& \6 `9 }2 Z
<><FONT color=#0000ff>int main(void) ; ^. o" `: I+ j1 J2 s5 r
{
. f% d5 O+ a6 n0 L" u/* request auto detection */ 5 c8 D) V5 Y6 p  I$ t
int gdriver = DETECT, gmode, errorcode;
: d; ~" N% b* u5 l! N. ?8 A7 ?struct arccoordstype arcinfo; % e5 b1 R* D" ]/ f& r
int midx, midy; 9 [+ O9 H4 e5 i2 b6 t/ J
int stangle = 45, endangle = 270; " ?: @! f7 C2 E! l9 \# [4 o
char sstr[80], estr[80]; </FONT></P>. I8 c8 N+ A' }  d# H
<><FONT color=#0000ff>/* initialize graphics and local variables */ ) |0 M4 Z2 c! G: n( s
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
) v0 c! u: ?* t. X' e$ U<><FONT color=#0000ff>/* read result of initialization */ $ y  E) h+ b( j
errorcode = graphresult(); 3 K( Q  C7 e  s9 I9 f
/* an error occurred */
/ X0 R3 t0 p3 d8 m5 `$ rif (errorcode != grOk)
# V! _* b1 [( R6 f; s+ H1 m{
+ U3 y' ?8 o: j: k# H$ Dprintf("Graphics error: %s\n", * _4 n/ z& \0 ?, T2 c
grapherrormsg(errorcode)); 5 R3 q4 O! O. I8 r/ Z
printf("ress any key to halt:"); 8 X. Z. i" f9 E1 ~% e
getch(); - Z% W: |. G( ]8 w' F6 I/ P6 ^
/* terminate with an error code */
) Z% b( t5 E) v% e2 m% rexit(1);
) e. ~0 M$ @" Q2 b} </FONT></P>. L. n+ l" w4 s
<><FONT color=#0000ff>midx = getmaxx() / 2; + M6 ^/ q# }6 g, Z
midy = getmaxy() / 2; </FONT></P>
2 L$ b2 R5 Z& _; v9 C) H<><FONT color=#0000ff>/* draw arc and get coordinates */
9 `& W4 {* n0 g$ N/ L: w1 psetcolor(getmaxcolor()); 5 K+ e8 S# V% Z4 _  \0 f2 i+ c8 }
arc(midx, midy, stangle, endangle, 100);
$ ~; h# L. N* K, `9 Vgetarccoords(&amp;arcinfo); </FONT></P>2 |( w) \# q/ Q# {. {/ l
<><FONT color=#0000ff>/* convert arc information into strings */
9 F9 d4 z/ a/ H8 F' @/ A! Csprintf(sstr, "*- (%d, %d)",
' l. m2 S5 V/ s# j5 qarcinfo.xstart, arcinfo.ystart); $ L7 b' {# j: {* P6 Q
sprintf(estr, "*- (%d, %d)", " g, d  d- x7 [& m
arcinfo.xend, arcinfo.yend); </FONT></P>; S3 {6 O: B/ F  y/ ?$ Z
<><FONT color=#0000ff>/* output the arc information */ 9 y3 t4 k1 g5 ~
outtextxy(arcinfo.xstart,
( U' V* [# }1 i& p' F, Garcinfo.ystart, sstr); ' k( l! [& o  z9 @6 r  d
outtextxy(arcinfo.xend,
8 L& r6 d+ x( V1 varcinfo.yend, estr); </FONT></P>
& v8 u, U4 E1 E" S<><FONT color=#0000ff>/* clean up */
+ e, i$ |. L5 I- ^/ Q- _, Tgetch(); - ?$ n* c# W3 d
closegraph(); ! Q6 L+ K, L5 U
return 0; 6 _4 S0 w% P% X4 _# G! \. Q
}
- F0 M) d: V  d: a2 c$ B+ [</FONT>
% ~& p% m5 m- _2 ~! {& T
& ]% g$ a9 n. R2 j' j</P>" o* n+ O- \' i" K) D6 m! p$ o
<><FONT color=#ff0000>函数名: getaspectratio </FONT>
/ I0 K# H. A% `功 能: 返回当前图形模式的纵横比
) L4 d& Q) \# T, M/ ^用 法: void far getaspectratio(int far *xasp, int far *yasp); 1 T3 z1 }. W* M6 B1 a  S6 w
程序例: </P>
  B" K# V4 ?* {. p/ }2 `' ]1 ?) ^<><FONT color=#0000ff>#include <GRAPHICS.H>
  E  ~6 H2 ]0 f" u6 w* v#include <STDLIB.H>+ y' u: B. j) A  @
#include <STDIO.H>
7 ~8 a: h7 z: q( Q7 t7 V$ o#include <CONIO.H></FONT></P>
: n$ K# T( z1 t3 }; v<><FONT color=#0000ff>int main(void)
* g; S5 s  ]: d3 r$ J# p{ " [' W& J- K) w: p0 ]# t1 _  q
/* request auto detection */
% K2 @" Q- R' Rint gdriver = DETECT, gmode, errorcode;
' c( F+ [8 l6 \5 p' zint xasp, yasp, midx, midy; </FONT></P>: b, J  L% q+ J) _/ n
<><FONT color=#0000ff>/* initialize graphics and local variables */ 9 j" S, U) Y% z
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>1 b3 L9 d: N: s9 \" o( y0 V
<><FONT color=#0000ff>/* read result of initialization */ 3 @9 j$ m& V" B9 ]
errorcode = graphresult(); ! K$ k$ l, e) Z8 `: j
/* an error occurred */
4 H) P. J! z1 X* F4 G- g0 Kif (errorcode != grOk) / d9 d) w# \3 a3 |8 L
{
  w' s1 p7 ~: Z7 O  |, fprintf("Graphics error: %s\n",
" c3 t; S# m' Jgrapherrormsg(errorcode)); ) v! S9 w' Y4 ^: D. g3 ?7 n4 _
printf("Press any key to halt:"); # }* N8 @' k9 Z" q# `: }
getch();
0 J5 e+ L5 Q; A  H5 h/* terminate with an error code */ 5 i9 R/ g( X$ h) N+ I: n% H
exit(1);
6 b# {( {2 k# n2 `$ S} </FONT></P>
# @* K2 w" B( }, W* L<P><FONT color=#0000ff>midx = getmaxx() / 2;
4 @+ D- Y) ~* Fmidy = getmaxy() / 2;
7 y/ d* j& k/ a) osetcolor(getmaxcolor()); </FONT></P>
; X( j9 L* F4 C5 s. \<P><FONT color=#0000ff>/* get current aspect ratio settings */ , C+ M- N: z0 C  h+ w+ z
getaspectratio(&amp;xasp, &amp;yasp); </FONT></P>7 ?0 Z$ t$ Y1 ]- P4 e
<P><FONT color=#0000ff>/* draw normal circle */ - T* p& L/ o/ T3 J9 j: b( I1 B
circle(midx, midy, 100);
8 a# i- }& ^9 X% w" m. e4 Tgetch(); </FONT></P>
7 e; j- m& t" D3 T<P><FONT color=#0000ff>/* draw wide circle */
7 o6 A1 M% F3 _+ j9 r/ Wcleardevice();
! m7 n7 n  l+ `6 y5 f/ C$ H- Y0 Lsetaspectratio(xasp/2, yasp); ! f. G5 |# M4 |) J$ f1 e* d/ g
circle(midx, midy, 100); * R# i0 u5 L3 M
getch(); </FONT></P>
& J5 I8 ~4 z5 L7 _, w8 g" N9 ]<P><FONT color=#0000ff>/* draw narrow circle */ * e$ N! u" g: V
cleardevice(); . T/ d/ c# g, w, |3 F: X
setaspectratio(xasp, yasp/2); % I+ J# H- r/ ?
circle(midx, midy, 100); </FONT></P>
% E* ^# a' h" e: C0 n<P><FONT color=#0000ff>/* clean up */ 3 t9 `$ f0 b- J% u
getch();
: c" V$ W6 v; S- pclosegraph();
$ x/ _8 x/ }- x) lreturn 0;
/ V. @& _1 C9 Y}
2 V3 R3 K7 q$ I- y: q- }4 J( k& v</FONT>
4 r, [# ^, p3 ^' L" }# }) B* q  u8 Y4 x
</P>
, j6 `5 I2 @8 j7 x- u) k<P><FONT color=#ff0000>函数名: getbkcolor </FONT>% O3 c1 b3 j! b
功 能: 返回当前背景颜色
# [) q4 z- I  B1 n) S3 l用 法: int far getbkcolor(void);
) ]* s/ Q$ S- a& ^' m( S程序例: </P>
- {) v1 V9 b, b( [, f$ _- \<P><FONT color=#0000ff>#include <GRAPHICS.H>: i  P5 J6 E5 u/ ~8 j
#include <STDLIB.H>3 F/ o- u- V8 v* I) z
#include <STRING.H>1 Y) C* \% ^/ P4 P/ r- b% T0 Y
#include <STDIO.H>
9 E# N' V4 q) g! k' e% j3 J/ i#include <CONIO.H></FONT></P>, I2 ~% t7 A8 a: o1 K. q
<P><FONT color=#0000ff>int main(void) ' q1 q+ O; A3 z
{
& l6 M5 l+ _' a4 ]' R/* request auto detection */ ' _/ v. m& N$ b1 `) K  ~+ J
int gdriver = DETECT, gmode, errorcode;
3 c' q' A/ N+ P) |6 Sint bkcolor, midx, midy;
& t) f6 v; a" }0 a: Q3 H8 vchar bkname[35]; </FONT></P>
4 c+ I7 L# [0 e<P><FONT color=#0000ff>/* initialize graphics and local variables */
0 D6 z3 g/ f. B: z1 g8 U9 Cinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
6 `" w( b3 n8 I+ g" C  H: p<P><FONT color=#0000ff>/* read result of initialization */
) d; M8 H/ K; E9 w7 Perrorcode = graphresult();
; r( r- X- K# y8 ^) i! l) t/* an error occurred */
: @1 S% Y, `! M; zif (errorcode != grOk)
$ }/ B- X% v+ C6 M6 m" B  V0 B{
) I7 M! X( I7 G- r2 [$ w' L3 eprintf("Graphics error: %s\n",
& C0 v: D' g5 ^0 |grapherrormsg(errorcode));
6 G) h+ V" w7 J" t2 _7 v0 |printf("Press any key to halt:");
/ v6 Z# h( o9 x" C3 n# h( xgetch(); % Q) d% N2 Y- I( N( m' G" i, J
/* terminate with an error code */
; `$ E* l1 i! }8 Kexit(1);
. q9 D) O# m4 j: W) F; l. `} </FONT></P>' H+ n# Q8 T( a  G, u. E% a, w
<P><FONT color=#0000ff>midx = getmaxx() / 2; 4 ]' L3 ]% o; h7 D: f# N4 i% H
midy = getmaxy() / 2;
7 G9 e! z4 X  k9 dsetcolor(getmaxcolor()); </FONT></P>) ^- y1 m; B; K7 `
<P><FONT color=#0000ff>/* for centering text on the display */ 7 |  g$ x) B: ]$ [7 n: @
settextjustify(CENTER_TEXT, CENTER_TEXT); </FONT></P># d, ?2 v; v5 f+ K1 I" t5 x! G
<P><FONT color=#0000ff>/* get the current background color */ % s1 H/ p8 v) R- ?
bkcolor = getbkcolor(); </FONT></P>; x3 F( ^% v- r/ n& X# ~6 B* _$ ~
<P><FONT color=#0000ff>/* convert color value into a string */
( _+ J3 K7 V1 ~8 F& n; xitoa(bkcolor, bkname, 10); 1 v' E+ V2 V7 z" L: \
strcat(bkname, # d" Z* l& L& O  s
" is the current background color."); </FONT></P>: z# F7 g5 l5 m9 ^! a7 P
<P><FONT color=#0000ff>/* display a message */
1 c8 \/ o6 F1 _; Z" L" h$ Bouttextxy(midx, midy, bkname); </FONT></P>
+ q1 I2 |1 b; y1 J5 C2 H4 H<P><FONT color=#0000ff>/* clean up */ ) z$ z* u8 j$ c' w: |
getch();
5 S0 _1 g, S) f3 q* rclosegraph(); % B, a& |0 J! \
return 0;
( g0 d7 |7 q' f. T, A}
$ W+ V0 S( B9 B" w) G/ W, V" Q3 q/ \; N6 v& ]
</FONT>
+ I3 l5 j3 q4 r</P>
9 X7 i) J# _* d% X8 I<P><FONT color=#ff0000>函数名: getc </FONT>. j% w3 B- U& V
功 能: 从流中取字符 : y. p/ A% ]3 U+ q8 R0 l  R
用 法: int getc(FILE *stream);
' U. [0 P* X8 ~/ ?9 @程序例: </P>7 O, Z" Q6 `, j. Y. ^1 U
<P><FONT color=#0000ff>#include <STDIO.H></FONT></P>% b* p2 z+ q6 ?
<P><FONT color=#0000ff>int main(void)
5 `+ U6 M1 u3 O& K. e2 I; t6 |{ 9 T7 \# Z& a) ~! q, m8 A$ P
char ch; </FONT></P>; ~8 \8 ]4 j( N& a- Y) O
<P><FONT color=#0000ff>printf("Input a character:");
# u5 ]' J4 w7 O! M/* read a character from the
" P% B0 R  r! x( O5 ostandard input stream */ / p9 O: ?$ ^0 p/ R
ch = getc(stdin);
3 L' k. b. U" G0 nprintf("The character input was: '%c'\n",
2 E' U. j8 F) i4 E0 D. O/ j, Rch);
, i: K- y- a  l; ^/ H1 Dreturn 0; . {! m7 H, G. ~' y5 ^3 s
} 4 W* ~( N3 Q; A! Z) A
$ g: {  P/ F8 N! L' }& r- X
</FONT>
/ L$ F) `) e7 F) b% K</P>& ]0 S6 E( z( Q3 e/ _
<P><FONT color=#ff0000>函数名: getcbrk </FONT>0 J8 V  n- [" l4 @$ U5 D
功 能: 获取Control_break设置
7 o: y3 c+ p5 s# k" _用 法: int getcbrk(void);
6 S, }/ B8 N  I0 x程序例: </P>6 n& H  Z; K$ P5 O  i# R
<P><FONT color=#0000ff>#include <STDIO.H>& N7 A. y7 Y' v& ]
#include <DOS.H></FONT></P>
( g2 Q  }1 e6 Z2 U$ d+ G<P><FONT color=#0000ff>int main(void) ' X& W" D; \1 a
{ & |% h: b, E9 [( k
if (getcbrk())
8 @' T8 Q# G! v0 V& J8 Fprintf("Cntrl-brk flag is on\n"); - E  B5 u& `4 H% B! r
else 3 ?* |* k# k/ |! ~  ]$ m1 X
printf("Cntrl-brk flag is off\n"); </FONT></P>
% d8 e7 [( b3 f! x: h6 @' H<P><FONT color=#0000ff>return 0; ! v: S# M. {3 H% X1 g
} </FONT>
9 `8 D; A6 l4 H# |3 X2 [/ U0 }" |8 z3 Z
</P>7 v7 x' F, y3 |
<P><FONT color=#ff0000>函数名: getch </FONT>
$ b3 w2 F& X$ S% v功 能: 从控制台无回显地取一个字符 7 I& `! {2 X! l+ ~% ]" b+ _
用 法: int getch(void);
+ t# x! m2 C" U: B* m程序例: </P>! V' [& Y1 m8 c- @1 e+ O
<P><FONT color=#0000ff>#include <STDIO.H>
% Z, e3 H" Q- R5 ]#include <CONIO.H></FONT></P>
$ k; z; f% G& ^' g<P><FONT color=#0000ff>int main(void) ; n1 W4 m& B% W2 G  e9 D& ^% B
{
" M+ g! x% _* bchar ch; </FONT></P>
+ }  g( D3 X; O3 a; t% V<P><FONT color=#0000ff>printf("Input a character:");
4 `: g: \  ?! N5 Ich = getche();
( e- u) H5 E0 y+ J0 i2 Hprintf("\nYou input a '%c'\n", ch);
2 _  s+ f: d4 @$ l, j4 f8 k" L/ breturn 0;
- r, ~1 j$ o& h8 h9 _' |}
) ?! ?! r7 G7 E, B4 P2 N' A4 y  t8 z, o) H
</FONT></P>9 u5 U2 t+ R/ J) ~! r" y$ f
<P><FONT color=#ff0000>函数名: getchar </FONT>
! A0 n% x7 }* {* ]0 ]- B功 能: 从stdin流中读字符
% D6 T8 l$ N2 v+ l0 _用 法: int getchar(void); ' C3 _3 ~' j( r1 B2 o2 W$ T1 s
程序例: </P>9 B& e5 i6 l3 J- \
<P><FONT color=#0000ff>#include <STDIO.H></FONT></P>
7 p+ b/ N( a# ~% a% w6 t( b<P><FONT color=#0000ff>int main(void)
8 O  V6 }' W! o; v{ 3 W0 y5 V; R5 j8 c  N
int c; </FONT></P>% @2 H7 s# y+ n! {( ~* x
<P><FONT color=#0000ff>/* Note that getchar reads from stdin and 3 J: i/ R! E7 v- B3 a9 _3 ?
is line buffered; this means it will 9 T8 ?" p& v. t( c3 m
not return until you press ENTER. */ </FONT></P>
0 M/ q& x! w# V6 t<P><FONT color=#0000ff>while ((c = getchar()) != '\n')
4 m+ E; U2 ]5 S' kprintf("%c", c); </FONT></P>* S) H; M  ^, p/ U5 E8 v4 F
<P><FONT color=#0000ff>return 0;
* G+ s5 j' j  l( N& G, ]; P}
: u) \0 u. O5 j3 C  H, H4 k</FONT>3 ]! f* L# S! m  h$ x9 p
</P>* }% p( u3 |( E7 i/ K
<P><FONT color=#ff0000>函数名: getche </FONT>9 ?0 K6 m  M- q' Q) O4 T( V( d
功 能: 从控制台取字符(带回显) - E0 E: ?/ M# z+ d
用 法: int getche(void); 4 S, |2 p7 ~; L5 h
程序例: </P># p, w% q7 t5 q. X/ ]9 p* o3 d" c
<P><FONT color=#0000ff>#include <STDIO.H># @) _9 O0 d& ?" M  r5 c- l
#include <CONIO.H></FONT></P>- k$ ]8 z3 f1 X' h- H( u; f
<P><FONT color=#0000ff>int main(void) 4 y2 ?  `7 x! E2 b
{ ) m: E: V0 t. B2 x% k  g
char ch; </FONT></P>
; B8 m4 c5 S1 U4 W  w% L: B<P><FONT color=#0000ff>printf("Input a character:"); / W5 c# K0 e4 _, U
ch = getche(); 2 v# X$ A$ S, q) Y
printf("\nYou input a '%c'\n", ch); ! G% z6 P8 \! X$ q* i" G  n
return 0;
; P, }% i$ A: U}</FONT>
2 P4 N3 g2 n& K1 d" C9 T5 B  u# M1 T( F2 S, w
</P>
, M5 I$ i2 u- _' \& x1 V<P><FONT color=#ff0000>函数名: getcolor </FONT>
; Z, G; @  |1 G) J! e0 J功 能: 返回当前画线颜色 & ]! K! i! c3 p8 j; l( o. L5 j
用 法: int far getcolor(void);
+ S) `% \2 [0 D6 I6 M- `程序例: </P>
1 @9 V# f7 S1 @, p* {& U<P><FONT color=#0000ff>#include <GRAPHICS.H>
) w+ K% U& ?6 [9 z5 c) @#include <STDLIB.H>
# d7 D! M, F7 v# M1 o: Y' N+ x#include <STRING.H>0 j0 ~% X, @1 I# x
#include <STDIO.H>/ Y) u1 u9 G/ O% G
#include <CONIO.H></FONT></P>  ?: m, |9 t) V# R8 g) X% U) Q  m: L
<P><FONT color=#0000ff>int main(void)
  @# H* }7 v5 ?4 c; ^{ ! X) B# r1 R3 C. f
/* request auto detection */ & w) b" l3 z) w
int gdriver = DETECT, gmode, errorcode;
/ @: l3 t' p: H4 B. Uint color, midx, midy;
; O* ^1 A- `# Qchar colname[35]; </FONT></P>0 D7 ~: E1 G# m( L
<P><FONT color=#0000ff>/* initialize graphics and local variables */
- _4 q& o' E' E- b  n/ V0 g2 jinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
1 j$ M4 d: @7 _/ P8 w5 L; q<P><FONT color=#0000ff>/* read result of initialization */ . }7 I6 K' |/ R' z3 b% J5 J
errorcode = graphresult();
5 X1 I8 a9 N8 Z/* an error occurred */
% E7 w8 c. \! Q$ sif (errorcode != grOk)
0 W4 T5 p5 b/ g, ~{ / c. D% z! @, E9 u
printf("Graphics error: %s\n",
* g9 C9 i9 O/ H) Pgrapherrormsg(errorcode)); 0 O0 W4 ?# h% z  V
printf("Press any key to halt:"); ! q( t! c( k! I: s
getch();
+ V- m5 o. O+ a1 G1 B- m/ W# o) B/* terminate with an error code */
6 R2 z: R9 @) Lexit(1);
6 b6 u7 k; |4 P$ f5 y1 T) U} </FONT></P>
' o% C% @  b) B. B# r0 M( R<P><FONT color=#0000ff>midx = getmaxx() / 2;
- w+ E5 z/ N* H& t' n, Jmidy = getmaxy() / 2; 9 H& t& C) V, X; G7 ^! K* J9 V. b
setcolor(getmaxcolor()); </FONT></P>
6 i0 d$ w/ U5 s* ^# v<P><FONT color=#0000ff>/* for centering text on the display */ % k/ s! L4 a0 ?% V
settextjustify(CENTER_TEXT, CENTER_TEXT); </FONT></P>6 l# |8 x) m5 l+ U/ J( D
<P><FONT color=#0000ff>/* get the current drawing color */
, x1 A1 Z3 V- s+ d9 l' pcolor = getcolor(); </FONT></P>
1 n+ O' }4 K& T% t4 s# h<P><FONT color=#0000ff>/* convert color value into a string */ 4 E, I& d/ y% M, g+ e
itoa(color, colname, 10);
; W1 D& b) W3 ~' k3 xstrcat(colname, / A/ ^7 k/ g7 n( @# h9 k* N' M% a
" is the current drawing color."); </FONT></P>
8 }5 a' C; f4 D<P><FONT color=#0000ff>/* display a message */ ' _) t7 s* h; f8 Z' B$ y( `0 h
outtextxy(midx, midy, colname); </FONT></P>
. J9 x/ k" b6 h3 m! L<P><FONT color=#0000ff>/* clean up */ . t3 u1 k( @% [/ x/ B
getch(); ' A# b8 o& _- M; f4 ]
closegraph();
! L) P7 [* n" E7 Q+ C2 j' E+ kreturn 0; 2 c- \: Y6 `# F+ }. m" a7 e
}
% x1 C7 i4 X, r3 A8 c, N</FONT>
" @, [* }& k% C/ S2 t9 V</P># J; }" l  i4 g+ N  |7 K
<P><FONT color=#ff0000>函数名: getcurdir </FONT>& r. C5 f7 W; O, ^4 y
功 能: 取指定驱动器的当前目录
% L4 \7 ]' r1 D$ K9 v2 j3 [用 法: int getcurdir(int drive, char *direc); ) {2 y' S$ @3 `
程序例: </P>( Q7 `5 A7 J4 J8 D5 u9 O
<P><FONT color=#0000ff>#include <DIR.H>
0 b2 ~* P& J; g  [3 n2 j#include <STDIO.H>
3 t1 l  v  R9 L9 m( _#include <STRING.H></FONT></P>" r7 H" i8 [+ N! L: l
<P><FONT color=#0000ff>char *current_directory(char *path) * F6 t" K# g( R0 O
{ ; }" V0 j+ g. Z; \! S  k& v
strcpy(path, "X:\\"); /* fill string with form of response: X:\ */
/ {: [% p: Q" L  [path[0] = 'A' + getdisk(); /* replace X with current drive letter */ % N# J# H: a' d# g. m) o( k7 C- x
getcurdir(0, path+3); /* fill rest of string with current directory */
: i! s. h# f8 M, {# V3 s' Xreturn(path);
) s8 L' Z7 S& B0 u; c1 k: p9 {} </FONT></P>( c' c7 V1 N8 S) Z0 O0 T
<P><FONT color=#0000ff>int main(void)
0 f# }4 ?2 H5 ~1 Q- h{
1 ]' E. _% @$ ?( {* t4 mchar curdir[MAXPATH]; </FONT></P>
) `% Q7 M; z. _. y0 |. S<P><FONT color=#0000ff>current_directory(curdir); 5 R8 ~5 p1 {  ?  L! ~& _
printf("The current directory is %s\n", curdir); </FONT></P>" u6 F: ^  _8 e# L0 D7 p! W
<P><FONT color=#0000ff>return 0; , d8 L' H) w4 x2 o
} . V! N6 E1 ?" x4 ~- v4 t. }* v( a
</FONT>8 _# [7 s4 H  u
</P>: t6 g3 T- c& ~! t1 C: }
<P><FONT color=#ff0000>函数名: getcwd </FONT>* @4 h) P4 ^/ X6 `
功 能: 取当前工作目录 : v+ {5 o8 H; a, G2 a- d* z5 C
用 法: char *getcwd(char *buf, int n); # R9 a5 O5 M+ L8 V& h
程序例: </P>) e+ |$ l$ ?! B0 |' H3 z5 }
<P><FONT color=#0000ff>#include <STDIO.H>
; h* m  s# V4 K* u6 \3 I9 |#include <DIR.H></FONT></P>  \% Z( l" x: r/ s
<P><FONT color=#0000ff>int main(void) 6 k1 ?( b; `$ b* Y& B1 ~
{
  N4 X# S' {" _2 A% _( |char buffer[MAXPATH]; </FONT></P>9 i( M4 {, h, T( ~* h& L6 a# {
<P><FONT color=#0000ff>getcwd(buffer, MAXPATH);
7 G$ a& X( _5 P+ S4 Bprintf("The current directory is: %s\n", buffer);
& n. A; M2 i- m6 X/ breturn 0; 8 b$ @7 l4 U: |2 ]
} </FONT>
2 g& q1 r7 _. A- r9 f: Q
1 Y: t3 p) x, ]% |</P>6 x! W4 V% |' i: B  O* L
<P><FONT color=#ff0000>函数名: getdate </FONT>
2 R6 O; m" R; m7 k# X9 n功 能: 取DOS日期 - [6 [. x3 z5 x) {. q6 ^) K
用 法: void getdate(struct *dateblk); 3 B( w7 t& s, \" c1 r
程序例: </P>% c9 M+ [# J; Y$ Z, `" g# r, x5 I- f
<P><FONT color=#0000ff>#include <DOS.H>$ n8 b/ |1 b" u
#include <STDIO.H></FONT></P>
6 S6 l6 x: ]7 C2 o<P><FONT color=#0000ff>int main(void)
8 ?" y& w9 n& ?# G3 Q- Y0 j{ 8 S# t7 v! u6 b) n$ I+ f
struct date d; </FONT></P>
& @- S" i9 |, u<P><FONT color=#0000ff>getdate(&amp;d);
) |* ]! a! M+ j. U1 Zprintf("The current year is: %d\n", ! Q2 H9 C) f6 E& Q4 s" U+ p
d.da_year);
9 N$ h' Y3 V. k0 Nprintf("The current day is: %d\n", / x5 u0 P  s! C( B
d.da_day); - c5 I# G+ N- M; a& e' t
printf("The current month is: %d\n",
4 d% Z1 t& p3 i: ld.da_mon);
, R( N/ O. K6 r( freturn 0; 6 j, `$ P% c5 M, {9 m( q
} ( T# A$ H, w: }
</FONT># o  |0 l4 x" ~: M- G& s
</P>4 x4 L5 P" ]* E- \, P* _
<P><FONT color=#ff0000>函数名: getdefaultpalette </FONT>
) J) I: l8 b- ^; k2 X功 能: 返回调色板定义结构 , ~/ D/ V6 u7 `9 j* I( C
用 法: struct palettetype *far getdefaultpalette(void);
1 @- p6 d9 X0 H& P! Y2 _" a$ c程序例: </P>0 f& o! v8 a& B  G
<P><FONT color=#0000ff>#include <GRAPHICS.H>
7 ]7 A9 @6 e) e. v5 D  N0 S#include <STDLIB.H>, ]( n  b) w( k. ~8 c6 W( l
#include <STDIO.H>3 v, P, p: H" t2 S7 q  l
#include <CONIO.H></FONT></P>
; Y  l4 b- y4 }<P><FONT color=#0000ff>int main(void)
: P5 k% X) x6 J! _{   C" g% o3 d  d( X- m6 N' w& e
/* request auto detection */
* [2 x: |/ ~! {8 w1 }' O2 l3 M( Rint gdriver = DETECT, gmode, errorcode; $ l2 R% O; \  y5 [9 y
int i; </FONT></P>
* s" G7 m% E: s3 [, B8 ~& A6 n<P><FONT color=#0000ff>/* structure for returning palette copy */
( W- r# l. P& h  i) g+ w. d0 zstruct palettetype far *pal=(void *) 0; </FONT></P>
8 k4 A6 h& {" g% z& B1 u3 i<P><FONT color=#0000ff>/* initialize graphics and local variables */
2 o; U! S8 G" N& q' X# q$ C! hinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>4 {& a; R: d  x& `8 G
<P><FONT color=#0000ff>/* read result of initialization */ ' r1 A; s5 j+ i$ |) t
errorcode = graphresult();
1 T+ G- ~1 p8 _# M: p  H7 Q/* an error occurred */
, @& Z" O5 s# u) B# O4 Tif (errorcode != grOk) $ u! \3 W8 M1 R% m" W; n) k  Z8 F0 I
{
2 I- d% g5 i- v. |& Kprintf("Graphics error: %s\n", 1 `& U5 X' y$ p7 g6 N& ~
grapherrormsg(errorcode)); # R4 S6 y8 {6 {) d0 i9 b
printf("Press any key to halt:");
4 A$ P* d0 z9 t7 x; L4 I& Egetch(); 2 S- d2 a, X( E+ u/ U* V4 T
/* terminate with an error code */
; {1 ~- b# \9 ^! u/ j  N5 g# R$ @exit(1);
0 u0 B7 S& a% V9 Q} </FONT></P>6 q% |# g/ `+ z& e% u! t! ?
<P><FONT color=#0000ff>setcolor(getmaxcolor()); </FONT></P>/ k9 a  e. ?9 C& T
<P><FONT color=#0000ff>/* return a pointer to the default palette */
0 B# d, ]$ m" [5 W$ y( R0 Mpal = getdefaultpalette(); </FONT></P>  R" e1 D3 n" Q% o* B. K9 {
<P><FONT color=#0000ff>for (i=0; i&lt;16; i++)
2 B; f* x& M% C6 t; O7 I: C5 A: c{ 7 T8 K+ y9 b+ a# m0 y
printf("colors[%d] = %d\n", i, * o1 j# l1 c4 n1 g" R) _5 n
pal-&gt;colors); 1 ^) Y4 Q5 _5 D2 }* ]9 x' f
getch(); " k5 D( \) g' q8 o5 {. i- n
} </FONT></P>' T3 M) D4 _- U3 e( d+ F# O
<P><FONT color=#0000ff>/* clean up */ ' k: ^9 x+ _. t  ?) G
getch();
0 p, C2 [2 ~% a) C1 n4 ~. y- T0 xclosegraph();
) F3 p# l4 D% x# E' W8 s7 ureturn 0;
- `3 M+ f9 V( @- R' ?}
- f$ D9 q( d. e* t2 A2 _8 l% c0 S</FONT>2 g# K! f0 r0 M% x
</P>
& f3 h7 K/ [% w# }! O2 @<P><FONT color=#ff0000>函数名: getdisk </FONT>8 s9 I" m' B! \( L3 E
功 能: 取当前磁盘驱动器号 ( r. c7 N0 M3 _' s$ X2 ~( `
用 法: int getdisk(void); " E$ ]. h. A( ~. Z
程序例: </P>! m; _$ K4 [& ^3 v
<P><FONT color=#0000ff>#include <STDIO.H>% A3 t# ]0 [5 T8 Y
#include <DIR.H></FONT></P>
$ C) t' H9 y5 f& v/ U% X) y% u  x<P><FONT color=#0000ff>int main(void) 4 s- p+ f: e7 r0 c5 C( n3 @# e& Z$ `& Q
{
' [1 O1 i; f; f" G! B8 _& _int disk; </FONT></P>
6 |! `$ L3 `9 x0 j<P><FONT color=#0000ff>disk = getdisk() + 'A';
, A2 J6 r8 A5 s% z( ?printf("The current drive is: %c\n", & z: U1 u. I- }2 C
disk);
) ]& g& }4 r( g4 F7 ]+ |- m& Lreturn 0; , s7 }5 ]6 H. G" F2 ?. l* r4 J/ A1 A
} 8 {% H, r. O. z
/ ?$ ~8 w' R! o
</FONT>
& C7 _) Y, L5 s9 Z  a# x3 j, L</P>
2 m+ G3 p; `) R1 Y. n: H<P><FONT color=#ff0000>函数名: getdrivername </FONT>% p2 v/ O7 J& g9 A/ J
功 能: 返回指向包含当前图形驱动程序名字的字符串指针
' k0 H3 P; d) [# z6 ~8 m9 X用 法: char *getdrivename(void);
0 B7 ?. I& \! \4 i/ c1 R- r$ d程序例: </P>$ t/ |& ^' q) X% U
<P><FONT color=#0000ff>#include <GRAPHICS.H>7 M" C) q. j" q$ Z7 j
#include <STDLIB.H>
; Y/ X: W  S: v+ i& {#include <STDIO.H>
' \8 ?* c3 N6 i8 z" j/ l#include <CONIO.H></FONT></P>+ W: L' o5 S( M
<P><FONT color=#0000ff>int main(void) $ z9 ~" M/ i$ ^! c0 j7 l# M$ |
{
) i/ J8 `+ d$ R% d) Y# K/ _/* request auto detection */ ' _, w6 |* P3 @
int gdriver = DETECT, gmode, errorcode; </FONT></P>+ {+ q$ u! N( S% ?" U) X9 p
<P><FONT color=#0000ff>/* stores the device driver name */
/ j: r& s. B8 F! }- ychar *drivername; </FONT></P>, f" a/ n! P  F
<P><FONT color=#0000ff>/* initialize graphics and local variables */
4 o6 b. E" @  V6 a$ U/ jinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
. @# J0 g! F. Q6 [* ^5 M7 t<P><FONT color=#0000ff>/* read result of initialization */ 2 {* S5 i9 a9 O6 K
errorcode = graphresult(); 5 `+ r" X8 l3 g7 X2 M7 t7 z
/* an error occurred */ ' z5 W  Z/ S7 D4 Y9 n) b& X% ^
if (errorcode != grOk)
1 D$ j7 X0 X' ^! q{ 8 z6 w# L. S' q' W& O# B$ ?3 n! M& t
printf("Graphics error: %s\n", 8 I. c! j' `( h  D3 a5 b
grapherrormsg(errorcode));
" C8 b( U' b$ m  Z4 z5 R# Eprintf("Press any key to halt:"); ! z# x( m8 G' o) _7 U! `
getch(); : b+ y! E+ E+ V' v
/* terminate with an error code */
* I+ G6 a8 G5 [9 X7 }1 J% Gexit(1); 9 h: n7 o% ^, \% J8 E: {
} </FONT></P>
  A  Z* R# w8 u) q1 c  G<P><FONT color=#0000ff>setcolor(getmaxcolor()); </FONT></P>
5 I& j8 i" i( w) m5 N<P><FONT color=#0000ff>/* get name of the device driver in use */
0 E' W9 f2 j: Z! ~drivername = getdrivername(); </FONT></P>
4 M& @: ?' V6 r% h4 g9 o! G9 ]<P><FONT color=#0000ff>/* for centering text on the screen */ ! X2 p! j6 X6 a" y
settextjustify(CENTER_TEXT, CENTER_TEXT); </FONT></P>
5 H2 `1 L1 \0 I, O9 J. Z$ g<P><FONT color=#0000ff>/* output the name of the driver */
" p! e# W. {; _( Q) I8 r6 B& V* Fouttextxy(getmaxx() / 2, getmaxy() / 2, 9 c8 ]. u! L; K2 x* h3 _
drivername); </FONT></P>
$ O" j: D1 A$ \' `- \  s9 H<P><FONT color=#0000ff>/* clean up */ ( w( T( C# C2 e* M( Q  P4 c
getch(); ; I! q; }) N2 J$ l, R& Q' u2 S7 T- @
closegraph();
3 W  v6 m! P, u5 U$ c* `+ Areturn 0; : G8 L% L8 C4 r4 h6 w7 A4 O
} " ^& A" u% u# E; Q+ a; L. d
</FONT><FONT color=#990000>( H# `2 B6 g' j0 p# e- i- Q
</FONT></P>0 b' w! z3 v4 D; e! i
<P><FONT color=#ff0000>函数名: getdta </FONT><FONT color=#990000>7 U, J6 Q' o7 d. `* C0 ~
<FONT color=#000000>功 能: 取磁盘传输地址 - A: L. M' H+ I1 @' Z' [
用 法: char far *getdta(void); - R) N" I: w+ X" v7 t
程序例: </FONT></FONT></P>
2 K* H$ Y8 R) b# Q- _! d<P><FONT color=#0000ff>#include <DOS.H>4 i% a1 c! o3 g1 E  p. x
#include <STDIO.H></FONT></P>8 b! x3 U% k9 T  }' g
<P><FONT color=#0000ff>int main(void)
$ U9 B+ S6 y8 T4 N- i; Q& {{   m7 K: n8 g4 n( I
char far *dta; </FONT></P>" Z* Y2 u  M; B9 x; q  C
<P><FONT color=#0000ff>dta = getdta();   P$ f  Q6 r' q9 n# Q
printf("The current disk transfer \
6 ]8 W4 F- V- A" F# a8 Raddress is: %Fp\n", dta);
- E5 v5 E; @3 @8 R0 p- p5 greturn 0; 5 |! J1 U! y+ Y, c5 i
} $ D; U& L; y9 c# E4 X
</FONT><FONT color=#990000>
, h/ B  }, b8 W. G$ ^) X' D</FONT></P>% a  l: y3 ?4 Y) @, K+ h" L
<P><FONT color=#ff0000>函数名: getenv </FONT><FONT color=#990000>1 v' I' r, S9 [3 q! _# |
<FONT color=#000000>功 能: 从环境中取字符串 * }. V3 Z) U* f$ T( O" }0 L/ s! ?
用 法: char *getenv(char *envvar);
) F+ ?* |! h+ t  a( g! E; g# F程序例: </FONT></FONT></P>! h8 H& q! m; [4 {' N$ ?. i$ \
<P><FONT color=#0000ff>#include <STDLIB.H>
2 D  z6 Q+ w" ^9 m: A# R#include <STDIO.H># k" \* l: I8 e
</FONT></P>. l9 R& X) P$ ~6 N1 C$ K1 e
<P><FONT color=#0000ff>int main(void)
7 n& E0 l! ]7 d2 `( I2 \8 w{
( N' M- R* c  k+ |% R( w/ u6 Ichar *s; </FONT></P>
  D& ?! W4 x' @+ i* W' D! D<P><FONT color=#0000ff>s=getenv("COMSPEC"); /* get the comspec environment parameter */
1 e2 E$ y& L6 }' [' e$ @printf("Command processor: %s\n",s); /* display comspec parameter */ </FONT></P># \2 n1 S9 ?" b9 ~6 |6 L
<P><FONT color=#0000ff>return 0; & Z5 I  f! z) [5 z
} </FONT><FONT color=#990000>, M2 |  _$ U4 m! k2 k1 b
! K7 I  a9 O' u6 s+ o: l

3 {; h9 o% z2 B( p  @</FONT></P>& E% U# k" A2 R9 _5 z
<P><FONT color=#ff0000>函数名: getfat, getfatd </FONT>
9 {; z8 Z8 ]( q功 能: 取文件分配表信息 $ ?7 @  }& f! q! l0 [
用 法: void getfat(int drive, struct fatinfo *fatblkp);
  G) x- p! Y" _4 w+ q2 |程序例: </P>! H1 {. G( }5 @7 n9 I6 Y
<P><FONT color=#0000ff>#include <STDIO.H># [0 {9 R) s! Z1 F! [7 w* i
#include <DOS.H></FONT></P>- u; {2 \$ V" _$ g0 M  d# x% [2 o
<P><FONT color=#0000ff>int main(void) / E3 Z% D- q2 ^4 `) m
{
) P5 G- b3 d. [$ n7 g2 O/ c8 cstruct fatinfo diskinfo;
8 P& l  s, x: J7 [$ xint flag = 0; </FONT></P>
+ M& t; T  ~3 ]) n$ W<P><FONT color=#0000ff>printf("Please insert disk in drive A\n");
+ w  Q6 w- t8 t' s6 z" f! Cgetchar(); </FONT></P>
* [* p7 O; z: E' Q, ~# V<P><FONT color=#0000ff>getfat(1, &amp;diskinfo); ; \/ r  @! F4 b6 b) D! v3 ^; g
/* get drive information */ </FONT></P>
/ J4 w; o; k' a  D/ ~<P><FONT color=#0000ff>printf("\nDrive A: is ");
* \2 l1 O* |$ Eswitch((unsigned char) diskinfo.fi_fatid) : ]& z" e5 r3 Q0 `8 P: Q& e, L
{ + G: y( k9 J) I) i9 a$ h
case 0xFD: : n7 z7 ?$ V+ }) a) h2 V4 w/ @
printf("360K low density\n"); ! S& O. w8 J  b5 i! a
break; </FONT></P>
; D( H2 v7 }& \, K, E- d<P><FONT color=#0000ff>case 0xF9:
7 T' f5 v) ^0 [! Z4 g" A# W, lprintf("1.2 Meg high density\n"); & v9 a& @1 w. ^" d+ t+ I
break; </FONT></P>% |7 r) Q( R; d2 W) `, ?8 |* {0 d
<P><FONT color=#0000ff>default: 0 F/ C( V4 U: i  a/ W
printf("unformatted\n"); / G  z& u) J& d
flag = 1; 4 y6 U- Y5 i, ]) ]* K8 s# B
} </FONT></P>
, @" @* d6 D$ I+ `/ U3 T8 L" @0 J. j! j<P><FONT color=#0000ff>if (!flag)
- L. ~8 X( U- c( [{ / x; v2 p5 G9 l5 w) }
printf(" sectors per cluster %5d\n",
  w7 b6 ^( d4 s' \diskinfo.fi_sclus); 4 g8 u, i0 M$ u
printf(" number of clusters %5d\n",
2 L$ m1 O! p& ~5 |; a8 g' ~1 A4 Vdiskinfo.fi_nclus); ( F! T( d% g" g& Y
printf(" bytes per sector %5d\n",
: q/ j, n% v  z4 m5 @. M" Ldiskinfo.fi_bysec); 6 l/ Q# S( I- M! V0 ]
} </FONT></P>9 l( W8 k0 U+ L/ N) x9 Z
<P><FONT color=#0000ff>return 0;
+ m5 ?3 [3 w% `4 ^}
, O( s" P- |8 @' Y0 ~; C</FONT>
* s4 y0 T0 d+ m* U- v6 C- e+ }+ B</P>' P( [, P; D0 b" O6 @+ j
<P><FONT color=#ff0000>函数名: getfillpattern </FONT>( g2 g6 D0 ~, f' B0 P
功 能: 将用户定义的填充模式拷贝到内存中 5 a% N! [9 v6 W* i4 k
用 法: void far getfillpattern(char far *upattern);
, X: }0 T" p8 i程序例: </P>6 A+ w6 ?& e9 C7 H1 Z
<P><FONT color=#0000ff>#include <GRAPHICS.H>) p0 ^0 H: b" N0 S3 d. R( z# |3 N. Q
#include <STDLIB.H>
, M( R+ w" `% a  |! w#include <STDIO.H>
3 N# \& m) f1 h8 t2 O( M#include <CONIO.H></FONT></P>" b, J/ ]: X7 B7 E9 ^$ \6 u
<P><FONT color=#0000ff>int main(void) & o4 k& ~7 E) l0 a. T6 }
{ % q2 H5 e0 m( u9 x9 @7 J# ^0 ]
/* request auto detection */
6 m! A6 D5 d, N2 n  Bint gdriver = DETECT, gmode, errorcode;   r' }1 ^5 \% {
int maxx, maxy;
1 ]" X7 L0 K, M/ R5 v( z+ pchar pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27, 0x04, 0x04}; </FONT></P>
5 x) [( ^% G' `# @8 M8 |9 p<P><FONT color=#0000ff>/* initialize graphics and local variables */ / d  h- L5 H: a% [1 n0 @: P! M
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
6 @" E2 s: K) }- L1 ^/ V+ Q( M<P><FONT color=#0000ff>/* read result of initialization */
2 T- x8 f  V- ^. z' M, [8 werrorcode = graphresult();
. C& [/ r; Y1 I: U. m* ~. u, }if (errorcode != grOk) /* an error occurred */ 5 I9 Q) E1 C" q* W9 N0 Y
{ 4 @* j  ^9 a, v+ Y' E" f3 |
printf("Graphics error: %s\n", grapherrormsg(errorcode)); * j' y. j# K" F3 V& p
printf("Press any key to halt:");
9 b7 q6 _- ?+ H  R! d: E, Dgetch();
& N% M# S2 Z" x) J4 Z" H) i3 o& gexit(1); /* terminate with an error code */ # }! I  t; m* W! P4 c! l, R
} </FONT></P>  p: J" x; `# B2 ^( _
<P><FONT color=#0000ff>maxx = getmaxx(); $ ~! |$ T' _0 Y# \, q; t
maxy = getmaxy();
  t6 ~! t8 h4 usetcolor(getmaxcolor()); </FONT></P>$ `+ F, ^4 K' ]. v$ j4 }0 i
<P><FONT color=#0000ff>/* select a user defined fill pattern */
2 P5 l3 M9 j/ S$ {/ `setfillpattern(pattern, getmaxcolor()); </FONT></P>
. {3 d3 ?& t& }% R) }* H<P><FONT color=#0000ff>/* fill the screen with the pattern */
" Q: c+ b# }" Z- Rbar(0, 0, maxx, maxy); </FONT></P>- O6 L! L9 i5 `  q- M9 Z1 M
<P><FONT color=#0000ff>getch(); </FONT></P>8 V& t% m& |! o
<P><FONT color=#0000ff>/* get the current user defined fill pattern */ " W3 f- l! H, Q' E8 t6 s! t7 U
getfillpattern(pattern); </FONT></P>
- h( p; C+ e8 A: ^6 j<P><FONT color=#0000ff>/* alter the pattern we grabbed */
" L/ i' g" K' k: Y/ x  Hpattern[4] -= 1;
' j3 Q: O+ c/ p2 h8 Ypattern[5] -= 3;
- D: D/ J' ~% d4 D% Ypattern[6] += 3;
5 O* A* }+ c* \4 G5 G2 j7 Zpattern[7] -= 4; </FONT></P>0 Y& h4 i5 _1 t2 [5 s
<P><FONT color=#0000ff>/* select our new pattern */
5 K* X8 K6 ~. y3 W# A  n7 i. Xsetfillpattern(pattern, getmaxcolor()); </FONT></P>
; \6 `; e3 r6 I" \: s% I, B9 n<P><FONT color=#0000ff>/* fill the screen with the new pattern */
' f# m/ Z- y1 I  bbar(0, 0, maxx, maxy); </FONT></P>
. I4 R' B1 P# j<P><FONT color=#0000ff>/* clean up */
, y! C0 _2 z( L! a% W8 T, o. bgetch();
8 s& z+ Z& Q. k8 C1 lclosegraph(); % \( y3 a( w- {9 a' K7 S; d
return 0; % R& e1 y5 Z! j5 [1 m& g1 {
}
# h+ I3 \1 H7 L</FONT>6 H6 G0 V, Q2 C: M  g, z  n- H
</P>
8 k- F( d, V! }& F3 D+ x, A9 l3 @<P><FONT color=#ff0000>函数名: getfillsettings </FONT>; O- t! {% O- t3 m6 s
功 能: 取得有关当前填充模式和填充颜色的信息 - q0 _/ O5 E; g& u$ g$ X. e: B7 x
用 法: void far getfillsettings(struct fillsettingstype far *fillinfo);
+ \2 x) `. s* i5 V程序例: </P>9 f! C" U2 v* o" i/ ^
<P><FONT color=#0000ff>#include <GRAPHICS.H>
  T/ u& _' e( k- ~, ^1 ]#include <STDLIB.H>+ C& J+ h( D4 u3 c
#include <STDIO.H>- M/ t" p* v3 O) \
#include <CONIO.H></FONT></P>/ j3 O: R0 F! i9 H& }0 Q
<P><FONT color=#0000ff>/ the names of the fill styles supported */
: s2 X0 ]' k% c6 }" U. b9 V. ichar *fname[] = { "EMPTY_FILL",
, r5 E9 [( k  ~"SOLID_FILL",
7 K9 \8 \( r1 r  V1 |9 G"LINE_FILL",
) D3 O2 R. P( x5 e+ A" L- i"LTSLASH_FILL",
1 C$ d2 X% ^. A5 U& p' x7 q# z"SLASH_FILL", ; z1 O" u3 f" z. z: F. I' U
"BKSLASH_FILL",
  D2 _" J4 g2 I4 s! m"LTBKSLASH_FILL",
6 O  H* U& u, O/ C% K4 [4 N3 Q2 t"HATCH_FILL", 6 H$ g: u7 h9 P0 a" v
"XHATCH_FILL",
1 C2 H) b* `; g" E"INTERLEAVE_FILL",
/ v. g; l% j1 E7 V; J2 \"WIDE_DOT_FILL",
1 }! |/ }1 _( C: U"CLOSE_DOT_FILL", 9 r, }. z! z. ?0 V
"USER_FILL" & n: |9 @+ E) E" e$ ?- ~) G7 R
}; </FONT></P>. J+ O" `6 |3 s7 Q
<P><FONT color=#0000ff>int main(void) 4 W; B) |' t. E7 A4 D; z1 `- J
{
7 Q. A: r$ v$ @; s) c/* request auto detection */ ) `$ y' [3 @' H: T$ d. F
int gdriver = DETECT, gmode, errorcode;
; o8 o  y5 H# U. i: d" w1 fstruct fillsettingstype fillinfo; + ~) `/ k8 i/ r
int midx, midy;
% F2 O. E3 Y- _char patstr[40], colstr[40]; </FONT></P># a# d& K% |* A, D
<P><FONT color=#0000ff>/* initialize graphics and local variables */
* d9 s; I, v3 q0 q2 d4 p& |1 g9 \initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>1 |: k6 w6 c7 E; s
<P><FONT color=#0000ff>/* read result of initialization */   A3 B; X$ X. p+ G! v
errorcode = graphresult(); 4 _9 u  k2 N9 k. I  D
if (errorcode != grOk) /* an error occurred */
+ x: t7 r$ L* J5 }! \* {% h, p{
/ n) ], o! ]: {  fprintf("Graphics error: %s\n", grapherrormsg(errorcode));
6 q3 k. R8 z$ J9 R9 Uprintf("Press any key to halt:");
# y' L$ j' Z: @7 _3 |0 P# Sgetch();
: |* A+ [* B/ V: ]9 jexit(1); /* terminate with an error code */ 5 K" E" T5 r1 U. A( c8 C
} </FONT></P>
9 w' l5 `5 u( {6 ~9 R<P><FONT color=#0000ff>midx = getmaxx() / 2;
, x, B6 u1 Y4 N9 }midy = getmaxy() / 2; </FONT></P>! m; H; d5 y  l
<P><FONT color=#0000ff>/* get information about current fill pattern and color */
* B2 W, D$ k4 [getfillsettings(&amp;fillinfo); </FONT></P>
1 Q4 P' E5 |; x. U' ?( P: n1 Q<P><FONT color=#0000ff>/* convert fill information into strings */ ! v% S  S! x( e3 w' l) E- i; V
sprintf(patstr, "%s is the fill style.", fname[fillinfo.pattern]);   s; h2 @  e) U; i, o) R
sprintf(colstr, "%d is the fill color.", fillinfo.color); </FONT></P>
2 V3 N7 C/ [& O( f* h<P><FONT color=#0000ff>/* display the information */
% l: a1 i3 \- V* ssettextjustify(CENTER_TEXT, CENTER_TEXT);
5 F6 ^( |5 o$ H5 L) douttextxy(midx, midy, patstr);
4 v$ S+ H+ D) g& |7 x3 w7 a% Z7 Y! ~outtextxy(midx, midy+2*textheight("W"), colstr); </FONT></P>
) e( P  L5 j5 f) S- j2 \3 ?<P><FONT color=#0000ff>/* clean up */ " {5 [4 x! l1 W2 |  F% e4 m4 g
getch();
( X: J/ [: C  u+ W  W' P6 Y) jclosegraph();
; \8 o  s  u- G* Y# h- \! p% N3 t! ^return 0; ( {% h8 ^* O  Z; D& n, G
} ( g, L6 H$ y; y# [4 s) e
</FONT>
% w9 G5 p) u  V7 C$ V( g( Q8 N1 V' u4 J0 ]- n" K9 ~
</P>
- I) `) Z  }1 O! l9 N/ F0 d<P><FONT color=#ff0000>函数名: getftime </FONT>
6 N0 h8 e# _6 a& ]. [" j6 i' b功 能: 取文件日期和时间 / U, r( i' N0 p( x
用 法: int getftime(int handle, struct ftime *ftimep); 1 H3 W; B* v& [/ U% c9 b$ J
程序例: </P>" ?$ B( T! T. H9 M- w
<P><FONT color=#0000ff>#include <STDIO.H>
) d$ ]% e! P2 r3 N0 k#include <IO.H></FONT></P>' @; |% x' U) D) f
<P><FONT color=#0000ff>int main(void) ' p% w( o7 b+ q! s1 M+ ?
{ , a* x' b9 y+ _! }9 A2 x, V$ I* ^
FILE *stream; ! l+ e4 x/ l! P# G% K. o
struct ftime ft; </FONT></P>
3 j. t% f6 f( R) d. F<P><FONT color=#0000ff>if ((stream = fopen("TEST.$$$", % C7 N' P& i8 h* L
"wt")) == NULL)
5 `2 h8 p1 e0 y& o. X7 r& j% v' E{ ! @! b& D: o* D' d6 ?
fprintf(stderr,
0 o: G* h) n- U1 G; R" ~8 W"Cannot open output file.\n");
( G- R  \! k4 }1 o; A7 P! ]return 1;
$ F9 |, n! i2 I4 U}   e+ E7 @; W/ ]& I
getftime(fileno(stream), &amp;ft); / H9 G2 T  |0 M' M; ?
printf("File time: %u:%u:%u\n",
* i/ t* n0 ^8 N2 [0 t6 y, Xft.ft_hour, ft.ft_min,
1 }* X7 {8 b: cft.ft_tsec * 2); * O2 D9 W# m1 g7 E) I7 [, a/ C
printf("File date: %u/%u/%u\n",
+ N' K1 d" b5 s. ~ft.ft_month, ft.ft_day,
" I( _& e7 b+ {( [; o6 C4 N# ?$ [ft.ft_year+1980); % |/ W' ?" c6 F; C% a7 x: h5 ?/ y
fclose(stream);
8 p% g( [5 z3 ^7 r  P$ f! vreturn 0; + E* ~/ k; I( F
}
  H$ {! r. f0 |# w, K4 X</FONT>
$ _& F9 k9 a, W  w4 k7 ]% s6 {! \. K. M
</P>3 A3 |. ?8 ^' ]; Q  ]
<P><FONT color=#ff0000>函数名: getgraphmode </FONT>8 S# V4 Z: x6 y7 Y2 F
功 能: 返回当前图形模式 6 v/ R6 A) M9 m
用 法: int far getgraphmode(void); 3 {7 f- R9 n+ R
程序例: </P>
" w$ ]8 N# b! J: v7 s<P><FONT color=#0000ff>#include <GRAPHICS.H>
# C. m  M. f& h& J#include <STDLIB.H>
. L* K' d3 |3 Q  m2 s#include <STDIO.H>  X% N: A* @0 @
#include <CONIO.H></FONT></P>
  _' K& l: A7 L+ r. N" U) B<P><FONT color=#0000ff>int main(void)
3 h- d6 J( X% L# v: _9 n! V1 g{ , A- o2 F: a* x. n' L7 ~
/* request auto detection */ ; e$ s. v# p' Q+ E
int gdriver = DETECT, gmode, errorcode;
" W1 t0 k: D, a4 cint midx, midy, mode; ) S- S6 Q# `5 e) Q
char numname[80], modename[80]; </FONT></P>0 k3 _5 S- q5 d2 O) s
<P><FONT color=#0000ff>/* initialize graphics and local variables */
  V0 _2 g+ ]/ p& minitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>. ~6 n+ a4 n" a; c6 F3 B+ p2 ^9 C+ ]
<P><FONT color=#0000ff>/* read result of initialization */ $ R: P" U$ D6 t* ^6 x+ R3 w9 Z
errorcode = graphresult();
0 H3 f/ h' g& a. l/* an error occurred */ + u2 x$ E7 Z3 x( ]
if (errorcode != grOk)
% @7 q9 _) F, e/ r0 _7 ?" O1 Q{
; l' c0 s- W0 pprintf("Graphics error: %s\n", 3 `% R) J" ?5 z/ v$ D: M5 F5 k9 Q5 f
grapherrormsg(errorcode)); 6 {% u) q3 t" p- _. ]
printf("Press any key to halt:");
! l& O* X( U- h* q2 \9 N  W# ogetch(); 2 e5 m- C+ N3 F4 K
/* terminate with an error code */
9 S* k5 z/ B9 z/ l7 c4 V, p, aexit(1);
6 J5 U5 _. T- Z3 L2 n} </FONT></P>
- n3 S$ i- `' y% ?5 k<P><FONT color=#0000ff>midx = getmaxx() / 2;
+ g! f, G2 v7 O' ]4 V3 Y/ omidy = getmaxy() / 2; </FONT></P>
5 Z/ X" x) E. r- x. [* p/ \. A% \<P><FONT color=#0000ff>/* get mode number and name strings */
9 a/ k4 S# f) \mode = getgraphmode(); / P2 u  {8 s1 d% N
sprintf(numname,
. r8 p' y6 X! d% H' R0 h, ~1 K"%d is the current mode number.",
/ F  l+ G, G$ B2 `mode);
$ [! o4 b5 ~) @/ v/ a# m0 Jsprintf(modename, 3 R, N, P: C7 z% U. w  `" S
"%s is the current graphics mode",
: P. N% ]1 e" K" j- `* Ugetmodename(mode)); </FONT></P>, T! l% X$ v( d2 S
<P><FONT color=#0000ff>/* display the information */
8 N! ]# n; @9 }/ e7 ?settextjustify(CENTER_TEXT, CENTER_TEXT);
5 w4 x( X6 l% P! V' Y5 W, Nouttextxy(midx, midy, numname);
* q- d* |* A: o1 N# Gouttextxy(midx, midy+2*textheight("W"), $ q' ~1 M7 }, H, Z5 G
modename); </FONT></P>
! m7 V5 s7 U' K' {. W4 K* R) C<P><FONT color=#0000ff>/* clean up */
& _+ U- y8 z% h; C* sgetch();
' q% u* j! w) X, M# h& uclosegraph();
, b: S( D; K; l# {1 S4 g1 I4 [return 0;
/ r3 y% w& e' k+ p+ [} </FONT>
+ Y: O0 y6 {) }4 C  Z. B9 e5 F. O- s7 ~5 y
</P>
; J# D# `# y: r7 N<P><FONT color=#ff0000>函数名: getftime </FONT>7 \* G5 k! f+ z" I2 V4 ?
功 能: 取文件日期和时间 - H% b' J) W6 M. @
用 法: int getftime(int handle, struct ftime *ftimep);
8 h) P' V, _+ P' P8 ^程序例: </P>( E7 @1 C+ L. [8 D# K/ q3 k8 |
<P><FONT color=#0000ff>#include <STDIO.H>! P% z: b' `9 A$ }/ ^* B9 v
#include <IO.H></FONT></P>
3 _5 R9 P6 T4 ]: D5 T<P><FONT color=#0000ff>int main(void)
- T, v2 y$ B) h, @3 Q3 [' p0 H{ ( z5 l. u0 z0 H2 x% a; r7 l* V7 Z
FILE *stream; ) _% g* Y! V% }& m+ z" Y
struct ftime ft; </FONT></P>; u; I  L- w- B! x5 D% E1 ?
<P><FONT color=#0000ff>if ((stream = fopen("TEST.$$$",
6 b. A4 i* S  D"wt")) == NULL) - i% ~! A( m1 a1 O$ c0 ^
{
$ N' D" x9 c+ p3 k5 Vfprintf(stderr, ; b! n9 p% ?! }+ X0 u9 z
"Cannot open output file.\n");
0 _( K- z- S: a6 K+ v; A( j' ?return 1; " s2 p' k# @' M4 C2 x
}
$ O  p+ y0 T! H  U  @3 Sgetftime(fileno(stream), &amp;ft); ; s/ z8 S/ V# `* e8 u+ h
printf("File time: %u:%u:%u\n",
8 i) R, u" l" f& {0 h* l$ Y& eft.ft_hour, ft.ft_min, + J+ a- L8 w- l$ h" B
ft.ft_tsec * 2); ; Y$ T7 B6 E5 G( |0 Q1 ]
printf("File date: %u/%u/%u\n", ; _* ]# o3 Z1 y: d
ft.ft_month, ft.ft_day, 9 B+ a; @9 J* d  q& F. b
ft.ft_year+1980); 5 E; q4 B1 V. q
fclose(stream); ) x3 Q  Z9 F" b& m# n6 S- h
return 0; 3 l+ F8 v9 b: v0 k) d" X9 ?
} </FONT>
  {( g# ]0 `* h. ?2 X: a) v, S4 {4 G9 e3 H* H
  s5 [9 A% }) m5 _, t
</P>
2 M1 M5 A+ j. u- H<P><FONT color=#ff0000>函数名: getgraphmode </FONT>, ^. `, m: v( Q% i* m  Y% m
功 能: 返回当前图形模式
2 H+ O( E7 W& D, v1 B1 ?$ i; s5 h6 R用 法: int far getgraphmode(void); 6 Y3 `# p# ~9 U* `8 Z
程序例: </P>" g7 t( m3 k; c/ h& {* b
<P><FONT color=#0000ff>#include <GRAPHICS.H># N: \" j5 X: Z- Z+ `$ F
#include <STDLIB.H>" D8 k) p/ L6 ]" {, Z# ~- O
#include <STDIO.H>- O/ x: @6 U' ?) z, f
#include <CONIO.H></FONT></P>
# X. z/ s4 {8 \" x- j" b. u<P><FONT color=#0000ff>int main(void)
* ]  a9 S2 ]( @1 e# Z, i! j( ~{
1 H8 m" o9 o1 m1 J. W3 j6 s% e/* request auto detection */
' d) \8 i# \, F) {( S  Aint gdriver = DETECT, gmode, errorcode;
' ^4 \4 W0 \3 P, Y% u5 kint midx, midy, mode; ; S" O) v; {! t9 J; C8 P- m, W7 d
char numname[80], modename[80]; </FONT></P>% T. `5 P; Z8 g, o2 r. t
<P><FONT color=#0000ff>/* initialize graphics and local variables */ ) X* i3 p- v: j" N; I- @2 \* j6 W- [
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>6 E9 a& u- V3 E. L
<P><FONT color=#0000ff>/* read result of initialization */
& O' L, Z  G' Derrorcode = graphresult();
1 _* H* G2 K( v7 f$ p/* an error occurred */   Q( w' L" v+ _, _2 D' G
if (errorcode != grOk) 3 N8 X; H# k% j: y1 T2 J
{ ( N& K! v8 p8 ?1 }4 r7 A1 g
printf("Graphics error: %s\n", . Z4 [- v4 c# }
grapherrormsg(errorcode)); 9 ^  ^4 M. N- s
printf("Press any key to halt:"); # S& X$ Y2 `+ E) S# x2 j
getch(); 8 d8 p( E5 T& ~4 k+ s
/* terminate with an error code */ 9 C) U# N% |( ?
exit(1);
+ e, q8 }5 _5 o0 k} </FONT></P>/ k$ X6 u0 s2 ~& C( C& K
<P><FONT color=#0000ff>midx = getmaxx() / 2; 7 L0 ]8 E/ I  |( |3 A: P
midy = getmaxy() / 2; </FONT></P>4 G& m4 I0 Q. B0 n' t
<P><FONT color=#0000ff>/* get mode number and name strings */ 1 p6 ?1 w! T% K9 \9 z$ o9 _1 O, a& q' D
mode = getgraphmode();
9 q, p) p/ g- `- g; D* C. ?- a+ asprintf(numname, * f% _# R7 t- Z/ Z. e8 B
"%d is the current mode number.", : _  I; V7 [9 ?& c
mode); 0 |! B+ F2 |' |  }  s  v& x  y
sprintf(modename, # j9 L4 a, d: h# @# m' E
"%s is the current graphics mode",
( u; C7 x" u) Zgetmodename(mode)); </FONT></P>
" r' t( {$ A, s* z: A/ f0 C<P><FONT color=#0000ff>/* display the information */
9 q# t- ^9 h% R& z& W* wsettextjustify(CENTER_TEXT, CENTER_TEXT);
; l/ ^% z4 p8 Q( G; E! P6 douttextxy(midx, midy, numname); 2 r+ d/ T/ Z9 k- {
outtextxy(midx, midy+2*textheight("W"),
/ U5 K* N% \5 H% cmodename); </FONT></P>' U6 x! ~' N! S3 y: h5 d4 y
<P><FONT color=#0000ff>/* clean up */
2 E2 X# E2 a& [getch(); 6 `' H2 Z% F4 s9 {
closegraph();
" d- @9 e4 h0 D% }# i- s5 X$ xreturn 0;
9 t5 b! D, A5 o- Q9 w}
% Z5 z2 _4 n, E& C5 Y</FONT>- A$ B! x- a1 E1 y
</P>
* V  H+ x  p- s3 ]$ H5 {" X8 b<P><FONT color=#ff0000>函数名: getimage </FONT>
' D) y% f9 E7 j( `功 能: 将指定区域的一个位图存到主存中 # _0 `. {1 F3 w" v. L# G( x
用 法: void far getimage(int left, int top, int right, int bottom, 5 i7 U: H/ Y: f! m5 B& l) b
void far *bitmap);
+ o! k9 k# x4 q  [( o8 J6 W2 m程序例: </P>& t! i* `9 z! M" U/ l  `1 N
<P><FONT color=#0000ff>#include <GRAPHICS.H>
6 }, W' _" s7 ~3 h5 D3 `' D#include <STDLIB.H>
3 J2 B* ~$ b; ?( Z#include <STDIO.H>- M- j: d& E, f0 A9 y% T! _$ U+ v) l
#include <CONIO.H>7 i1 w: y/ s2 }5 B
#include <ALLOC.H></FONT></P>, o5 Y9 }, i: p1 t' a1 m
<P><FONT color=#0000ff>void save_screen(void far *buf[4]);
) O3 t' H$ ~/ E! N+ R$ q' kvoid restore_screen(void far *buf[4]); </FONT></P>
" |& s6 T  g# {5 q<P><FONT color=#0000ff>int maxx, maxy; </FONT></P>
  P) R! J0 p; k$ ~1 Z<P><FONT color=#0000ff>int main(void) - P+ ]3 A2 X" Z
{ . t  @% S8 O0 ?+ Q; N6 g* ^8 d
int gdriver=DETECT, gmode, errorcode; ' c9 s2 B2 D9 x) z% v/ U
void far *ptr[4]; </FONT></P>5 G% B- B; `5 R
<P><FONT color=#0000ff>/* auto-detect the graphics driver and mode */ 2 [' ?; j5 |4 h& q. W# l
initgraph(&amp;gdriver, &amp;gmode, ""); 4 t( x" M, o# d8 t- l1 ]$ r& E
errorcode = graphresult(); /* check for any errors */
& ?6 d9 e* r5 ?% i1 j' f. jif (errorcode != grOk) " o* N1 q2 a& H  C7 w
{ / r, J! i$ W9 R# L/ B: L
printf("Graphics error: %s\n", grapherrormsg(errorcode));
8 |& h* V' W* T) V6 iprintf("Press any key to halt:");
" p) U- V( p& Mgetch();
1 g7 D  u; K, _/ p  cexit(1);
2 i0 f5 N! y0 t# S}
. Y5 P8 V' s1 e3 Y: imaxx = getmaxx(); ( ~3 z6 c/ z# t7 G# G
maxy = getmaxy(); </FONT></P>
; c, x- t' D: g<P><FONT color=#0000ff>/* draw an image on the screen */ 6 [6 Y! k9 z3 J
rectangle(0, 0, maxx, maxy); ! Z0 x- G6 W9 f; l# @
line(0, 0, maxx, maxy);
, c4 X- \4 x) f! m/ \line(0, maxy, maxx, 0); </FONT></P>3 Q5 ~3 A( V; O& \' g- k
<P><FONT color=#0000ff>save_screen(ptr); /* save the current screen */ 4 x) ^$ j3 `. c, G, _# @0 B/ y8 S
getch(); /* pause screen */
' E$ i7 ?8 g) m2 ~3 |( ocleardevice(); /* clear screen */ ( d& l0 @+ [! P. K
restore_screen(ptr); /* restore the screen */ 3 V) J, S9 o0 i" }" E
getch(); /* pause screen */ </FONT></P>
$ v3 h  q: I' o! M<P><FONT color=#0000ff>closegraph();
. m0 \7 i5 O( ~: Areturn 0; - t! J! j4 D5 @( `  E- e; B, U* w
} </FONT></P>
: C( i6 l/ Y9 p/ h1 _4 X<P><FONT color=#0000ff>void save_screen(void far *buf[4])
* V% ^: H/ k1 F; m2 d3 i( G, {{ 5 b* N$ p3 w( _3 b* C
unsigned size; % g5 W0 ^8 }) s" s- e: t& q
int ystart=0, yend, yincr, block; </FONT></P>
( z6 M& N$ e+ `! v<P><FONT color=#0000ff>yincr = (maxy+1) / 4; . s6 ]* {+ X# M
yend = yincr;
; l- N* |6 N9 [2 h" fsize = imagesize(0, ystart, maxx, yend); /* get byte size of image */ </FONT></P>( g5 R0 P2 U$ ~5 I5 N
<P><FONT color=#0000ff>for (block=0; block&lt;=3; block++)
4 _4 J# p* \7 R* ?: f+ |{
% k* a# ]1 [* x" J3 i* K: \, Lif ((buf[block] = farmalloc(size)) == NULL)
4 C0 r& d8 w* c{ 4 Q5 u8 H3 Y# e; D
closegraph();
  x  u+ d7 ^4 W, Z& M# \printf("Error: not enough heap space in save_screen().\n");
" K& Z5 L1 @' Y; I& zexit(1); 4 R* z, U" b+ \) r
} </FONT></P>
& S6 K, h' w. d! q6 u. T% P' e<P><FONT color=#0000ff>getimage(0, ystart, maxx, yend, buf[block]);
7 ]( Q6 t6 g# ^+ y; @ystart = yend + 1;
6 s( [; k2 M& j! C' hyend += yincr + 1;
5 u3 D  I( E7 v( X}
/ E4 I% z; l9 Z; X} </FONT></P>. p, T# e6 n7 y" r5 A! f
<P><FONT color=#0000ff>void save_screen(void far *buf[4]) . f8 ~0 [( B! o7 C7 E, V
{ ! t! R1 w! E5 ]0 ?6 u. D4 d/ I
unsigned size;
1 A+ d$ d; s2 }int ystart=0, yend, yincr, block; </FONT></P>/ V2 S& ]9 g9 x
<P><FONT color=#0000ff>yincr = (maxy+1) / 4; # u& Z) _! `5 g0 J1 p
yend = yincr;
- F! [3 M& K1 m) xsize = imagesize(0, ystart, maxx, yend); /* get byte size of image */ </FONT></P>
1 c, S; l, T& w) Q<P><FONT color=#0000ff>for (block=0; block&lt;=3; block++)
: I+ m% B+ a& h' c3 [, }( a{
3 D; ^3 Y# b, m; \: X5 tif ((buf[block] = farmalloc(size)) == NULL)   B  P4 G* t% n9 o2 k0 Z
{ " V) U2 }: m) i
closegraph();
8 W. E, {! Z. {5 O7 b" c& I6 S8 Dprintf("Error: not enough heap space in save_screen().\n"); - T1 q: h% z( j* ?& N0 X
exit(1);
& l+ S" o; v- y9 ]2 [7 g, u} </FONT></P>) E& U6 Q& J9 R8 V
<P><FONT color=#0000ff>getimage(0, ystart, maxx, yend, buf[block]);
/ X* ~( i0 m9 V: ?& j4 Tystart = yend + 1;
0 V/ h6 c! u# q! p9 Vyend += yincr + 1;
# h/ X5 O/ S/ [8 M4 B6 T}
  c6 Q  z2 l  z} </FONT></P>
0 H; y% f) z+ P<P><FONT color=#0000ff>void restore_screen(void far *buf[4]) / e- M. ~  Q% G
{
, c1 l  S, F& V% y' ?5 ]3 _! K; {; Kint ystart=0, yend, yincr, block; </FONT></P>- R- v  _4 n" ^9 \
<P><FONT color=#0000ff>yincr = (maxy+1) / 4; # s4 L3 i9 w7 q: E: l& V
yend = yincr; </FONT></P>! k# b6 [1 q$ d$ f; f8 P6 y
<P><FONT color=#0000ff>for (block=0; block&lt;=3; block++) ) c9 i) [& k& ~5 H, g: h: t) j
{ 6 a' D6 p: d4 u3 ~  Z& J
putimage(0, ystart, buf[block], COPY_PUT);
0 Z% x0 C' M& [+ i! p3 l( {farfree(buf[block]);
6 g- e2 L8 ?% R4 s. o9 Y8 x" yystart = yend + 1;
8 d/ [" Q+ B1 K; x( A4 z$ g% ~yend += yincr + 1; / p' |! y5 R. l- ~1 ]& C9 k
}
3 b: X# D6 W3 Z  d} </FONT>
' _! i: t8 S3 V7 x, F+ h<FONT color=#ff0000>
9 J( |( O- x# f3 Q& J0 @& C- {</FONT></P>
7 l: U8 I7 S& i' E<P><FONT color=#ff0000>函数名: getlinesettings </FONT>
* l- ~% [, n0 u. B% P6 D功 能: 取当前线型、模式和宽度 1 @, \) c4 ]( x2 Z
用 法: void far getlinesettings(struct linesettingstype far *lininfo):
3 ^- d/ L# C  G0 }程序例: </P># V' ^+ W- j0 A) D3 V3 b
<P><FONT color=#0000ff>#include <GRAPHICS.H>
3 {) u9 P1 _9 x& V6 [#include <STDLIB.H>0 t% ]% l: H" {4 R! Z+ I0 ?9 a
#include <STDIO.H>/ w1 [& H7 V: ]" n5 U
#include <CONIO.H></FONT></P># a- i) C, R2 c' w
<P><FONT color=#0000ff>/* the names of the line styles supported */ 2 b, i+ a, T* ~; L; z; q+ F
char *lname[] = { "SOLID_LINE",
( P! b* U% ^% y& r  f"DOTTED_LINE",
1 M9 b: F3 b- P3 @1 f3 h: v! |"CENTER_LINE", 7 g, H" f' K# T1 I# \3 v# m
"DASHED_LINE",
& m# v- m/ R, L7 Y"USERBIT_LINE"
6 K+ {+ S2 Z" {& H: Z}; </FONT></P>
" f, j9 `- G7 B1 Y9 w5 @<P><FONT color=#0000ff>int main(void) - ?2 \- g4 x6 S- h
{ 8 @) m  i9 r0 k; B
/* request auto detection */ ! M; N, b# g! r) w. h' p
int gdriver = DETECT, gmode, errorcode; # g" q6 Y1 P% z  G7 x
struct linesettingstype lineinfo;
) {4 |! Q" e* |3 K6 qint midx, midy;
8 b6 m& N! D+ G' }char lstyle[80], lpattern[80], lwidth[80]; </FONT></P>
' I* ?2 G* E2 I+ c& f<P><FONT color=#0000ff>/* initialize graphics and local variables */
# p+ z9 h% r% Q. q" kinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>, \+ \$ ?7 w( S( w
<P><FONT color=#0000ff>/* read result of initialization */
# h! s+ z* e$ P9 m# V$ Oerrorcode = graphresult();
: C2 A- U" s: F9 zif (errorcode != grOk) /* an error occurred */ : X8 B- y7 L- ]3 V( |% d) e0 s2 ?: \
{
% T# h# ~  g: R8 k5 Dprintf("Graphics error: %s\n", grapherrormsg(errorcode)); & |( P5 w# b+ N8 J% N- T2 o
printf("Press any key to halt:"); & E  p3 R; W, E; m8 D! g8 \
getch();
. }6 A+ ~5 O7 C' ^# Texit(1); /* terminate with an error code */ 5 ~7 ]8 ]8 E' q3 _$ q
} </FONT></P># r) f# z; f) ^8 {$ q- d; A8 J
<P><FONT color=#0000ff>midx = getmaxx() / 2;
& ]) X6 {; U4 q6 t7 h/ zmidy = getmaxy() / 2; </FONT></P>
3 F2 l; ]. F4 J; G<P><FONT color=#0000ff>/* get information about current line settings */
0 b$ G! D. P3 D; xgetlinesettings(&amp;lineinfo); </FONT></P>2 h. v# Y9 k  M; y' b3 K: h
<P><FONT color=#0000ff>/* convert line information into strings */
4 P0 Z6 T( z4 q' Esprintf(lstyle, "%s is the line style.", 5 c, E, Z$ Y! a1 w1 `$ R
lname[lineinfo.linestyle]); : ^& I5 W  y- m* T) A! g
sprintf(lpattern, "0x%X is the user-defined line pattern.", . U# Y5 t! ^: z+ X4 ^1 B$ t
lineinfo.upattern);
$ U6 g0 Q4 l6 ^$ Tsprintf(lwidth, "%d is the line thickness.", $ F- g, _) d* C- o8 q/ `& J# Q
lineinfo.thickness); </FONT></P>; A+ [" h3 O, d) \+ t- ^0 `
<P><FONT color=#0000ff>/* display the information */ 7 K  M# Y) z0 x0 c- b8 O
settextjustify(CENTER_TEXT, CENTER_TEXT); 1 u: l6 _* k& V  a9 E$ P: B
outtextxy(midx, midy, lstyle); ( G: Y, o% {  |, x$ ]2 M7 _0 Q
outtextxy(midx, midy+2*textheight("W"), lpattern); 9 x* Z8 S4 P8 B5 r
outtextxy(midx, midy+4*textheight("W"), lwidth); </FONT></P>' X$ d" D: }! D4 a; ?8 b4 V; T
<P><FONT color=#0000ff>/* clean up */ 8 R4 I1 {, ]' n1 _
getch();
8 Y/ m& Y2 D  `. p2 h/ E9 K+ xclosegraph();
- T$ \; u% J1 p# ^, m# ~9 kreturn 0;
8 n# k2 T. i  z# E  q} </FONT>7 }5 p; Y. D9 S
. o' _. Z8 M0 z
</P>, y, N9 w. w6 t& B! D" ~$ s5 _7 ?
<P><FONT color=#ff0000>函数名: getmaxcolor </FONT>
6 K; Q8 B7 V* i% R, J; t功 能: 返回可以传给函数setcolor的最大颜色值 ) r) }' y, S3 c
用 法: int far getmaxcolor(void); : I+ Q8 n) Q  e5 h
程序例: </P>
; I+ z3 d% y. s8 i! r<P><FONT color=#0000ff>#include <GRAPHICS.H>
- o( z3 ^- C0 r0 j- B, [' T# |#include <STDLIB.H>: m. K2 h8 m+ u& C# g( L
#include <STDIO.H>
1 \" o' F' J( Q4 i  j9 o#include <CONIO.H></FONT></P>
9 i% R3 s0 ]$ {8 [- `<P><FONT color=#0000ff>int main(void) 3 e, u2 T. J1 I/ T$ N8 r& v
{ 4 b/ N& E3 e& p5 Z# \* T
/* request auto detection */
& `2 U3 }; `/ O3 ~$ ~4 ?2 gint gdriver = DETECT, gmode, errorcode; $ S6 i3 t6 S+ Q
int midx, midy; ; e  k& j7 r* O% r/ m7 [
char colstr[80]; </FONT></P>
; z( i4 {' {: k6 q  M- f1 g<P><FONT color=#0000ff>/* initialize graphics and local variables % i- J+ E9 l. j" Y) k
*/ initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
$ r, k% l' W2 b* {5 k0 F<P><FONT color=#0000ff>/* read result of initialization */
/ O) x; k5 A) K# T+ e$ R4 [errorcode = graphresult();
/ c  M9 b9 ]- P' ]+ H. x* _if (errorcode != grOk) /* an error occurred */ 2 w- `9 G# R& u5 O: _9 s
{
3 ~. Y* H: K. T- ?  @1 s! Q" Gprintf("Graphics error: %s\n", grapherrormsg(errorcode));
9 P. ?* K2 |( X$ O7 R" X! nprintf("Press any key to halt:"); 5 _0 u0 y2 T5 A$ Y8 C
getch();
% e6 h6 `, E* Z' J8 E; ~exit(1); /* terminate with an error code */ 0 N" n0 F- P2 F. C& {" F
} </FONT></P>
: n; b' P1 V# R$ ?2 q+ I: H<P><FONT color=#0000ff>midx = getmaxx() / 2; ' ^3 r0 H5 W% S6 ?6 G, R
midy = getmaxy() / 2; </FONT></P>
" @5 ?$ W3 E1 n<P><FONT color=#0000ff>/* grab the color info. and convert it to a string */
0 _+ T2 g" U5 O/ i, r$ Asprintf(colstr, "This mode supports colors 0..%d", getmaxcolor()); </FONT></P>
3 x) H% N, l0 f+ b7 e' a' |- p<P><FONT color=#0000ff>/* display the information */   g  t& o' E8 [( K2 l4 [# \% {2 r. B) r
settextjustify(CENTER_TEXT, CENTER_TEXT); # m% M$ O+ h3 E+ `- i& z6 H
outtextxy(midx, midy, colstr); </FONT></P>+ f2 R! U: z! A
<P><FONT color=#0000ff>/* clean up */ , _- l! X5 l1 E9 V' `* Z: x
getch();
; j$ s! I# j: lclosegraph(); # {% f2 ~2 N; X. u0 B0 G/ A
return 0;
, L' c+ d! p: t8 ]- R} </FONT>+ l5 Y0 V2 s1 B
6 M* V* Y( K: K* ^$ c, z- p  C

4 |) c' _! C( r  Q) Q) S</P>
. k0 Y3 R4 p6 e6 I+ S9 t" x<P><FONT color=#ff0000>函数名: getmaxx </FONT>& C) p& b# s6 j$ Y- B
功 能: 返回屏幕的最大x坐标 / u) ^, g! D3 t4 ~, z
用 法: int far getmaxx(void); / x" I1 \( z; ]
程序例: </P>) I8 _8 c+ c+ E& Y  C: r" ]
<P><FONT color=#0000ff>#include <GRAPHICS.H>! R+ M2 S6 |) Y, j4 J% v' R
#include <STDLIB.H>
% \/ l9 ?8 ^' u#include <STDIO.H>
* ~2 l$ S! F2 t4 t: T#include <CONIO.H></FONT></P>
& b1 D- r3 `+ H0 a( y% _  J<P><FONT color=#0000ff>int main(void) ! W! m4 X: p8 I
{ $ L& D# v7 E& ~- c( {
/* request auto detection */ 0 J4 i' k2 p$ j& D! |
int gdriver = DETECT, gmode, errorcode;
' H& j% Y' ]3 {6 p3 i8 V  P0 m, lint midx, midy; ' |9 g7 o3 z, n- O' ?/ {
char xrange[80], yrange[80]; </FONT></P>
6 n8 V& o. h$ C' I5 W& F2 {<P><FONT color=#0000ff>/* initialize graphics and local variables */ % N0 Q: Q  l& p" Y6 v1 V
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>. l9 A5 |: q- r% p* y( O1 h
<P><FONT color=#0000ff>/* read result of initialization */ 8 o  m  X1 Z- z- e( f! J, u0 U5 V
errorcode = graphresult(); ! ~4 A& Y. Q# y9 L' w7 r
if (errorcode != grOk) /* an error occurred */
2 E3 x% K! p, @& b7 S* [. l{ 2 K) W9 u" N9 o+ m) R: v- F% _2 ]6 B
printf("Graphics error: %s\n", grapherrormsg(errorcode));
& D+ o: v: Z0 L* d+ H, s0 h! Pprintf("Press any key to halt:");
+ Z& y5 b8 ?# e' P2 H! H7 j- [getch();
0 {9 l# ~+ |" [' B8 h- M% Texit(1); /* terminate with an error code */ & f0 u2 v# h% @  T& f/ w9 U7 g" N
} </FONT></P>* g, h( k* X- R+ {! Z, W
<P><FONT color=#0000ff>midx = getmaxx() / 2;
/ Q  w/ ^2 I4 ^midy = getmaxy() / 2; </FONT></P>7 U4 {, X7 Y* Y* F# h3 B9 [
<P><FONT color=#0000ff>/* convert max resolution values into strings */
$ P# P1 J4 ?5 L: z# Psprintf(xrange, "X values range from 0..%d", getmaxx());
8 F1 B6 Q$ T! z0 w$ Nsprintf(yrange, "Y values range from 0..%d", getmaxy()); </FONT></P>
! M" l: T5 ~7 g, g" V  l, m/ j<P><FONT color=#0000ff>/* display the information */ % M# j+ v) M6 l& Q4 N* a+ {6 p5 H8 g
settextjustify(CENTER_TEXT, CENTER_TEXT); " |2 V: @$ m' d
outtextxy(midx, midy, xrange); 2 z+ T* L0 }  _
outtextxy(midx, midy+textheight("W"), yrange); </FONT></P>, G: I; d. n$ [8 t9 t
<P><FONT color=#0000ff>/* clean up */ 7 i! N! _2 O+ h4 U. a" ^
getch();
! u$ j- u: y8 n, z7 f* G3 Rclosegraph();
; T; G/ ~* I: i# C8 p8 areturn 0;
' ]& ^+ d1 W5 w+ I: `- e}</FONT>
1 }5 z) X' U4 s) b' J- }) i2 L5 H6 Y% i: @( j1 M* C
</P>: X' T( u1 u/ A9 k3 f; h, T6 f
<P><FONT color=#ff0000>函数名: getmaxy </FONT>
  S; K, a& T5 ]- F, K9 \功 能: 返回屏幕的最大y坐标 1 m$ W3 q- u; C7 q- A
用 法: int far getmaxy(void);
- r# p* n' m1 h/ S. v+ v程序例: </P>
* x( f% |7 B# M# [4 h' }<P><FONT color=#0000ff>#include <GRAPHICS.H>
7 ?$ s" j& [: w( z#include <STDLIB.H>, z6 I/ M5 \- ]4 k5 U
#include <STDIO.H>! P& A2 Y. s0 s. |
#include <CONIO.H></FONT></P>
$ l- s' u! d& D<P><FONT color=#0000ff>int main(void) + @+ [- S5 M+ c9 _
{ - ]) D5 ]! q% ~, R
/* request auto detection */
2 p; V: _  u' F& e8 K$ [4 X' tint gdriver = DETECT, gmode, errorcode;
& Y3 M$ ~4 J0 x! e7 g) V7 Eint midx, midy; . X& H0 ?. U5 W3 p) ~: e+ n
char xrange[80], yrange[80]; </FONT></P>
4 g3 }3 Y# X6 e) x! W<P><FONT color=#0000ff>/* initialize graphics and local variables */
  M" v5 @6 @3 Q% T' v8 }" p8 h, uinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>) v, k/ @' i8 [
<P><FONT color=#0000ff>/* read result of initialization */
7 V. Z: I" [/ V! Gerrorcode = graphresult(); / F# n* I5 i5 o. u8 R5 y& d
if (errorcode != grOk) /* an error occurred */
4 p+ {; f3 i9 c{ 4 u  j0 X& L- h+ q8 I6 f
printf("Graphics error: %s\n", grapherrormsg(errorcode));
$ D: C$ j  f9 J% o# Pprintf("Press any key to halt:");
8 S  ^' X  O4 ^2 @4 e/ v9 Ngetch();
1 o/ o4 a8 [  `( Iexit(1); /* terminate with an error code */
5 b4 H8 j6 M. k$ z; \} </FONT></P>
: N7 a7 c3 d1 b! g/ i) [<P><FONT color=#0000ff>midx = getmaxx() / 2;
: U2 s; o% F& s. N/ i8 Ymidy = getmaxy() / 2; </FONT></P>) N0 j: e, B, [. C5 y$ w0 l, k
<P><FONT color=#0000ff>/* convert max resolution values into strings */
6 z4 A# K- @  J% S# O  e. v9 @sprintf(xrange, "X values range from 0..%d", getmaxx());
5 ~, K$ V* f6 J; k% _1 Fsprintf(yrange, "Y values range from 0..%d", getmaxy()); </FONT></P>/ P# e- ]6 k& A0 }* v# \
<P><FONT color=#0000ff>/* display the information */
& j, T, j9 o+ r+ q8 Rsettextjustify(CENTER_TEXT, CENTER_TEXT); 7 @, b& B  y# m. S0 @
outtextxy(midx, midy, xrange);
% g& }3 I! Q6 f4 v  f7 f$ _& Mouttextxy(midx, midy+textheight("W"), yrange); </FONT></P>$ n  J+ A* T! B! n% v. _! C
<P><FONT color=#0000ff>/* clean up */
# a0 n1 {% I% z1 @( `, s, }getch(); 5 I. D% I! U5 ^% n7 D1 ]" X  P% U
closegraph();
7 ~6 B5 h3 h' g: oreturn 0; , B  Z8 ^3 X3 Q0 |! `- j9 O1 ]
} </FONT>  X0 Q' z: R/ \7 G2 z2 ?2 n
</P>
5 L; i6 o9 B; S) c, I. t5 e<P><FONT color=#ff0000>函数名: getmodename </FONT>/ A/ f: i1 W* r# W. f9 |8 c: r
功 能: 返回含有指定图形模式名的字符串指针 - \  o& t* z4 M% Y) _! k# t
用 法: char *far getmodename(int mode_name); % T+ J4 L3 x: V0 _) Q2 I2 n
程序例: </P>6 }" M$ c1 D3 R# J
<P><FONT color=#0000ff>#include <GRAPHICS.H>
) S8 I- r" R% r" n#include <STDLIB.H>
" d5 F: [6 w& T. f#include <STDIO.H>9 j- K9 R: g, U1 G9 ~
#include <CONIO.H></FONT></P>
# C4 N0 x3 {; J* A9 Z# J<P><FONT color=#0000ff>int main(void) 1 M# p5 y0 `% G1 G
{
9 Z0 @/ l( g6 v9 o7 b4 M! ]/* request autodetection */ ) K" G1 p) a) j% p  v: \
int gdriver = DETECT, gmode, errorcode; & R( E& w  F$ q: I6 j8 J* {
int midx, midy, mode; % e1 ~8 l1 M6 M2 X
char numname[80], modename[80]; </FONT></P>5 f4 f% n' a, x8 S" X1 O; `
<P><FONT color=#0000ff>/* initialize graphics and local variables */
$ f  |  A  U/ k6 oinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>5 Y: H* C- a; i( w) @
<P><FONT color=#0000ff>/* read result of initialization */ 3 m: ]2 X0 g) F
errorcode = graphresult(); ; C+ d8 p" V! i0 Q
if (errorcode != grOk) /* an error occurred */
4 `7 b+ I1 t% m! H2 A& ^: {$ ]{
6 A! f" a% H6 M0 }5 g7 v0 fprintf("Graphics error: %s\n", grapherrormsg(errorcode)); : V  y: q2 r) `0 f. {5 t( K7 \
printf("Press any key to halt:");
# q( U$ \1 l  L5 v. a& Wgetch(); # \$ C6 w' E; R. u% R* \, I( N
exit(1); /* terminate with an error code */ ' S( E3 M$ N* T$ B& Z
} </FONT></P>* D% {1 i6 h& ~: T( k
<P><FONT color=#0000ff>midx = getmaxx() / 2; 9 a+ s4 Q. Q1 D, j9 ~) @
midy = getmaxy() / 2; </FONT></P>
/ U& t0 F- o4 B( f$ Q+ Y. D' q<P><FONT color=#0000ff>/* get mode number and name strings */ & V( W% A) U& W% a, m, S/ }
mode = getgraphmode();
$ T$ X/ K9 ^$ x9 l. T! ?sprintf(numname, "%d is the current mode number.", mode);
8 _3 D. v8 Z. ^9 @sprintf(modename, "%s is the current graphics mode.", getmodename(mode)); </FONT></P>
( K3 v8 t/ p, P! Y! N  v<P><FONT color=#0000ff>/* display the information */
. }4 g! R$ x4 c2 P( X- F$ osettextjustify(CENTER_TEXT, CENTER_TEXT); / ~& S0 @- l. S  m( W* ]
outtextxy(midx, midy, numname);
8 r! [; c% @/ Y+ m- T+ A: n9 Routtextxy(midx, midy+2*textheight("W"), modename); </FONT></P>
: f" h6 T; h% b1 B+ H, J<P><FONT color=#0000ff>/* clean up */
; A( }! h" G  [8 m8 h7 O! Y/ E. sgetch(); 9 D9 a! K4 N8 T0 h- b, i
closegraph();
& L1 N+ o7 C; i& M) wreturn 0; " F& l" \( X( d
} </FONT>
* H- n4 K. i5 M. r/ Z' A6 }3 t, [" ?1 t5 c3 N! a
</P>4 p; O/ B7 D; E3 d
<P><FONT color=#ff0000>函数名: getmoderange</FONT>
, u7 Y4 ~, @7 q! a1 x) z功 能: 取给定图形驱动程序的模式范围 0 S$ i+ T+ S0 B% O0 F6 C
用 法: void far getmoderange(int graphdriver, int far *lomode,
- W8 j3 k1 r, ~8 y# g! }% s) T9 uint far *himode); ) e6 P% X/ n5 [0 a% b  M, }
程序例: </P>! S( a0 Z9 l8 L; V9 I, f! \
<P><FONT color=#0000ff>#include <GRAPHICS.H>
- k9 _- l& N: R4 [& G4 S0 [#include <STDLIB.H>9 x2 r$ A4 j- J0 Y
#include <STDIO.H>/ O& F8 a. k! O6 o9 L0 ?: n
#include <CONIO.H></FONT></P>
5 q6 p( m; q; N/ G) w" K& K# ?* \! T7 _<P><FONT color=#0000ff>int main(void) , R% W( p6 P  ]
{
- D& c  W: L9 T! h+ T0 m& G- b/* request auto detection */
% D( q+ ^" W) c+ Jint gdriver = DETECT, gmode, errorcode; . l# h* I. L1 y. t
int midx, midy; : K/ I4 u- w% f; F* d. S4 _
int low, high;
8 b8 A1 D; P& ?1 f( d" b, Kchar mrange[80]; </FONT></P>8 @: ?  S7 p% \# z1 a" m+ a
<P><FONT color=#0000ff>/* initialize graphics and local variables */
3 I! C! P' S) z) u8 S1 J. `initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>( i  L, z. Y# f# e
<P><FONT color=#0000ff>/* read result of initialization */
0 P7 T/ O1 S0 j& ]- }; Gerrorcode = graphresult(); # y+ U2 o, Y0 d7 G
if (errorcode != grOk) /* an error occurred */ 7 |6 O. w& q% N+ ^2 B3 ?. z
{
# m( v# W! g5 E4 Lprintf("Graphics error: %s\n", grapherrormsg(errorcode)); / V6 G2 B4 J- h) L6 r1 X
printf("Press any key to halt:"); 3 G& e3 W" z: o6 f
getch();
% {5 o- p  x5 r& {exit(1); /* terminate with an error code */
$ W3 X" W! G1 L9 Y: V+ I$ e! ]} </FONT></P>
( ~  D: U0 N& M) g0 N" z% ]1 A<P><FONT color=#0000ff>midx = getmaxx() / 2;
3 y4 k' Z: {9 U4 Y3 f! s% M$ |midy = getmaxy() / 2; </FONT></P>0 y+ g9 g! `% C( S$ y8 l
<P><FONT color=#0000ff>/* get the mode range for this driver */
+ P& Y; N. k5 Y, ^# ?9 Zgetmoderange(gdriver, &amp;low, &amp;high); </FONT></P>; l2 }# l2 D9 U* x
<P><FONT color=#0000ff>/* convert mode range info. into strings */
* t8 c2 v: P' M  t, c% Ysprintf(mrange, "This driver supports modes %d..%d", low, high); </FONT></P>  ~, q  N/ X; Q7 O+ H6 b% J
<P><FONT color=#0000ff>/* display the information */
& \9 U. f4 v& o1 g- R% gsettextjustify(CENTER_TEXT, CENTER_TEXT); ! U; p" R' q/ e6 J5 H& N/ T
outtextxy(midx, midy, mrange); </FONT></P>5 Z1 C2 u7 q' R+ Q. \
<P><FONT color=#0000ff>/* clean up */ . X" D. \& m% _. C; s- Y
getch();
, M/ a: K4 h0 ^, Oclosegraph(); + M+ H+ W3 C5 U3 p& v; u
return 0;
) M1 M9 M+ m9 y} : \, n1 h4 g0 g. J
</FONT>1 @) F0 g2 @. ~- Q: M, M
</P>
# F" ?1 A! Q( X. ?  p<P><FONT color=#ff0000>函数名: getpalette </FONT>1 D4 Q/ o% x- A/ X6 h! ]
功 能: 返回有关当前调色板的信息
- p7 A* I/ I' ~; z& u% J3 b! ~* X用 法: void far getpalette(struct palettetype far *palette);
. ~1 X  Y4 c5 o" N6 t程序例: </P>
: I4 i9 o+ s2 h& k<P><FONT color=#0000ff>#include <GRAPHICS.H>
! P9 v+ Y/ C; n7 K) c: c# b#include <STDLIB.H>; ^# e6 W0 C+ x
#include <STDIO.H>
! c( u0 M/ w' ~0 U& S- U#include <CONIO.H></FONT></P>7 D: b! }$ H* x/ N
<P><FONT color=#0000ff>int main(void)
0 F& Z; o4 ~4 p  F# B{ " d) K# N1 P) q# ^, S
/* request auto detection */ 2 A" \3 A9 a( g, a9 h0 K
int gdriver = DETECT, gmode, errorcode; , Q0 ^# \! I" j6 X- y1 K3 |
struct palettetype pal;
( K9 _: W) j4 gchar psize[80], pval[20]; 5 ?$ o" M$ ]7 B( f  k
int i, ht; 3 |3 C5 [3 [6 W/ E* W
int y = 10; </FONT></P>
; ]1 F# r* g7 I$ I! Z' v% A3 ~<P><FONT color=#0000ff>/* initialize graphics and local variables */
* I/ P7 F7 k) Binitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
0 `. T% D7 N3 x$ b<P><FONT color=#0000ff>/* read result of initialization */
6 i. X( z- K# S5 ?- O7 Terrorcode = graphresult(); ; o$ c9 Z% V6 p
/* an error occurred */
/ l3 \6 S, q: s$ n5 d, Uif (errorcode != grOk)
. B! |( D1 _8 d6 ?/ ^: T: u! I# B3 \{ 6 U3 A( M; @/ a  G. M
printf("Graphics error: %s\n", 9 ]3 l0 t, Q! m/ U7 I
grapherrormsg(errorcode));
; L1 Y6 h8 e1 B6 Nprintf("Press any key to halt:"); 2 I7 X- `0 S: h8 y2 `) t
getch();
2 N: }/ L1 }7 m/* terminate with an error code */ 1 Y6 u+ q: T8 c) _( A3 C) t
exit(1); - m( \6 D& O$ H3 P) t  x" B1 y- J% n
} </FONT></P>) |! a2 T  J4 \
<P><FONT color=#0000ff>/* grab a copy of the palette */ 2 ~6 l, g- d8 y7 l. {# h
getpalette(&amp;pal); </FONT></P>
' Z5 D/ F, R2 E! _# b" j<P><FONT color=#0000ff>/* convert palette info. into strings */
9 M  n9 s% f- k; z8 a$ M0 Tsprintf(psize, "The palette has %d \ 7 g- o  o4 m' p# ^! ~3 q. B/ M. z# p
modifiable entries.", pal.size); </FONT></P>
- o. l' l0 s5 r<P><FONT color=#0000ff>/* display the information */ ) f" I1 E9 m! c6 _
outtextxy(0, y, psize);
0 v. R$ o" S" O9 B) K0 qif (pal.size != 0)
# B" f; q& W2 k- c{
, L! Q) e$ S6 s( U( G4 rht = textheight("W");
' w5 o( ]8 |2 A6 D; T; hy += 2*ht; ( s+ {- k% G% L* z' O
outtextxy(0, y, "Here are the current \ ) H' D+ t# X$ d) q' X$ G! F( D
values:");
; a! `* Z6 ]$ s. p) Yy += 2*ht;
% k) U9 J% d1 ~for (i=0; i<PAL.SIZE; <br i++, y+="ht)"> { 3 S; t# m7 t' d- y
sprintf(pval, ; U/ Z2 ^2 C  _% j9 F
"palette[%02d]: 0x%02X", i,
0 E- O" Z- F  K2 x# ~2 `pal.colors);
( D, n, _6 x2 i/ Qouttextxy(0, y, pval); ! y. y1 ]' \  d+ E6 }& i. p
}
( R" R2 b9 j: f& {# y9 c* ^} </FONT></P>$ E* v: A/ A' L. n; |4 I+ ?
<P><FONT color=#0000ff>/* clean up */
1 f" c& \) g# |# \$ wgetch();
! q7 M9 Y5 @% S) z7 o  J" \( Yclosegraph(); </FONT>
5 g8 b' G1 l# }  f3 P! _  a$ M2 Q# t<FONT color=#0000ff>return 0;
$ k7 `& Q6 O: A1 X! n' w0 o* Q$ f, u} ! b; S0 o0 J+ {* q/ X, P4 F: P, M
</FONT></P>
% Y2 L% s, i, A3 {  D( y3 l0 X<P><FONT color=#ff0000>函数名: getpass </FONT>
% C! \! S. O" b5 b3 W8 I7 A* Q功 能: 读一个口令
7 }5 E8 q6 K: V: E1 }7 ^用 法: char *getpass(char *prompt); 0 F2 y$ P% ]; T1 V- h
程序例: </P>
8 @1 a) M% e. \; ]) G6 J7 z<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>4 v+ u! v2 U3 u+ K
<P><FONT color=#0000ff>int main(void)
: n6 {3 M: i+ e0 A{
  p# C. l: b7 u. \0 S' G; h" kchar *password; </FONT></P>
! f1 K$ N4 J1 v( M; a/ j<P><FONT color=#0000ff>password = getpass("Input a password:");
- L' {7 Q, O5 W% m  ocprintf("The password is: %s\r\n",
; K5 H+ ^1 r7 e% ^, o+ lpassword); * S& i! K! V  ~7 W
return 0;
5 m* M" ~" ^8 S}
, S) d' `6 x  z</FONT>  |; S& E" S$ H$ |
3 W$ d' l& i0 e$ S& E4 l+ C
</P>
+ v( G# |8 j0 A: Q<P><FONT color=#ff0000>函数名: getpixel </FONT>& ]$ k/ c) q( O& r/ `. y1 N
功 能: 取得指定像素的颜色
1 j9 y7 J9 a: T+ B用 法: int far getpixel(int x, int y); ' Z5 v2 [% ?! l7 x. s  ]# {# w. a
程序例: </P>
5 }, r) z& s. _: w* s' ~4 ^) p<P><FONT color=#0000ff>#include <GRAPHICS.H>" L) I2 u3 j, [6 k5 f4 K, Z
#include <STDLIB.H>9 J' }; Q  @$ ]& ^
#include <STDIO.H>: t/ X, C0 O/ N
#include <CONIO.H>/ R* m8 A6 h2 E2 ^$ p8 u" h
#include <DOS.H></FONT></P>
% J$ S/ D# F0 n+ r$ h( P7 t<P><FONT color=#0000ff>#define PIXEL_COUNT 1000
1 s1 J) E7 j4 i$ _% u6 o#define DELAY_TIME 100 /* in milliseconds */ </FONT></P>9 L% r% J* S3 G2 n# V
<P><FONT color=#0000ff>int main(void)
7 Z- w3 s$ n$ r{
& q" ]# W, S/ I6 Z/ C" K: s/* request auto detection */
8 E- l7 Q5 B0 M: v, `int gdriver = DETECT, gmode, errorcode; 6 ?6 |5 U5 h$ T# i( ?) \9 l
int i, x, y, color, maxx, maxy, ) g  |" p$ s8 O: ?% G, Z1 y# n
maxcolor, seed; </FONT></P>
( q. \9 T, N. g$ T$ K<P><FONT color=#0000ff>/* initialize graphics and local variables */ 2 h! u% o1 T, ^+ D
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
* h3 w' ~2 l6 u2 J. q( a1 z3 X<P><FONT color=#0000ff>/* read result of initialization */
# u5 M. ?: t1 Z/ R2 `1 ^8 Uerrorcode = graphresult(); $ A9 g! U, v2 Q0 e% r5 j3 y$ x
/* an error occurred */
) L1 o* O$ {! F+ Zif (errorcode != grOk) ( F- v( a3 O; A! }5 c
{
0 R7 D5 s5 J, I; l: d; g0 vprintf("Graphics error: %s\n", . C; E, `; L, ]' z+ \- W. w
grapherrormsg(errorcode)); ' F8 v& `6 |2 h
printf("Press any key to halt:");
  k& `( s+ O; h7 kgetch();
' P% D) H) S; J5 z/* terminate with an error code */
' s' _& n* `  o) d6 z  {exit(1); ! e" e) ^$ F8 D5 O' d5 U3 @
} </FONT></P>5 l6 R5 h; c+ c* u$ J. I& m$ G
<P><FONT color=#0000ff>maxx = getmaxx() + 1;
6 V: G1 e  A+ kmaxy = getmaxy() + 1; % u# E8 s6 t# f6 {
maxcolor = getmaxcolor() + 1; </FONT></P>
% E6 c9 J) N$ N% r% A# _<P><FONT color=#0000ff>while (!kbhit()) - X$ J# v4 |) N9 {
{ , e/ H0 G  T' l( ?. b! k$ z- R
/* seed the random number generator */ 7 X3 ^2 K( i* v4 G8 r7 ?
seed = random(32767); ) _  `1 b2 o) \8 c5 R' P$ r  l
srand(seed);
% L- I& v' x- y* ffor (i=0; i<PIXEL_COUNT; <br i++)> {
$ F3 O* b3 w% i" ]5 v: ?x = random(maxx);
! ]3 v, v% a/ @9 [% G4 Zy = random(maxy); 3 A3 H! ^' d2 B5 ~! L
color = random(maxcolor);
9 F2 u, D4 D, G3 @* F: V5 hputpixel(x, y, color);
; I/ C) L; D4 L  A4 o* g} </FONT></P>
( L+ ?5 e2 X5 V* O  \<P><FONT color=#0000ff>delay(DELAY_TIME);
9 {9 x8 q# X( asrand(seed); % M( i- [) e7 A6 q
for (i=0; i<PIXEL_COUNT; <br i++)> { ; ~6 N- w8 j8 Y
x = random(maxx); " G8 C2 L8 t5 V* M0 b% E
y = random(maxy);
, q2 |3 ~+ x! D. I$ Ocolor = random(maxcolor);
" C8 p: w# V( Sif (color == getpixel)</FONT> </P>
1 T# J7 g5 |/ M+ j4 z6 {<P><FONT color=#ff0000>函数名: gets</FONT>
' T7 l1 Z( w! j功 能: 从流中取一字符串 / ?7 b* C* r) L
用 法: char *gets(char *string);
: z, t! Y3 N3 m1 x" Z  g% W9 K程序例: </P>
9 t6 F8 \3 ~- |" z' V- K9 [6 A<P><FONT color=#0000ff>#include <STDIO.H></FONT></P>) k% S$ h" Q; R
<P><FONT color=#0000ff>int main(void)
( P% `+ S0 C  ^- X6 J( n% E8 |% @{
! F# M- N9 z9 O/ U7 n1 Lchar string[80]; </FONT></P>
+ @, M7 E7 t- |4 e4 D. a* u<P><FONT color=#0000ff>printf("Input a string:");
' [: w, F" e/ U5 L6 a1 @gets(string); ( m' W! y/ O" Y' |9 U' w
printf("The string input was: %s\n", 7 G8 m5 S  Y  r7 l& h
string); 7 Q6 ~* R" j9 h' {1 O
return 0;
/ l/ C- f& Q& T4 x, I}
# g5 Y$ h1 H2 u/ b4 T6 U+ W) I$ m: \
! S0 V. K- ^' H, y$ Q</FONT></P>8 ^, b: N8 G3 j6 |( }. `. D( f
<P><FONT color=#ff0000>函数名: gettext </FONT>
4 p7 H1 b9 n) T& o: _功 能: 将文本方式屏幕上的文本拷贝到存储区
# c& e" G0 ?( w! b" q. f1 J) ~用 法: int gettext(int left, int top, int right, int bottom, void *destin);
0 B  t4 f5 j' M5 c$ N. Z# }: v- j程序例: </P>
3 L4 i" R! W9 u+ j<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
. P6 T1 m, d; k* H1 H! ~<P><FONT color=#0000ff>char buffer[4096]; </FONT></P>
, a3 o" ?. B, p( E& e<P><FONT color=#0000ff>int main(void) ( y! H; `7 k, }. ^$ I' }& o
{ " r. e& z8 z% F+ F0 o
int i; & b# W! Z/ x7 t) F7 o5 ]
clrscr();
4 `- e2 n/ g5 Q  V9 r% Ifor (i = 0; i &lt;= 20; i++) 2 y. \: e2 }9 v
cprintf("Line #%d\r\n", i);
5 i9 ^( o( S! ^& xgettext(1, 1, 80, 25, buffer); . w5 ]+ ^9 ?$ v+ j* H9 n3 {
gotoxy(1, 25);
% b% C* }' b* c( q/ J6 a5 ycprintf("Press any key to clear screen...");
* `" U$ u; o4 s: kgetch(); ( g: v- n( F% B* R
clrscr();
8 P9 |- o0 Q( i0 ]4 W! I9 n, Jgotoxy(1, 25);   V: H& G  B" B4 y+ g  l
cprintf("Press any key to restore screen..."); : u1 p$ m7 \4 u% i4 x' v: m1 l
getch(); " C" N( }5 Z0 z4 W: `4 e
puttext(1, 1, 80, 25, buffer);
# l0 T8 h! u- f8 @9 {& `gotoxy(1, 25);
7 b8 n; p9 K% d$ h, \' l6 C4 ^cprintf("Press any key to quit...");
$ U! t/ A5 `' _getch();
, |( _8 D) ?& xreturn 0;
$ }+ p* b5 Z- b1 L7 L3 v) k: f}
% Z/ R% A4 v. d6 \/ n</FONT>% P5 w/ }8 n' @0 L1 \5 S; |  \
</P>
: C" \4 p5 P# N! ]8 Z$ R<P><FONT color=#ff0000>函数名: gettextinfo</FONT>
0 _; I$ J7 e9 F" W7 s功 能: 取得文本模式的显示信息 + c' ?: t+ E3 ]6 F( \
用 法: void gettextinfo(struct text_info *inforec);
0 _. L$ ~4 }0 Y; N- x程序例: </P>
; T# s, c# w, R4 F! Q- o<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
0 i  P) f( B! T2 a; N<P><FONT color=#0000ff>int main(void) $ [# @0 X" ^7 I# a2 l
{ 7 V3 Q. S. H2 P6 o
struct text_info ti;
) K5 g- T  w7 F' kgettextinfo(&amp;ti);
+ _0 v# |, F6 o& v& ^. [cprintf("window left %2d\r\n",ti.winleft);
- q- y) `& V% Icprintf("window top %2d\r\n",ti.wintop);
, r; C" w0 B3 q% T, fcprintf("window right %2d\r\n",ti.winright); ; t% a7 X: A9 k2 V& x7 x
cprintf("window bottom %2d\r\n",ti.winbottom);
  K, X& Y5 M' N0 O% P* ?! L- j7 acprintf("attribute %2d\r\n",ti.attribute); # S4 K! b. m) q5 F$ ^
cprintf("normal attribute %2d\r\n",ti.normattr); . M# W3 x% I" B' Z/ l
cprintf("current mode %2d\r\n",ti.currmode);
. \7 q3 K. m7 Rcprintf("screen height %2d\r\n",ti.screenheight); ' E& }+ g% j- O0 V* P
cprintf("screen width %2d\r\n",ti.screenwidth);
- x: h9 z9 w4 c! B) Ocprintf("current x %2d\r\n",ti.curx);
9 k, |  \8 z. T& J# wcprintf("current y %2d\r\n",ti.cury);
" T3 y9 @1 ~& O9 a1 V5 P& [return 0; ) j. I- V5 s2 z, h! l4 j' f* [
} / t5 c. U/ D5 I% J; W5 C
</FONT>
- }. p& q9 |2 K: R6 a" k% t9 Z</P>
" Q( h; N( }( [3 v( @8 v<P><FONT color=#ff0000>函数名: gettextsettings </FONT>
" t  H5 I+ e) d; B功 能: 返回有关当前图形文本字体的信息
) j. g4 u! o! I8 S8 _6 k. t用 法: void far gettextsettings(struct textsettingstype far *textinfo); 5 w3 D, b! v/ h$ N, E6 \& G
程序例: </P>
9 f; W  `7 y& P! g<P>#include <GRAPHICS.H><FONT color=#0000ff>
: `$ S8 U2 D3 D" v, v#include <STDLIB.H>$ F; {* U3 }: K5 i) g' a; F2 }
#include <STDIO.H>1 j6 V( f! r& N0 _
#include <CONIO.H></FONT></P>
3 a6 g  ^5 |8 r5 G" b5 |% Y7 Y<P><FONT color=#0000ff>/* the names of the fonts supported */
+ S5 H8 \# R0 ]1 [! S" `char *font[] = { "DEFAULT_FONT",
; t. E& G2 O% c9 r# x"TRIPLEX_FONT",
3 C: P5 }* N! R"SMALL_FONT", ! Y8 `. }" t) n- A
"SANS_SERIF_FONT", ) S& k5 l* B) P) z& w0 u
"GOTHIC_FONT"
0 _+ I9 @+ f/ W8 k% S; J2 @# M}; </FONT></P>
# j+ ], W# S$ Z1 L- k<P><FONT color=#0000ff>/* the names of the text directions supported */ * i& Q# @% c" Q) z
char *dir[] = { "HORIZ_DIR", "VERT_DIR" }; </FONT></P>
" W+ I1 U0 [6 }+ f; J0 w7 P0 }! B<P><FONT color=#0000ff>/* horizontal text justifications supported */ ) w1 F* G+ _' A& s: v
char *hjust[] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT" }; </FONT></P>
4 p6 S3 Z+ ~6 f* d0 C+ c( f; k<P><FONT color=#0000ff>/* vertical text justifications supported */ 7 X* e1 y& f0 D! Y% O
char *vjust[] = { "BOTTOM_TEXT", "CENTER_TEXT", "TOP_TEXT" }; </FONT></P>
" t- J" t3 ?0 i1 u( ~; X7 V<P><FONT color=#0000ff>int main(void) 3 I  |8 Y5 Y. U6 Y
{ 4 L* F5 ~1 z8 W9 S5 ^# a: a
/* request auto detection */ , L. U2 V' r0 s
int gdriver = DETECT, gmode, errorcode;
" Z% ]4 u2 }7 a, Ystruct textsettingstype textinfo;
# L! F: ]6 y; N+ tint midx, midy, ht; 7 X7 j/ h. E  m8 b' O
char fontstr[80], dirstr[80], sizestr[80]; ! E2 V9 c6 Y1 e2 `, j+ _
char hjuststr[80], vjuststr[80]; </FONT></P>% x, G# i7 O/ p; I
<P><FONT color=#0000ff>/* initialize graphics and local variables */
2 f" V' v! ^9 ]+ Yinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
/ v( F& ^7 @  Q<P><FONT color=#0000ff>/* read result of initialization */
- g& j2 c2 l+ v' perrorcode = graphresult();
- a* I! s+ E% ?* fif (errorcode != grOk) /* an error occurred */ + x1 `4 Y+ q  o. Z/ l/ N
{
0 ]% U+ G6 Q$ n$ a8 jprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 4 o1 N6 l: M6 v" a. s& O6 ?
printf("Press any key to halt:");
. p+ X0 p- Y! p8 Cgetch(); 8 y3 f% u6 l. v3 t
exit(1); /* terminate with an error code */
& o7 F) d2 {7 u  M+ P# g: P} </FONT></P>& V& n5 C6 ~; e' K* A
<P><FONT color=#0000ff>midx = getmaxx() / 2; . z% B6 p) j. T
midy = getmaxy() / 2; </FONT></P>
7 `. W6 o/ c8 L& M<P><FONT color=#0000ff>/* get information about current text settings */ & v+ @! B! M+ S7 _
gettextsettings(&amp;textinfo); </FONT></P>2 l: @: H. G; I
<P><FONT color=#0000ff>/* convert text information into strings */ . g+ m. i; n' D
sprintf(fontstr, "%s is the text style.", font[textinfo.font]); ! _; [8 U( {7 d, R2 |/ ^& W
sprintf(dirstr, "%s is the text direction.", dir[textinfo.direction]);
6 _9 U( S* K. Xsprintf(sizestr, "%d is the text size.", textinfo.charsize);
5 V( X# e$ v: ?$ f5 p5 Gsprintf(hjuststr, "%s is the horizontal justification.",
6 m2 q, Q3 U: whjust[textinfo.horiz]); 4 ^7 J4 M( |; ?9 a
sprintf(vjuststr, "%s is the vertical justification.",
" A# x9 {" b4 ?* e( Lvjust[textinfo.vert]); </FONT></P>- Z& Z# Y( x0 R/ `" O8 x+ i
<P><FONT color=#0000ff>/* display the information */ % Q0 x9 M& G" t; S+ i2 a6 y: \
ht = textheight("W"); - }' x% F& h9 U) c$ C0 C
settextjustify(CENTER_TEXT, CENTER_TEXT); 8 x  s, U; B1 Z# k- A6 r
outtextxy(midx, midy, fontstr);
3 Q5 K* E# p% x  i" b% V/ A/ q4 o0 Jouttextxy(midx, midy+2*ht, dirstr); ) }+ m! t' e7 ^$ A: R* }2 Z  s
outtextxy(midx, midy+4*ht, sizestr);
0 ?8 f) L  Y8 H3 c7 j% }outtextxy(midx, midy+6*ht, hjuststr);
8 k! w; `) D$ O: t6 {outtextxy(midx, midy+8*ht, vjuststr); </FONT></P>
7 h+ S; A: R) @- G! n" x<P><FONT color=#0000ff>/* clean up */
. h" ~: C; ^6 E- {% zgetch();
+ F. I+ W& _" p$ Z+ a; l6 tclosegraph(); $ C& t8 p; I# D# W# z3 ]8 M
return 0; " A; S$ k  O( w, \: E
} </FONT>+ {; D0 }) z: Z$ v5 g
</P>
2 ], o' c, `: m7 W<P><FONT color=#ff0000>函数名: gettime </FONT>5 ^* k5 j( s( b+ W! z
功 能: 取得系统时间
7 U9 [, i0 e$ R/ i2 {用 法: void gettime(struct time *timep);
: F. g0 y3 ~1 Z/ M) y2 p程序例: </P>
: c  D# P& l+ K( D1 t<P><FONT color=#0000ff>#include <STDIO.H>
5 q+ d) t, p7 I% ^#include <DOS.H></FONT></P>
$ h3 }% H- z# T: o<P><FONT color=#0000ff>int main(void) 2 ]1 Y3 D0 ~" ]4 m, n" J
{ ' G0 n9 N1 t9 M' f
struct time t; </FONT></P>0 g4 c! V- c; q& i- ?8 L3 ]
<P><FONT color=#0000ff>gettime(&amp;t);
. z5 @8 j; q( p- T) yprintf("The current time is: %2d:%02d:%02d.%02d\n", # M2 v. y- a) O5 t1 n% M
t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
! q7 z; `, x8 m- ^8 Ireturn 0; . Q0 }2 ~- Y, N) D7 c
} . M$ _, P+ c' N0 \+ K0 @
% y2 G# F' e# ~5 m( e/ k# m
</FONT>
4 r( f3 x' B9 n</P>
, B; q' X, Y; {7 |9 f<P><FONT color=#ff0000>函数名: getvect </FONT>' U; d7 A! T0 h- k- h% H
功 能: 取得中断向量入口
$ o& q) k5 C4 I& ~/ N用 法: void interrupt(*getvect(int intr_num));
1 C+ V0 k) @# [+ [程序例: </P>0 ^; o2 c' u3 u8 x" B
<P><FONT color=#0000ff>#include <STDIO.H>
9 j( C- Z; U8 i; n) r  U6 @#include <DOS.H></FONT></P>
8 M' ]7 O. b$ f  y/ X<P><FONT color=#0000ff>void interrupt get_out(); /* interrupt prototype */ </FONT></P># f, x! P0 }# E! p% _% ?: @: H
<P><FONT color=#0000ff>void interrupt (*oldfunc)(); /* interrupt function pointer */
/ \! {2 X: x8 [9 hint looping = 1; </FONT></P>! w) R* j) M3 C
<P><FONT color=#0000ff>int main(void) ; j( A, X' n% n7 n2 n- t+ x
{ * \% `0 C! j) f" q% _3 s
puts("Press <SHIFT><PRT Sc>to terminate"); </FONT></P>9 v- K& t0 m& [: }. e
<P><FONT color=#0000ff>/* save the old interrupt */ 1 v5 @  P! r! G! G/ u2 l" n  e
oldfunc = getvect(5); </FONT></P>
3 N' l( v  E% N! w: g* a( t<P><FONT color=#0000ff>/* install interrupt handler */
, N6 I, ~) B! Osetvect(5,get_out); </FONT></P>
6 M5 c  f7 Z2 _. T<P><FONT color=#0000ff>/* do nothing */ 2 j& i' u' ]* r1 B* G* n
while (looping); </FONT></P>
) A4 {' m, M4 N- b7 U<P><FONT color=#0000ff>/* restore to original interrupt routine */
7 H3 ?- j  V; p/ D3 Gsetvect(5,oldfunc); </FONT></P>
2 O" o' x8 u, M6 R! E! H5 q$ j) R0 a<P><FONT color=#0000ff>puts("Success");
7 O4 o- Z  O7 [6 T- sreturn 0; . s! x. i4 }1 v
} ! Z  s. w- v- N. d
void interrupt get_out() $ K8 `, s- Q- S6 I9 q
{
/ L( i: r* q1 E, o7 _: T( ?looping = 0; /* change global variable to get out of loop */   o% `7 c; L/ _+ v0 x5 }7 U
}
+ c, E1 n" H. e3 d% B+ V</FONT>
2 L" i. z* o: ~* [  M) L</P>% g3 v$ P, K$ s
<P><FONT color=#ff0000>函数名: getverify </FONT>
( f" o- u8 ]1 `9 S功 能: 返回DOS校验标志状态 " ]6 s3 F# ~! n$ I% [
用 法: int getverify(void); ' s& z( W5 H5 f1 _! C# {
程序例: </P>, v& T- I/ Y) g( z/ Q+ p( ]8 I
<P><FONT color=#0000ff>#include <STDIO.H>
: O; k/ E8 \- q4 @7 {' f/ {$ l#include <DOS.H></FONT></P>1 Q, I! ^! O2 f( W
<P><FONT color=#0000ff>int main(void) 0 H6 }& r# D+ o1 G. d
{ 5 c0 _- l" R0 \
if (getverify())
8 x: a) b# F+ c9 Eprintf("DOS verify flag is on\n");
) D1 M0 p* o% J2 eelse 8 Z8 n4 w7 [) E. }3 }  k/ w- k
printf("DOS verify flag is off\n");
6 Z2 j- x' @, j1 treturn 0; . W3 [' K$ M" T% a
} + T/ j- w4 f8 @9 E( X, m
</FONT></P>
4 t7 N* O5 U# q. n<P><FONT color=#ff0000>函数名: getviewsetting </FONT>
& f* {7 }, y& @1 T7 O& c. X功 能: 返回有关当前视区的信息 : A" g& A  k, l' z6 s/ m
用 法: void far getviewsettings(struct viewporttype far *viewport); ( y% h! Y9 t; p: D8 C
程序例: </P>
% s, U( I6 c) g- U% f<P><FONT color=#0000ff>#include <GRAPHICS.H>
" f& W' A! O% u; D+ ]#include <STDLIB.H>
& t4 _) ^9 j. R#include <STDIO.H>
, x2 s+ O6 t  ^+ |#include <CONIO.H></FONT></P>
! r3 B' ?4 {" `9 @, o& D" g! b<P><FONT color=#0000ff>char *clip[] = { "OFF", "ON" }; </FONT></P>8 B( C9 L5 @; c- k8 f
<P><FONT color=#0000ff>int main(void)
) f# S0 s' o' _  i  l# z% t0 i* c{
& m* L5 L: M2 P/* request auto detection */
# q. X. B* Y; n/ k' {int gdriver = DETECT, gmode, errorcode; , A7 y/ ~& E( Y- ]
struct viewporttype viewinfo;
- Q% l) _2 O, k& N3 f; U+ Eint midx, midy, ht; ) E' Z9 X2 s! T8 P7 N
char topstr[80], botstr[80], clipstr[80]; </FONT></P>
* R; A- `/ f8 S7 R2 V* y<P><FONT color=#0000ff>/* initialize graphics and local variables */
: m  ]) q) A8 i0 S) u$ dinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>8 M8 ]- c0 F. E8 H" I2 p
<P><FONT color=#0000ff>/* read result of initialization */ 0 p$ E1 u7 y7 h- S
errorcode = graphresult(); + l, u+ c: d9 P
if (errorcode != grOk) /* an error occurred */ : j8 z6 C+ b) Z: y6 ?
{ 5 a2 t& ]) C' x2 U) S2 Z. ^4 n
printf("Graphics error: %s\n", grapherrormsg(errorcode));
0 K4 k( S6 g6 ]# W  [printf("Press any key to halt:");
: I/ T! p8 y' Y! ]getch();
( b2 m+ F: F7 I& Y  t+ Yexit(1); /* terminate with an error code */
/ b* a! e' w2 T  a- u} </FONT></P>
& y' m0 C  }5 U8 u) o; X<P><FONT color=#0000ff>midx = getmaxx() / 2;
) }3 r2 |4 [" `midy = getmaxy() / 2; </FONT></P>& O; {, d/ O$ C: z5 e, Q/ [
<P><FONT color=#0000ff>/* get information about current viewport */ + M: t$ Y, H  M5 z# r
getviewsettings(&amp;viewinfo); </FONT></P>8 \* G, a7 `3 ]; q( f; H5 f8 j
<P><FONT color=#0000ff>/* convert text information into strings */ 7 _2 Q$ ~* k: X& _0 l  }
sprintf(topstr, "(%d, %d) is the upper left viewport corner.", 2 b. F# _* ]' }* _; L! b( Z
viewinfo.left, viewinfo.top); , H. w+ ]0 T+ S. ?
sprintf(botstr, "(%d, %d) is the lower right viewport corner.", " Z! u' d) H' M3 j
viewinfo.right, viewinfo.bottom); 6 g4 Z' l/ N6 f- o& L, D
sprintf(clipstr, "Clipping is turned %s.", clip[viewinfo.clip]); </FONT></P>
: p9 E* A5 {* k5 w/ b5 Q+ Y<P><FONT color=#0000ff>/* display the information */ 2 u  l  `# ?$ |: Q
settextjustify(CENTER_TEXT, CENTER_TEXT);
- W5 l; x2 ?) _3 aht = textheight("W"); + L0 ]# G& }+ L& Y" n8 v; E
outtextxy(midx, midy, topstr); - c0 o/ b) L, u" i  u
outtextxy(midx, midy+2*ht, botstr);   f0 o. E% G! O; a
outtextxy(midx, midy+4*ht, clipstr); </FONT></P>1 o" g* Q) Z& @- K% ^
<P><FONT color=#0000ff>/* clean up */ 7 v, |5 j2 T4 k  ?3 \. T
getch();
4 N) Y1 T$ \! `7 R4 Gclosegraph(); 7 M* S5 T8 G  M
return 0; - h5 G! Q/ E4 F1 w
} </FONT>  C# c8 E' [. n  e0 k% b: ^
3 r' D; ~2 I% V- J) `& }: m- o
</P>% k9 k1 [% T6 z+ L$ u5 q
<P><FONT color=#ff0000>函数名: getw </FONT>, B' D: o9 p  x
功 能: 从流中取一整数 / `* b4 H1 `4 e- Z
用 法: int getw(FILE *strem); & k7 l9 i- g- Q
程序例: </P>9 H. P% {: ^/ T! g" V  u3 u
<P><FONT color=#0000ff>#include <STDIO.H>
0 r4 b. p9 M% H: ~4 {7 E#include <STDLIB.H></FONT></P>
. d% _: F" L( G5 \<P><FONT color=#0000ff>#define FNAME "test.$$$" </FONT></P>! e+ a3 G: G7 h. v( W: l
<P><FONT color=#0000ff>int main(void)
: k& Q' L% p$ h# @& O  i{ , J' {' d% v$ A7 M# ~5 h" ~
FILE *fp; , `" n5 _) ~0 _4 W* S$ Z
int word; </FONT></P>) |6 |- a; w, h
<P><FONT color=#0000ff>/* place the word in a file */ 9 U% V& u1 V( }9 h
fp = fopen(FNAME, "wb");
1 Z4 H2 U$ z9 eif (fp == NULL)
7 _6 x  s" R( i) I" L{
7 l0 F; p! k7 H* w; ]printf("Error opening file %s\n", FNAME); 4 m9 i0 G4 ~& U% e( S! Q
exit(1); 6 x7 Z' t8 j4 G
} </FONT></P>; g. y3 o/ o- M2 D
<P><FONT color=#0000ff>word = 94; ) {) l( k2 N" ]  k/ f, e/ G( e
putw(word,fp); % R7 ]4 z- e1 X& @% _; I
if (ferror(fp)) : c, Q/ h5 {- x' K
printf("Error writing to file\n");
3 ~9 B& k, C8 n, ]else
3 p' O( [8 d( Fprintf("Successful write\n");
# C, R4 H6 x2 d9 w) Zfclose(fp); </FONT></P># P) O1 A) f! `; l6 d: W+ \' o
<P><FONT color=#0000ff>/* reopen the file */
& n5 N# O1 }3 `0 Y# Q" M  G# dfp = fopen(FNAME, "rb");
  k; C. n* [8 l% Pif (fp == NULL)
+ J- o8 ?% [9 _% ?6 A; l% q: @{ 5 [5 J1 y; `3 {$ `! L
printf("Error opening file %s\n", FNAME);
1 u- h4 b" c  kexit(1);
6 z8 c# J( Y. i' D% q4 {7 U} </FONT></P>* J* k& D+ b# x( I% j: l
<P><FONT color=#0000ff>/* extract the word */ ( h# |. E+ k3 M( {5 N! Q
word = getw(fp);   P2 t8 B' c+ c) a+ G, Z6 o
if (ferror(fp))
" P; E) F( T% s- o+ ~+ sprintf("Error reading file\n");
1 S( `2 o2 R7 T) Xelse 6 B9 Z) o+ ^7 }: s, X% |' f
printf("Successful read: word = %d\n", word); </FONT></P>
. z: |' n) Q* T  I5 R: g* z<P><FONT color=#0000ff>/* clean up */
8 d# e/ G/ t# I  p$ y" X! J% N0 r% h+ ffclose(fp);
/ s- j; b5 l* Qunlink(FNAME); </FONT></P>- d; m$ O1 D6 `
<P><FONT color=#0000ff>return 0;
( N* ~) l" b" E, g} </FONT>9 J; v# }1 K& A* n4 w
, E7 k/ x5 U. @$ A/ C
% ]. X9 V% o8 J, p% f& b) i7 }  ^
</P>, C& @: r& i( I  N
<P><FONT color=#ff0000>函数名: getx </FONT>& ~2 u% H/ D2 S  \
功 能: 返回当前图形位置的x坐标 $ E1 |6 N2 z5 w
用 法: int far getx(void);
% B2 p$ X" a4 T) \, l' ?程序例: </P>! u1 J, i% \1 x' z0 G
<P>#include <GRAPHICS.H><FONT color=#0000ff>- m: E, Y) y: j: ?
#include <STDLIB.H>- Y$ t& l, J) i) e' |  c
#include <STDIO.H>
) ~% d/ G$ u: E: m: A#include <CONIO.H></FONT></P>$ h6 j  B+ l, a$ ^( g/ T3 i' ?
<P><FONT color=#0000ff>int main(void) - D8 k. I! P1 u
{
! D6 |3 g, H- w# V/* request auto detection */
" \0 _/ u9 M' x( \8 D$ gint gdriver = DETECT, gmode, errorcode; / c* J; \9 [1 H9 A' [
char msg[80]; </FONT></P>4 F8 Z  b; S* D$ I" H3 u: t* u
<P><FONT color=#0000ff>/* initialize graphics and local variables */
; F$ J, s. }# v: _initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>& a0 V, x' t$ O8 N& j" Q! S2 s
<P><FONT color=#0000ff>/* read result of initialization */
* h5 S8 Q2 z: @! W, Ferrorcode = graphresult();
4 l1 e% ]+ N0 K, }6 n8 p: Oif (errorcode != grOk) /* an error occurred */ ' ?0 @% h* A2 y7 ~8 T$ a1 d
{ ; l" J4 x4 F# I0 b5 q0 b- _) `9 ^
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 9 S  r& X, B& Q8 K
printf("Press any key to halt:"); $ A, W2 ~4 E& u% x% s" y0 T2 Q+ h
getch(); & `, c4 H* z" a$ `$ J
exit(1); /* terminate with an error code */
: D2 o2 L7 C$ E$ q# t1 Z5 }} </FONT></P>; g5 H4 w5 d; r' h& M
<P><FONT color=#0000ff>/* move to the screen center point */
* G. q) M/ c2 zmoveto(getmaxx() / 2, getmaxy() / 2); </FONT></P>7 J6 y( N0 d2 P  w. M
<P><FONT color=#0000ff>/* create a message string */
: ^6 y, k3 [7 R, {sprintf(msg, "&lt;-(%d, %d) is the here.", getx(), gety()); </FONT></P>! L9 U* ^4 R4 p
<P><FONT color=#0000ff>/* display the message */ 9 l- ^0 C6 A5 @6 _/ M4 c7 E( u
outtext(msg); </FONT></P>
3 x* d. T  B6 r6 C: m<P><FONT color=#0000ff>/* clean up */
9 L+ |! d) T6 {! b$ W# h1 igetch();
, E2 a& Z2 U1 [' x$ Sclosegraph(); ; t5 R1 }+ T1 R
return 0;
* F9 Q/ a8 l: [6 A) _' y: }! Z4 C} </FONT>
, f: V; u' B, [* F8 w9 c/ C
6 t+ d. h# Y2 n. t& t# {( u</P>
0 ]0 t% u. x& ~! s- g' y& {<P><FONT color=#ff0000>函数名: gety </FONT>7 f9 e% ?) d; [
功 能: 返回当前图形位置的y坐标
# b/ b; i. M2 D- c& M5 q: g, C用 法: int far gety(void); 6 r$ w' T' s. l# h( k$ Q( B& ^, m( m" L
程序例: </P>) R6 y0 W0 G% T& K
<P><FONT color=#0000ff>#include <GRAPHICS.H>$ S  T' K( E+ p1 L2 H& ?
#include <STDLIB.H>( q" T- }+ \* U+ @% g, I2 L# P7 R  s
#include <STDIO.H>( U+ l( D% W: c2 n
#include <CONIO.H></FONT></P>
+ w2 H: \! P- U8 H7 B<P><FONT color=#0000ff>int main(void)
$ v7 L/ k4 u+ i# |{ - D; M! f# W* `2 A1 l
/* request auto detection */
9 W! N5 i4 r# m8 ?; L7 yint gdriver = DETECT, gmode, errorcode; ' [( r! U- Z' z
char msg[80]; </FONT></P>
$ m! V, _/ u" q<P><FONT color=#0000ff>/* initialize graphics and local variables */ 6 b# A) A7 c3 f1 x# y
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
" h1 k8 J- Q+ |3 [( \( `. D2 C- Z<P><FONT color=#0000ff>/* read result of initialization */
3 S& w. v# U. u3 Kerrorcode = graphresult(); 2 M, y5 s3 A, L( q' t/ [' B
if (errorcode != grOk) /* an error occurred */ 3 S" E" [: q+ C" p
{ ' L9 l9 z/ g0 l, `/ o0 p
printf("Graphics error: %s\n", grapherrormsg(errorcode));
, E) G, ], ^' _# d/ Q2 H: Cprintf("Press any key to halt:");
) b6 y0 `: @6 x* D8 f* c+ Ygetch(); $ ]1 S* S! r* @6 W- O& b7 t
exit(1); /* terminate with an error code */ 6 `8 M9 M9 Q0 s$ d3 F' |8 `' i
} </FONT></P>, L# R0 k* G8 t7 I6 m7 f- h
<P><FONT color=#0000ff>/* move to the screen center point */
- S) h' F. S0 Kmoveto(getmaxx() / 2, getmaxy() / 2); </FONT></P>" |  P9 s7 l- Y6 M
<P><FONT color=#0000ff>/* create a message string */
4 l# S7 [" L& k# B% r, w1 ]sprintf(msg, "&lt;-(%d, %d) is the here.", getx(), gety()); </FONT></P>
8 Q  R& V; {  x. Q: s7 Q, t<P><FONT color=#0000ff>/* display the message */ . N6 e- b. w2 s" z  M+ H! ~9 V2 r
outtext(msg); </FONT></P>
3 B( n) n# J# a! Q<P><FONT color=#0000ff>/* clean up */
2 W( L0 I. F/ dgetch();
7 r) a* V, x* i7 m  @/ `closegraph(); 4 Y! p& |% P' K. x
return 0;
* J: q2 C. @$ B; ~, \; |} </FONT>
/ r5 L, _9 }$ p7 C1 f7 k
6 r! [) t* U; T, ~% ?4 o  X0 l+ m  j</P>
( l: O3 A3 i/ b$ }4 ?+ v( ~<P><FONT color=#ff0000>函数名: gmtime </FONT>
8 J1 S: t+ k! m0 r! f功 能: 把日期和时间转换为格林尼治标准时间(GMT)
, M3 K1 z* W( r4 x; \6 }用 法: struct tm *gmtime(long *clock);
, l$ X7 y% N' s2 I! ?5 }9 t程序例: </P>
* L6 E1 t1 Q; p! }3 r<P>#include <STDIO.H><FONT color=#0000ff>5 e/ Q& ~; f/ u' _( e. L- |
#include <STDLIB.H>& a. e! u' ]8 _  _$ U; s" D) x  `
#include <TIME.H># ^/ K; K% N0 D; Q! v' w0 O
#include <DOS.H></FONT></P>
/ \) Q/ x/ u- N0 F3 u8 ?<P><FONT color=#0000ff>/* Pacific Standard Time &amp; Daylight Savings */ ) m8 M4 ^  s; G( B- X
char *tzstr = "TZ=PST8PDT"; </FONT></P>
5 c* m. P1 ~4 _* o/ Y3 L; }<P><FONT color=#0000ff>int main(void)
% |/ ~2 ~6 j# P( B8 b  r) a{
* _: r& n7 b8 ?6 x6 q: Gtime_t t;
' w' i# C$ w) r. q/ b4 D7 J* G. mstruct tm *gmt, *area; </FONT></P>
# g3 l! G- w* B/ n6 e2 M/ {/ D<P><FONT color=#0000ff>putenv(tzstr); ! Y$ o) K% ]9 a* K+ ~" L2 p3 |& B
tzset(); </FONT></P>
; P0 l3 A6 k  h3 P5 A- X4 y<P><FONT color=#0000ff>t = time(NULL);
% o2 {; `& f, _0 Z+ a; x- uarea = localtime(&amp;t); " a. ]3 E- Q, T6 w9 S: J
printf("Local time is: %s", asctime(area)); 6 r9 x! l- \: G6 W7 A/ e
gmt = gmtime(&amp;t); # `" G3 \8 [- K3 f) f
printf("GMT is: %s", asctime(gmt));
) ]. J; [9 E; F4 c% I$ Xreturn 0; : |) p& m: n1 o1 K( b
} </FONT>! U$ ?0 X0 ]1 X% l& T( e$ b

! O9 B! D/ c) f. j. }5 ]</P>
# A5 a) r9 l& }; Y6 V<P><FONT color=#ff0000>函数名: gotoxy </FONT>; {; D+ u% C2 k* i& y' p
功 能: 在文本窗口中设置光标
$ ~( i( O1 d# u用 法: void gotoxy(int x, int y);
: B' X9 [* l  X2 p3 R9 t程序例: </P>0 x% D: _8 v# X' g6 h; t
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
3 g3 ^( o, x7 z; R/ j( J<P><FONT color=#0000ff>int main(void)
' N& v: @/ e# Q+ f9 F9 I{ * J! z$ B: R$ h. c3 _+ s9 K9 D
clrscr(); 5 |& O' j! ^6 g
gotoxy(35, 12); % m, G! L( o  B* b1 g3 @, @$ w  M5 x
cprintf("Hello world"); $ K' U+ y6 j- q+ c
getch();
4 }0 x! D4 F: r8 Zreturn 0; 0 o; Y8 w8 ]# {8 _% T, \* Y
}</FONT> 6 V+ [! [2 Z/ C# b7 a5 j' s
3 \+ X8 N. D5 q; n& D% C" g0 a
</P>2 n( R3 M. I8 }+ e2 E
<P><FONT color=#ff0000>函数名: gotoxy </FONT>
/ ?7 Z9 E1 `- B& r8 E( `5 i+ C功 能: 在文本窗口中设置光标   Q/ V- G8 L( ~* H; S
用 法: void gotoxy(int x, int y);
7 w- _7 H. U6 A7 T程序例: </P>
; r& l7 P& ?/ \/ K<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>& P0 P' ]' {4 l! Y9 H
<P><FONT color=#0000ff>int main(void)
) W! g$ I1 V+ U" @2 R( j3 c{ 8 q+ h" n8 o$ g/ k0 Y1 [5 w* ]2 v
clrscr(); & P  X7 r' q! y$ q5 |! a! S4 }
gotoxy(35, 12);
) E& @* l. I5 B+ i, w+ Dcprintf("Hello world");   `- D4 y0 v# P' }$ y! W( E7 k
getch();   s( ?7 B& P- p6 _
return 0; + z: k: P' T  R4 v( I( X$ k
} " f! n. U8 ^5 x4 s
</FONT>
  E8 H7 {. p8 S8 k5 H( [2 L</P>
8 p" K, ]& }+ ]7 T<P><FONT color=#ff0000>函数名: graphdefaults </FONT>
9 O" C* l" m1 H0 x& C7 {功 能: 将所有图形设置复位为它们的缺省值 . j! O- g3 p9 W1 G: R
用 法: void far graphdefaults(void); 3 d) |8 N  H! F( L8 w
程序例: </P>
4 u* e# C8 e. r- f<P><FONT color=#0000ff>#include <GRAPHICS.H>! S/ m$ v; Y) h% v) b, V
#include <STDLIB.H>
: B+ Y/ x. [  y/ o& }; `#include <STDIO.H>
9 K) ]. y0 t6 M: _# ^: G2 k#include <CONIO.H></FONT></P>
, Q6 x1 @% e" G2 z, z# w/ g<P><FONT color=#0000ff>int main(void)
8 o% j- {- c5 K& j{ 5 ~# u- w, _& B. N1 I2 @- ]) }
/* request auto detection */
; T! Z+ N# v7 s2 z$ Lint gdriver = DETECT, gmode, errorcode; ' z  [, Y- E" f( m7 i% `+ I
int maxx, maxy; </FONT></P>
' s, H% J7 a8 X$ {  x& J% p1 Y  G<P><FONT color=#0000ff>/* initialize graphics and local variables */
8 ^" }9 m/ m. s) V; r: R* |8 l# E# Iinitgraph(&amp;gdriver, &amp;gmode, "c:\\bor\\Borland\\bgi"); </FONT></P>+ V1 {4 P3 B: f, v, F7 J- @
<P><FONT color=#0000ff>/* read result of initialization */
6 U6 r/ F3 G' M/ N( }errorcode = graphresult();
% L$ F6 W0 Y7 |, }if (errorcode != grOk) /* an error occurred */ 5 e& G) g2 I$ P. [( o1 C0 M
{ % A# ^% t- D/ L3 c! f+ N/ ^2 d  K# Y
printf("Graphics error: %s\n", grapherrormsg(errorcode)); ! z0 w+ k% p1 c" h) ~: f" H' k
printf("Press any key to halt:");
" r3 z  |, i  @1 X& ]getch(); 2 c! @9 B6 k  I8 h$ W; ~  ~
exit(1); /* terminate with an error code */
' O4 P% v8 N' S} </FONT></P>. K- }( B, \  J, P+ V  W
<P><FONT color=#0000ff>maxx = getmaxx(); 0 ?0 e4 C: W: D: o
maxy = getmaxy(); </FONT></P>6 C+ I8 z& D* `6 M
<P><FONT color=#0000ff>/* output line with non-default settings */ 2 ]7 Y' v  V6 c. i
setlinestyle(DOTTED_LINE, 0, 3); - s/ P/ c7 ]! b8 v* C  ?# d4 O; @
line(0, 0, maxx, maxy);
9 q. g( Y+ |0 p  P: o- v1 G& `outtextxy(maxx/2, maxy/3, "Before default values are restored.");
8 N) v. E4 J" A* u9 {7 A9 A6 d$ xgetch(); </FONT></P>9 I  l4 r% d& y! s: b5 [1 z$ K% F/ H
<P><FONT color=#0000ff>/* restore default values for everything */
2 O7 ^4 ~; Q# F. D& ^7 x3 w2 Ygraphdefaults(); </FONT></P>
" h8 ]6 ?3 j& D( J<P><FONT color=#0000ff>/* clear the screen */ & l% q3 e' e, y7 K9 N
cleardevice(); </FONT></P>* I8 u: R1 h4 v# H5 `1 l
<P><FONT color=#0000ff>/* output line with default settings */ ' N# p# A2 R2 X; m5 [! b
line(0, 0, maxx, maxy); ' a) f1 H8 `% x" S# M& g3 J
outtextxy(maxx/2, maxy/3, "After restoring default values."); </FONT></P>! }- l) s4 f/ c6 {4 p# o8 F
<P><FONT color=#0000ff>/* clean up */ 7 \( c9 s$ m3 A9 J
getch(); 7 |2 o1 v3 T% ^! z7 j" q" }
closegraph(); 8 r  E) k9 w  w+ \8 F
return 0;
' P& [1 t+ u+ Z% L} ( u/ S2 j* v5 J
</FONT>
) M& h/ I! B0 `8 l" q9 C5 I</P>8 \$ `; R' H3 P
<P><FONT color=#ff0000>函数名: grapherrormsg </FONT>
  ?0 H+ T$ t4 `5 c7 D; \4 H功 能: 返回一个错误信息串的指针 7 N5 p8 ^" [8 x% l$ ^5 x7 N$ u
用 法: char *far grapherrormsg(int errorcode); 3 S- X' l, }9 W
程序例: </P>
4 q: ]* n, u+ M6 z) v# ~' P<P><FONT color=#0000ff>#include <GRAPHICS.H>
/ v* E- I( j6 M, B) H#include <STDLIB.H>) J% E; i. Q1 d1 x% o) |
#include <STDIO.H>( V7 D6 }$ D( g! Z0 C% N0 w4 `# m% @; f
#include <CONIO.H></FONT></P>
8 r0 Y- j1 d# L7 ^) B8 R<P><FONT color=#0000ff>#define NONSENSE -50 </FONT></P>
* W4 ~' g4 p) D! f7 V<P><FONT color=#0000ff>int main(void)
8 O( ~, U( e7 t% [4 J7 V# l( Z{ 1 P! f  d9 H' U" z& z
/* FORCE AN ERROR TO OCCUR */
9 W3 S- ~! C% `" ^" {2 C7 @: Kint gdriver = NONSENSE, gmode, errorcode; </FONT></P>; g3 F& I  q! h8 T- i
<P><FONT color=#0000ff>/* initialize graphics mode */ 0 J9 R. I2 [* O* t8 l; W1 @6 S1 `
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
/ V  B8 `- G: D, ~; _) L1 C<P><FONT color=#0000ff>/* read result of initialization */
0 D( E$ i1 d2 k, q* h! Werrorcode = graphresult(); </FONT></P>
; n5 S/ L: C' }* `: A6 s2 `% C5 p3 F<P><FONT color=#0000ff>/* if an error occurred, then output a */
2 B9 X5 m, e2 J( `- ]- l1 _/* descriptive error message. */
5 n  ^! S& o  D! mif (errorcode != grOk) 4 G/ r" t2 p1 u# @$ o: n
{
/ X& C" H7 m' B, V* w$ W3 Iprintf("Graphics error: %s\n", grapherrormsg(errorcode)); : B  e/ F7 N% w" c. J
printf("Press any key to halt:");
  W; B" T; ^4 W+ a6 ]2 r2 F8 r4 Sgetch(); 4 l8 Y  {! m% o9 \9 l! j7 P/ Q7 ?8 C
exit(1); /* terminate with an error code */ ) L. j7 n/ ]9 y* k- y
} </FONT></P>% C1 s# [! _+ }' G
<P><FONT color=#0000ff>/* draw a line */
& |% u* m2 {4 ]line(0, 0, getmaxx(), getmaxy()); </FONT></P>
% d! r' ]7 j: G& O<P><FONT color=#0000ff>/* clean up */
( d. h+ B7 z4 i# xgetch(); ' l4 ]. F# E. L* b4 n' Q1 y6 y
closegraph(); / ~3 v/ Y, d! @0 y
return 0; 6 [  b$ E. V- z5 @" Y# D: c
}
% m4 y& Z$ V' b% A6 O  g% D. Z</FONT>
+ Q( e& v3 Z( }7 l</P>
& E- o9 c: p+ D! M  E: n" e<P><FONT color=#ff0000>函数名: graphresult </FONT>4 ~  B0 F3 |6 {; J
功 能: 返回最后一次不成功的图形操作的错误代码
  a9 h4 F4 j" }- H) S* o5 J用 法: int far graphresult(void);
. ]8 ]" X( i0 P. g( e程序例: </P>7 L! N+ T  x% C# `6 H: Q
<P><FONT color=#0000ff>#include <GRAPHICS.H>
' H4 Z, o  S* x  P6 k- h3 S#include <STDLIB.H>
! r8 V' o) {% M# v4 b#include <STDIO.H>0 J( s/ K  R9 n6 q3 o- S
#include <CONIO.H></FONT></P>- ^/ Q' _" _5 a! D. F+ s& m/ I
<P><FONT color=#0000ff>int main(void)
# B4 e3 n# e, `{
& j$ L# k; Y+ Y- ]/* request auto detection */
! |3 J: a( r6 xint gdriver = DETECT, gmode, errorcode; </FONT></P>
' N( G6 d" y( u! T. [% D<P><FONT color=#0000ff>/* initialize graphics and local variables */   h1 g% ~5 ]; j8 f: n) R" q
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
0 L( v0 H( c9 Q. ^; w" p- x<P><FONT color=#0000ff>/* read result of initialization */
4 f8 k2 \( R+ gerrorcode = graphresult(); </FONT></P>
% c4 b; K# s5 l<P><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */ & S  Z- q# p- b8 n- H; F
{
, r7 ?% E' Z/ X6 Fprintf("Graphics error: %s\n", grapherrormsg(errorcode));
& |* f, W6 {7 D' w7 oprintf("Press any key to halt:"); & T" S+ E4 N+ T/ K) K. w1 f
getch();
0 c, K/ W" O$ H$ T" y5 h; `, K. Y6 eexit(1); /* terminate with an error code */
8 S3 r, n# `4 S} </FONT></P>. C$ C5 x; y& ?
<P><FONT color=#0000ff>/* draw a line */
  `2 h, g9 ], V* `line(0, 0, getmaxx(), getmaxy()); </FONT></P>/ H) Q0 c4 J/ q
<P><FONT color=#0000ff>/* clean up */
- _) X: _% B% N8 kgetch();
$ J  `" _5 g- d- n" W, Q7 h, Kclosegraph();
& g$ k: J: V3 H) g* W$ Creturn 0;
% E5 ]& U- U1 `! r& v. S- n}</FONT>
4 L; T* \7 u5 T+ F2 Y* _) T7 |</P>
; W0 _) I# i. {' E9 L, @) z<P><FONT color=#ff0000>函数名: _graphfreemem</FONT>
+ j2 X! d, Z' M& L( e/ O3 o功 能: 用户可修改的图形存储区释放函数 8 |4 f- L0 Z! H9 b+ h  E
用 法: void far _graphfreemem(void far *ptr, unsigned size);
6 ~6 A6 B" z2 p1 f$ ]5 h5 h% q程序例: </P>& x" [$ Q* _8 h+ O' W. z; O, o( z( M
<P><FONT color=#0000ff>#include <GRAPHICS.H>) x4 Y, q7 ?1 ^3 q8 R# R
#include <STDLIB.H>1 W; x/ D. ?( U+ i  m
#include <STDIO.H>
7 J( _% |5 f: T  K9 D% ]#include <CONIO.H>
  g# o- x1 O4 a#include <ALLOC.H></FONT></P>
+ J  i- `  S( i7 g. a<P><FONT color=#0000ff>int main(void) 1 Q7 H5 L4 `# ]/ W
{ 2 ]( c% @4 H- M$ L. S2 |) c( V
/* request auto detection */ 6 z9 a, K7 l# A; p
int gdriver = DETECT, gmode, errorcode;
0 ^7 I1 X& y6 O2 vint midx, midy; </FONT></P>7 C' d( F$ W6 R- }
<P><FONT color=#0000ff>/* clear the text screen */
' j: t2 t3 o4 I% nclrscr(); 8 Q, e- y+ L# u: t2 t6 z! Z0 H4 m
printf("Press any key to initialize graphics mode:");
4 Y' j1 t8 J' J6 Zgetch();
1 M* ^% n5 {3 {, Y$ d" c2 i7 H. Hclrscr(); </FONT></P>1 J6 l1 n* E* k" J
<P><FONT color=#0000ff>/* initialize graphics and local variables */ , I  f5 L( Q# Z4 ]+ S6 c* ?
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>; a$ Y+ U0 i! [' U
<P><FONT color=#0000ff>/* read result of initialization */ : Z9 j- U2 F0 D
errorcode = graphresult();
" p: e8 k" X/ v( o7 A4 Dif (errorcode != grOk) /* an error occurred */
. }0 |" t" }: Z3 G! ?1 I# A{
4 Y4 S7 ?, |6 k2 zprintf("Graphics error: %s\n", grapherrormsg(errorcode));
4 C- Z% n7 ]" M4 K2 W1 eprintf("Press any key to halt:"); * F" j; S9 Q+ p
getch();
& v+ x7 Q( [5 l9 texit(1); /* terminate with an error code */
9 f( j+ S9 B- S2 k7 I} </FONT></P>1 n, T/ q" f2 K7 K* f
<P><FONT color=#0000ff>midx = getmaxx() / 2;
! a+ e7 i( f) r  @  y* amidy = getmaxy() / 2; </FONT></P>3 Y! z5 C7 A: x. {8 X# i
<P><FONT color=#0000ff>/* display a message */ $ m, _# H$ u! e* Y
settextjustify(CENTER_TEXT, CENTER_TEXT); : s7 h# s% g+ \3 P2 Y; Q
outtextxy(midx, midy, "Press any key to exit graphics mode:"); </FONT></P>
% m3 H6 r$ e+ y8 P  ]# J, t0 d# p<P><FONT color=#0000ff>/* clean up */ * r# N! f% R" ~( ]) \( Z
getch();
, s7 l) V2 W3 S, h' L' hclosegraph(); 3 A  w6 O. p% ^- d
return 0; 9 ]/ a0 L1 X% P. L# ^; W) S4 y
} </FONT></P>/ F/ L. z+ T% i7 ]8 G
<P><FONT color=#0000ff>/* called by the graphics kernel to allocate memory */
2 m# C, }3 l/ B( O8 _* Vvoid far * far _graphgetmem(unsigned size)
  N5 e$ I0 b6 i9 _8 Y{
% a  {$ S5 A1 l! V' q9 o9 T; f. ~printf("_graphgetmem called to allocate %d bytes.\n", size);
3 P' P; x5 c! }! e) Bprintf("hit any key:"); " M; S/ ?: c& E) L- [. m; J
getch();
5 U8 K- F/ Y0 q( i$ `printf("\n"); </FONT></P>/ a, M. T; X3 \( _9 ~
<P><FONT color=#0000ff>/* allocate memory from far heap */
& l# R2 P! t( d1 B2 q( Q6 Vreturn farmalloc(size); ' m+ [% x  {% s1 y
} </FONT></P>
7 ?+ p9 l# @, s. [1 A<P><FONT color=#0000ff>/* called by the graphics kernel to free memory */ , ~% J) v! w: B% A' w: \
void far _graphfreemem(void far *ptr, unsigned size) 3 x0 E+ x# t8 `+ |5 f
{ 2 p+ F$ d  Q% I2 s" N% R/ T, I0 Q' R4 z
printf("_graphfreemem called to free %d bytes.\n", size); 1 @& t/ y& Q7 ?( r" T, T! C
printf("hit any key:");
- b- _3 ~0 F/ j8 O' tgetch(); 8 N1 T1 ], ]2 A1 H9 j. J; O
printf("\n"); </FONT></P>
/ c2 v6 u6 |, m7 m# k, B3 w  N<P><FONT color=#0000ff>/* free ptr from far heap */
  J& P0 Z4 ]6 O* nfarfree(ptr); - ?8 O2 C0 B- c7 |& \& k# ^) t
}
; o3 H/ ^8 g: ?8 a</FONT></P>( Q0 _, A, W" y7 }+ z* M
<P><FONT color=#ff0000>函数名: _graphgetmem </FONT>$ o! \# J$ m  j/ Z0 B. u9 [! u
功 能: 用户可修改的图形存储区分配函数
( B: r: X2 [' Y: ~8 ^- a# ^用 法: void far *far _graphgetmem(unsigned size); & q: g7 K6 A- C' G( m& u2 Z4 e
程序例: </P>7 i. c# G+ O% ]! Z
<P><FONT color=#0000ff>#include <GRAPHICS.H>
( s3 k8 o% t) _6 |' q6 Q#include <STDLIB.H>
3 R; {) r9 W  f#include <STDIO.H>
' K! Q! _" b# P" P3 W#include <CONIO.H>0 E' p1 L7 V+ Z+ [) d+ y
#include <ALLOC.H></FONT></P>
& W, \- s' H4 x- u<P><FONT color=#0000ff>int main(void)
1 i- ]# z  a7 c7 v{
% ^1 \7 K: G! e  N  m) J/* request autodetection */ 9 x8 P) \% s, G
int gdriver = DETECT, gmode, errorcode;
7 H7 b, ~) p( r1 }* vint midx, midy; </FONT></P>
) c# S( G6 T  p- }% d+ l; C3 u<P><FONT color=#0000ff>/* clear the text screen */   q4 v5 ~& \: S) c; X  b) C0 b
clrscr();
# `: U% e1 a- {" ~2 \$ V- ^& ^printf("Press any key to initialize graphics mode:"); * Z1 d$ x: t4 h9 ]
getch(); 1 e9 I) x2 _4 U9 s' c  o
clrscr(); </FONT></P>
2 I* |+ x8 |8 R: C# G8 ?+ q: j<P><FONT color=#0000ff>/* initialize graphics and local variables */
" o9 _0 R7 s; P  X) Kinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
9 D& h1 V5 X6 I5 ]# b<P><FONT color=#0000ff>/* read result of initialization */ 5 q! W& A" G2 @4 U; o; d
errorcode = graphresult(); - Z6 \* \* t+ O1 G
if (errorcode != grOk) /* an error occurred */ ; K+ O1 \+ N: U8 O5 y
{
0 g4 A+ j- o+ x8 N! O" X4 rprintf("Graphics error: %s\n", grapherrormsg(errorcode));
8 y1 h% [8 p% A; [- e; jprintf("Press any key to halt:");
$ B7 j+ Y8 `' V# Agetch(); 8 a. C$ H1 U# \% _5 U7 b! Q. C
exit(1); /* terminate with an error code */
6 J9 s7 [  {, n$ N- E3 Y5 ?} </FONT></P>( H$ a" i8 |( }  a* B3 E3 a
<P><FONT color=#0000ff>midx = getmaxx() / 2;
+ I: ^2 C* M' J, n  ]; `6 ?midy = getmaxy() / 2; </FONT></P>8 ?/ O0 i* f+ i9 s* m4 h8 `
<P><FONT color=#0000ff>/* display a message */
8 x+ b4 F3 a1 i( h: S9 Fsettextjustify(CENTER_TEXT, CENTER_TEXT);
4 ~- B7 m5 }& ]1 k  Qouttextxy(midx, midy, "Press any key to exit graphics mode:"); </FONT></P>8 Z& H; D2 n  {: z" O- w6 N
<P><FONT color=#0000ff>/* clean up */
, W& i1 J$ R8 G4 _, G5 ggetch(); 8 _1 O! ?* ^# T  h- g- `+ W
closegraph();
4 b4 P. N& g0 N: A- Ereturn 0;
+ X# A9 Q+ A$ A5 d$ ^} </FONT></P>' v2 L2 P; r- L
<P><FONT color=#0000ff>/* called by the graphics kernel to allocate memory */   I- K( K/ p3 B5 }! ?* N
void far * far _graphgetmem(unsigned size)
+ T, ]: R. @! Y, v5 [9 L{ 2 q* Q5 d* v# F2 ?8 S  G% T
printf("_graphgetmem called to allocate %d bytes.\n", size); 2 ?4 E" }: v. M2 o. I
printf("hit any key:");
0 P% `4 a# g" X4 [3 @9 cgetch();
% _+ G0 L4 f8 h' I, r: j3 ?8 @printf("\n"); </FONT></P>
6 V3 \, _: m; ^$ {<P><FONT color=#0000ff>/* allocate memory from far heap */
- K& V" _" s/ o' V& o1 Sreturn farmalloc(size); 2 f- n8 n% f" {7 H- P: U8 m) @
} </FONT></P>
0 o8 o; K+ a) O, k8 E  s<P><FONT color=#0000ff>/* called by the graphics kernel to free memory */
; T; g. i% K5 I: ]0 z# |; j: bvoid far _graphfreemem(void far *ptr, unsigned size) ! w/ u3 i; ^6 x- V4 x/ D$ _  U
{
5 Z. d: @( R2 y: d) x; H. g/ g$ n# Rprintf("_graphfreemem called to free %d bytes.\n", size);
$ M5 }, p) {" j. i4 T) |1 Q" `printf("hit any key:"); 7 ]) V6 T3 Q1 t: N
getch(); + |5 u& l: g; ~: h6 ?) ]
printf("\n"); </FONT></P>  Z9 F( j9 k+ x/ i
<P><FONT color=#0000ff>/* free ptr from far heap */
4 m  Q' I- [+ Q5 Z$ H7 E2 G3 wfarfree(ptr);
% Q" f  p; g3 Q: @}& K+ P5 h& {) S" _
</FONT></P>




欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5