- 在线时间
- 0 小时
- 最后登录
- 2007-9-23
- 注册时间
- 2004-9-10
- 听众数
- 3
- 收听数
- 0
- 能力
- 0 分
- 体力
- 9975 点
- 威望
- 7 点
- 阅读权限
- 150
- 积分
- 4048
- 相册
- 0
- 日志
- 0
- 记录
- 0
- 帖子
- 1893
- 主题
- 823
- 精华
- 2
- 分享
- 0
- 好友
- 0

我的地盘我做主
该用户从未签到
 |
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(g开头)</FONT></B></FONT></P>
9 C$ x g& f) ^+ Z; e
' M* A2 k% ?2 N! o
9 J4 @, X; T+ [<p>+ Y( B2 @$ j0 l
< ><FONT color=#ff0000>函数名: gcvt </FONT>
1 k) g" [; Q5 v$ L- U* X功 能: 把浮点数转换成字符串
2 g3 ?- [& w1 p用 法: char *gcvt(double value, int ndigit, char *buf); ~3 S& q" J- [) F) w4 w* b/ z
程序例: </P>
# a- }- y) p* P' Z< ><FONT color=#0000ff>#include <STDLIB.H>3 S/ Z+ A/ d$ B7 t# I
#include <STDIO.H></FONT></P>. d" U3 @/ F6 V) S5 C/ l7 a* y$ Y
< ><FONT color=#0000ff>int main(void) 3 C, n0 h' ]8 L r! o9 T
{
- w. N! @8 l0 M0 S& C8 I! ichar str[25];
( l# _4 H) D+ V8 jdouble num;
' S+ {( h* T! U) Z2 y7 m/ g _* kint sig = 5; /* significant digits */ </FONT></P>0 v2 ^! z( u; }" T3 g
< ><FONT color=#0000ff>/* a regular number */ - D' J7 U% `" }
num = 9.876;
% f- s* C. u' r8 jgcvt(num, sig, str); * i+ ?! p- o% U3 b
printf("string = %s\n", str); </FONT></P>
! L1 x7 @ W( }5 C& g< ><FONT color=#0000ff>/* a negative number */ 8 J/ v% q' g; }& }. J% D
num = -123.4567; 1 Z) i1 M( f8 \4 r1 L+ h
gcvt(num, sig, str);
6 x/ V+ v' B4 q2 c+ x$ Mprintf("string = %s\n", str); </FONT></P>. |' Y% R) r/ Q5 s+ Q
< ><FONT color=#0000ff>/* scientific notation */ 3 _- z& T+ T5 v, w: U
num = 0.678e5;
. A2 m; W8 h! a. ~# J8 a- n* ggcvt(num, sig, str);
! c' G. s# B @' f1 [printf("string = %s\n", str); </FONT></P>) z6 E6 P8 L1 L+ L, Y
< ><FONT color=#0000ff>return(0); 4 g: @" M, r1 f6 h
}
: H6 [6 Y: \6 F U7 l
F& a% }' W6 L% |+ @9 k K</FONT>, E9 }& N, M$ X, ?$ r
</P>
* I: ^# U- J3 F) D) I6 o {< ><FONT color=#ff0000>函数名: geninterrupt </FONT>3 a0 f2 R) \ _- @- T$ s
功 能: 产生一个软中断
1 J: K% u6 F; ` F. z" X用 法: void geninterrupt(int intr_num);
! X2 H8 A9 w7 e& r% {# `6 ^7 h0 b程序例: </P>$ z, ?. P1 j' n' F
< ><FONT color=#0000ff>#include <CONIO.H>
. a* [! s) S$ ^+ ^6 D& Y#include <DOS.H></FONT></P>6 P1 F" o; R+ D, h. r- ^
< ><FONT color=#0000ff>/* function prototype */ % I9 H5 L4 W& U ?6 l( q
void writechar(char ch); </FONT></P>
, F" Y# e* z) U7 b6 a3 X< ><FONT color=#0000ff>int main(void)
) f$ I- O3 o" M. K% }/ J{
- l) C$ |. L) ?8 ~& w( Lclrscr(); / t* w' z7 }( ], d4 [
gotoxy(80,25);
7 j/ B* m: e1 A: r$ xwritechar('*'); ) j2 S( J6 p) M
getch(); 2 r& J7 o5 ]: Y/ \3 W! \
return 0; % i' t/ o# \) t Y& R
} </FONT></P>3 s% L v2 \) _+ V. ]/ `
< ><FONT color=#0000ff>/* / O; j$ I7 i5 k5 _5 h3 q
outputs a character at the current cursor ; H6 O7 y' G6 S- q2 v
position using the video BIOS to avoid the / B: W4 N; U& u/ s# j4 k. i+ f
scrolling of the screen when writing to
) p& \5 M) u5 ^- p1 [location (80,25). ' F3 I: k$ q" Q, V0 _# A0 _
*/ </FONT></P>
7 n; n% D, J0 `' t8 Q< ><FONT color=#0000ff>void writechar(char ch) & w2 w, \" _0 `
{
8 A5 V; _8 v4 F" i$ Hstruct text_info ti; / u) t5 v! t' V3 z/ i
/* grab current text settings */
$ A& Q7 I7 b; L( Q Ygettextinfo(&ti);
; Z5 ?) G9 ` n( P2 V4 T/* interrupt 0x10 sub-function 9 */
1 p% _, j% \7 o! |+ G$ s, Z_AH = 9;
& c) `% {$ ]9 ?6 H9 d/* character to be output */ 3 ~- `2 p* v3 e8 y+ r
_AL = ch;
6 h4 f' [% S* R& D/ @_BH = 0; /* video page */
. V! r H/ U2 M- p_BL = ti.attribute; /* video attribute */ , F. g* x2 x. V" o
_CX = 1; /* repetition factor */
6 ~+ i. _8 p) X r( D6 @8 b$ wgeninterrupt(0x10); /* output the char */
! {6 ^% P9 f# J. _, v; D} 4 m7 z: n3 ] K: v
</FONT>$ y4 K8 D! F }% ]% y
</P>
/ R5 `# p+ _* g- L8 [' q9 m< ><FONT color=#ff0000>函数名: getarccoords </FONT>2 `" T) O1 z! P! d% n6 [# A* m
功 能: 取得最后一次调用arc的坐标 9 ?3 d' n; @5 Y: L' `& q
用 法: void far getarccoords(struct arccoordstype far *arccoords); $ K8 S2 h( M# \( t/ p
程序例: </P>
J, ]" c6 s6 Q5 |/ @4 l< ><FONT color=#0000ff>#include <GRAPHICS.H>& N- V- B7 A0 G# E- d2 _
#include <STDLIB.H>0 J% a& A! d3 |5 C$ Y5 u0 f. F6 y4 l
#include <STDIO.H>/ T9 y- R9 M/ t6 d$ t
#include <CONIO.H></FONT></P>. I `( @. ^1 p j9 f
< ><FONT color=#0000ff>int main(void) - ?8 Q) l9 C8 K# r
{ $ ?/ \, f4 H8 p' J4 L0 |! w
/* request auto detection */ % d* J8 @8 y2 b6 e" b: _+ a
int gdriver = DETECT, gmode, errorcode; 1 C, u$ c" Z1 X" A9 c; l1 o
struct arccoordstype arcinfo; + @4 F" N8 g! w5 P8 w- i5 P" g
int midx, midy; $ U$ l# o1 G/ U! t1 W
int stangle = 45, endangle = 270; - A; K2 V x. a% }% F
char sstr[80], estr[80]; </FONT></P>
$ ~# H1 o, u6 ^< ><FONT color=#0000ff>/* initialize graphics and local variables */ 4 |: v- ]% o' w+ G
initgraph(&gdriver, &gmode, ""); </FONT></P>! s5 _! E. D. J/ e
< ><FONT color=#0000ff>/* read result of initialization */ / S; n# G' h A. I$ g
errorcode = graphresult(); + M+ }! Y, E) }3 S4 ]. l& h
/* an error occurred */ " q8 L+ V% ]6 d( t. U! R5 g% J1 O
if (errorcode != grOk)
8 r1 V- A" {/ M7 R* i! R{ + `* _& O( u+ q; n( n0 h/ O
printf("Graphics error: %s\n",
C1 q2 P3 X; G0 _grapherrormsg(errorcode));
9 n7 v% g8 M/ sprintf(" ress any key to halt:"); 4 Y8 }. _' r ]$ G6 t1 u3 `5 Y
getch();
' `6 m5 r$ n+ e" Y/* terminate with an error code */ , Y" t$ D- _+ O
exit(1);
' F3 p: @9 M9 l V, h} </FONT></P>
0 @! R8 r2 P- _( u- S. a< ><FONT color=#0000ff>midx = getmaxx() / 2; , n) A5 z* ]/ Z2 }9 |
midy = getmaxy() / 2; </FONT></P>6 `, q8 R7 E; W) @5 G# u1 j7 s1 c
< ><FONT color=#0000ff>/* draw arc and get coordinates */ % y; _5 k- N% Q6 D
setcolor(getmaxcolor()); * g5 }9 g- U5 V, F+ X
arc(midx, midy, stangle, endangle, 100);
0 N: A. q# {2 B6 X/ p/ o0 mgetarccoords(&arcinfo); </FONT></P>
4 {4 e' i+ x0 r4 B: u2 M: C< ><FONT color=#0000ff>/* convert arc information into strings */ + _9 ?* _/ S& ~9 W( Z
sprintf(sstr, "*- (%d, %d)",
1 V$ ?3 b4 I @' C6 `6 warcinfo.xstart, arcinfo.ystart); 7 Y* m" u( ^" O3 _: p/ u5 X
sprintf(estr, "*- (%d, %d)",
( k' v( C1 ]9 g9 y# Harcinfo.xend, arcinfo.yend); </FONT></P>
: J$ k( Z+ q$ k) g4 W3 A< ><FONT color=#0000ff>/* output the arc information */
" }$ K v1 @0 R+ Q( f. k' Z6 wouttextxy(arcinfo.xstart,
4 s( w/ `# X: u/ u xarcinfo.ystart, sstr); ; [5 V5 {; b# j$ o) E5 j
outtextxy(arcinfo.xend,
$ w1 B1 X6 K; c- F @arcinfo.yend, estr); </FONT></P>
2 l' y& L4 d! H< ><FONT color=#0000ff>/* clean up */ 0 v2 P9 V' Q- F' x
getch(); 2 B9 W* M# ~. b# W
closegraph(); 2 \; ~8 J8 R# w! C
return 0;
& g$ R% Z# {3 I" u8 T% Q% Y}
4 P6 @" A/ o, G7 }4 u( a! P, B</FONT>( C% c" }9 a3 u" r2 {7 K( R
, @* i$ d9 W' u' V# N4 [</P>3 S, v2 _# j' }5 P% P0 M
< ><FONT color=#ff0000>函数名: getaspectratio </FONT>7 `& y0 w/ ^6 c6 d
功 能: 返回当前图形模式的纵横比
E& c1 O8 e% C6 p9 ^3 [) R3 u用 法: void far getaspectratio(int far *xasp, int far *yasp);
% w; ]1 X$ Y0 L/ n. k$ t5 W4 z程序例: </P>
. `( b- _0 H+ _- p, H+ G< ><FONT color=#0000ff>#include <GRAPHICS.H>
& a0 D, ]1 {& ]+ A# W9 h/ h#include <STDLIB.H>/ |. s( `" W- T
#include <STDIO.H>! X* K8 e4 l" o; @6 h6 M1 f
#include <CONIO.H></FONT></P>
7 w# i9 H, W1 Y9 [< ><FONT color=#0000ff>int main(void) & Q* ], f9 i2 r) [9 v/ x( R8 U
{ ) S; q( ?& c0 M
/* request auto detection */
1 C$ j8 z1 m1 j4 T4 vint gdriver = DETECT, gmode, errorcode;
, f0 [6 [) N& T) }0 qint xasp, yasp, midx, midy; </FONT></P>0 T2 X) x5 W! [, w: v. L; N
< ><FONT color=#0000ff>/* initialize graphics and local variables */
5 X/ c: T& W7 V( a" Pinitgraph(&gdriver, &gmode, ""); </FONT></P>
I( Y. E& H0 n* W5 G$ I% V5 g< ><FONT color=#0000ff>/* read result of initialization */
3 E% M0 h0 s$ Q9 k9 rerrorcode = graphresult();
/ C5 m; a* c/ N* I$ }9 k/* an error occurred */ & {' H4 v1 u5 q& }! k2 m0 y" j
if (errorcode != grOk)
) z s4 D" a& o* [ W{ 7 B; l! E0 q; Y' F
printf("Graphics error: %s\n", 5 H. v: Y! ^% J, P
grapherrormsg(errorcode));
) i/ x8 k% e2 a& H4 L: B1 Gprintf("Press any key to halt:");
8 a! l) ]( g% {getch(); ! x$ o: z" |8 w+ X0 h& N* A
/* terminate with an error code */ + [* r- x8 m; O3 B/ ?
exit(1);
% Z) J0 J8 \$ p! b. {. Z6 @} </FONT></P>
. L! A" ]( \0 K<P><FONT color=#0000ff>midx = getmaxx() / 2;
- Y. f1 c# C' |midy = getmaxy() / 2; # [* h) i1 T: W# t$ u
setcolor(getmaxcolor()); </FONT></P>4 E! H# U; c) d, E! H
<P><FONT color=#0000ff>/* get current aspect ratio settings */ ' H3 c7 X! p3 W; d1 S
getaspectratio(&xasp, &yasp); </FONT></P>! Z- Z* y2 k* u5 F$ t0 S" e
<P><FONT color=#0000ff>/* draw normal circle */ v2 u- G) ]7 j+ n
circle(midx, midy, 100); 0 J" ?* q" ^- p6 O
getch(); </FONT></P>
+ [7 l* S6 l2 o<P><FONT color=#0000ff>/* draw wide circle */
; S. I8 f' U+ G% Z! U" ycleardevice();
% _3 |. i$ _1 V# t, xsetaspectratio(xasp/2, yasp); : a; E( W" h" @# D& G9 Q( T
circle(midx, midy, 100);
: I8 M8 Y) h0 a! f8 fgetch(); </FONT></P>
3 w3 z& L3 L) B7 {5 S' z& ]<P><FONT color=#0000ff>/* draw narrow circle */ / \) O/ n# R. n9 X
cleardevice();
9 b7 p7 Y- g" i. dsetaspectratio(xasp, yasp/2);
' k6 V: |+ k. _circle(midx, midy, 100); </FONT></P>: \2 N1 U# A* k
<P><FONT color=#0000ff>/* clean up */ 8 K. i7 `5 {2 ~6 {
getch(); ) f" c. i% C% }8 i- y
closegraph(); ' p0 r4 J7 C" E; ?8 `
return 0;
2 R B y$ _! ^7 }0 @2 ^$ y} : L: y5 H+ I* }9 e- z
</FONT>
' R1 h6 W0 e9 m& W. ]. e+ b3 A9 p: h3 @1 z1 ~
</P>
' l4 N2 S7 x- A8 K' m) T4 l6 m<P><FONT color=#ff0000>函数名: getbkcolor </FONT>0 ~; H5 D: x, V" p0 j6 W
功 能: 返回当前背景颜色
( v& u3 Y6 w% `' _用 法: int far getbkcolor(void); 0 @4 w& \( q' w+ ]7 V4 \
程序例: </P>
! b W! ~. ^* x7 P) i: w5 W5 W<P><FONT color=#0000ff>#include <GRAPHICS.H>
7 w, t& U3 ?) {0 j; b#include <STDLIB.H>
- ?7 j# {% M0 D#include <STRING.H>
) V6 Z; Z" r7 q. c& O3 w+ s#include <STDIO.H>6 A* }% y8 b1 } B
#include <CONIO.H></FONT></P>: F! V' W/ O' w* q6 M
<P><FONT color=#0000ff>int main(void) $ u2 {) x( t$ i* x2 Z
{ $ l0 A: h! Z% L, r# z" V& i- A, E
/* request auto detection */
5 U( @' ]7 o% Y+ j% Aint gdriver = DETECT, gmode, errorcode; + y/ F' k' Z; r) x9 f* \7 T
int bkcolor, midx, midy; , u" k& S2 n/ ]" C
char bkname[35]; </FONT></P>( ^! |' z2 @9 z, X! L6 @3 p, v6 y* R
<P><FONT color=#0000ff>/* initialize graphics and local variables */
! ~9 T$ K/ t: A0 i: H0 \9 Ainitgraph(&gdriver, &gmode, ""); </FONT></P>
2 n0 L2 z2 z, h<P><FONT color=#0000ff>/* read result of initialization */
$ o, B9 r+ D( verrorcode = graphresult();
0 x/ W8 |6 h% b) N& _/* an error occurred */
5 s: R0 h; E& q5 tif (errorcode != grOk)
- Y# i4 l# b& e, t( H% x& d' } ~# y{ + D5 O5 D% o) e$ T7 `
printf("Graphics error: %s\n",
1 X0 _/ \' n7 j" |) X: c& Z9 x B9 A* H) ~grapherrormsg(errorcode)); 0 P& T! j, w+ T
printf("Press any key to halt:"); : T0 w: k4 B) T+ S* W- @
getch(); M4 W9 f; l1 k2 k& x
/* terminate with an error code */
8 s/ ?, _7 H3 g; s! W9 ]/ cexit(1);
4 I ]5 a W& }# I/ u8 G} </FONT></P>0 v# b* }- h6 n# x1 B# |# ?
<P><FONT color=#0000ff>midx = getmaxx() / 2;
9 X" Y4 }& p& d) h9 m$ Gmidy = getmaxy() / 2; 3 O) F$ B t, \; L
setcolor(getmaxcolor()); </FONT></P>3 i' g" e/ r% C5 O3 l
<P><FONT color=#0000ff>/* for centering text on the display */
& c, ~( C* K& Z* Dsettextjustify(CENTER_TEXT, CENTER_TEXT); </FONT></P>
6 ]3 l8 N8 `% Q3 D$ h<P><FONT color=#0000ff>/* get the current background color */ * l1 s- @; z# k6 W1 M6 y
bkcolor = getbkcolor(); </FONT></P>
* t# ^: p" N8 s$ Y/ n<P><FONT color=#0000ff>/* convert color value into a string */
* u' ]* n$ g4 o* W# Pitoa(bkcolor, bkname, 10);
! \3 g3 p, a9 F" h% A3 Astrcat(bkname,
6 F' ]" b. h& v; o: P& u" is the current background color."); </FONT></P>: I3 R6 z9 u! j
<P><FONT color=#0000ff>/* display a message */ , N/ D9 e* d1 @! ^" _8 w
outtextxy(midx, midy, bkname); </FONT></P>
3 M: B5 H* i- b1 T8 {<P><FONT color=#0000ff>/* clean up */
, Z% N: S3 f$ t# d) \8 Z1 cgetch();
7 @$ n( u* i' w& u9 Q1 Hclosegraph();
- C2 g. B) I% H, b- Y/ Areturn 0;
- c3 G1 H; E: E8 ~% O7 Y. l} }" u$ {! ?+ L( k
& B$ u0 I" Q6 Y v4 ?8 {
</FONT>
7 [" g$ k6 N4 y# [+ c</P>" a$ f" X/ X' `# L8 }# l7 l, h/ U& W
<P><FONT color=#ff0000>函数名: getc </FONT>
8 r9 b! r9 d8 i3 z: o: Y1 G功 能: 从流中取字符
/ `2 p/ Z3 _+ V& G: n用 法: int getc(FILE *stream);
, `* ^6 h, d! i" l) G" g, L程序例: </P>
) e# a8 p: }5 V0 _, D' |. Y7 o& ^# K<P><FONT color=#0000ff>#include <STDIO.H></FONT></P> z% r( O T$ W$ x% H
<P><FONT color=#0000ff>int main(void)
1 C: M5 A: e. {' [" Q% q8 V{ 8 D! ^* l) c# Z8 e
char ch; </FONT></P>. J6 ~- d; m; J: F0 e: O' C
<P><FONT color=#0000ff>printf("Input a character:"); 8 N3 J5 R; N# ?* T/ R* ~
/* read a character from the ) _1 O+ d& A1 d7 {' m2 a
standard input stream */ & s& R4 N; H& Y9 a: x0 |4 a" v
ch = getc(stdin); * ~( n1 t4 V$ K" i9 [/ m
printf("The character input was: '%c'\n", ( C2 P/ M J8 o; d
ch); 8 }9 q3 d6 n& B; [! s
return 0;
5 M5 Q7 Q! h1 r} 1 U' g/ H. C- { q) k
; V: p( Y" S- Q2 m4 g
</FONT>
% K* A. E# D5 x o% Q1 ]0 m</P>: x- r/ Y0 f9 J* b! W
<P><FONT color=#ff0000>函数名: getcbrk </FONT>
' m1 _% u/ r; F' Z7 i功 能: 获取Control_break设置 # q$ @/ Q: G/ c/ t2 a/ F( K5 a& j
用 法: int getcbrk(void);
' Q# C9 s0 d6 `+ X程序例: </P>: l/ B5 P3 U8 g6 e K
<P><FONT color=#0000ff>#include <STDIO.H>; ]# v' ]- r$ L/ } J6 n5 l
#include <DOS.H></FONT></P>) @6 _8 O' D, o" [0 h+ c
<P><FONT color=#0000ff>int main(void)
/ K7 G2 }$ _+ ^4 J5 b) ^{ 7 `1 F% J2 v, Y" {9 l8 e
if (getcbrk())
, n) ^2 }) {; u- `/ v; T, @printf("Cntrl-brk flag is on\n");
( I4 }! Z2 Q: p/ i) Q5 R- `- Q% yelse
# H- E+ {6 s1 i% [0 @- tprintf("Cntrl-brk flag is off\n"); </FONT></P>
. B1 W P# [8 W* F<P><FONT color=#0000ff>return 0;
+ i# `' r6 i( D& b6 X2 F} </FONT>8 O& J& O( ^4 q. c* t# s8 B- V
$ o4 u* z; a. Q' |4 m4 a; y J</P>/ t! H9 k. Q, ^8 \ B$ h _
<P><FONT color=#ff0000>函数名: getch </FONT>
2 z* D& i: g* E9 W4 ]. R( ]& `/ B0 \功 能: 从控制台无回显地取一个字符
9 _1 }# f+ N" u# ]" A s: e$ y用 法: int getch(void);
4 ?6 C4 |7 F r8 W( T& {5 a2 f程序例: </P>2 V; N( ~8 e0 i& m: {0 J) D$ v
<P><FONT color=#0000ff>#include <STDIO.H>/ ^" o# I' j/ L" C2 j8 _
#include <CONIO.H></FONT></P>- `0 b/ I+ n9 J( j
<P><FONT color=#0000ff>int main(void)
" t5 K+ M* I+ o% |+ C! {9 Z( _( K{ ( s7 ^0 f3 V5 H7 o' s& K6 M
char ch; </FONT></P>
* C$ _- O# p6 a% N& V<P><FONT color=#0000ff>printf("Input a character:");
+ F: p' a {" Pch = getche();
2 z1 w/ D! X) E3 J% X& aprintf("\nYou input a '%c'\n", ch);
3 e; w0 n: f" \& l) ?; treturn 0;
" ^+ w' c5 z1 D. p' G} : m) b& V/ [; r: K7 e
+ G5 b% B' x8 Y; X% F5 U
</FONT></P>
4 ?, H' r" H {! B<P><FONT color=#ff0000>函数名: getchar </FONT>
* o" Y! @7 H0 z功 能: 从stdin流中读字符 2 a2 q. D) J j
用 法: int getchar(void);
' l- P1 G" V' n# v$ c程序例: </P>
* p( S) \/ [) H<P><FONT color=#0000ff>#include <STDIO.H></FONT></P>- h' c* F" W- I7 K* P" y, e8 q3 z2 G
<P><FONT color=#0000ff>int main(void)
& _1 q) c) X; z* {: j4 y1 g{ $ Z2 b9 F! u& E! i$ E& K
int c; </FONT></P>
, _# t8 v1 w# r. S- C<P><FONT color=#0000ff>/* Note that getchar reads from stdin and
9 u9 C$ C* W& m5 F8 U& V7 Y, O0 _is line buffered; this means it will
. ?& ?0 i; Q" D! @) N9 }1 @5 Mnot return until you press ENTER. */ </FONT></P>
" J' Q! [. C& a, c<P><FONT color=#0000ff>while ((c = getchar()) != '\n')
, n4 i# ^9 Y. O# `: lprintf("%c", c); </FONT></P>8 y3 c6 T# a- k2 c- Y
<P><FONT color=#0000ff>return 0;
/ @) l2 P, [/ F6 g: H: D}
* ~5 O* q- t. J</FONT>8 c: q7 W# V/ h3 s: @9 D3 f" q$ F$ @" K& C
</P>
' V* h* c$ a8 H- I- z+ M<P><FONT color=#ff0000>函数名: getche </FONT>" U4 b& W, J- ^6 h" G+ ~
功 能: 从控制台取字符(带回显)
. l/ J V, r( a3 l* W. s% Z用 法: int getche(void);
; K/ E" H" s' _6 e程序例: </P>) @) G1 e% e, s2 z" y
<P><FONT color=#0000ff>#include <STDIO.H>
2 M) n6 E) p; C: l#include <CONIO.H></FONT></P>+ ?- A: K8 S: D2 w1 t9 G9 E5 h. I
<P><FONT color=#0000ff>int main(void)
# d% J. t) p6 k. l2 M/ x3 R& S8 l{
; O+ `8 R( Y# V: l( f0 U- \2 W- ~char ch; </FONT></P> ?7 n6 k! y5 [; A
<P><FONT color=#0000ff>printf("Input a character:"); 1 s' W: R2 s( q0 f# F
ch = getche();
6 a8 u& V X" b4 J4 M1 `( eprintf("\nYou input a '%c'\n", ch);
. O6 N$ Y: H c# V8 x4 @return 0; ' d6 \, f: h3 t3 l5 b
}</FONT>
a9 ^5 T( O# G' {- \. T, O, ~' y& C' p5 ?. a f8 X
</P>, y( I1 }9 n: U5 i- C/ ^
<P><FONT color=#ff0000>函数名: getcolor </FONT>
: m( X0 I: L, G- W功 能: 返回当前画线颜色
/ H5 w2 E9 p0 r+ ]8 g用 法: int far getcolor(void);
3 @8 ^ d8 P+ f) g+ E, H& S程序例: </P>9 ~1 k+ |& {4 Z
<P><FONT color=#0000ff>#include <GRAPHICS.H>
) E2 \/ v2 M7 w/ o1 q#include <STDLIB.H>* x1 x2 T; }- j8 K _
#include <STRING.H>
: M7 C1 x$ P/ I7 e& P+ ^5 K1 y& a#include <STDIO.H>
& s+ Z- B1 ^% m z# v5 b#include <CONIO.H></FONT></P>4 G) ~. e( a+ |' C! g
<P><FONT color=#0000ff>int main(void) 9 S% O; C# u, W. p: p
{ 2 B+ J4 y/ M2 p5 ~, Q
/* request auto detection */
# @" D& j. ?- @1 x, P, Nint gdriver = DETECT, gmode, errorcode;
! @+ @' ?3 V( G8 C! Q$ Y Yint color, midx, midy; ' @ p# F( X2 _# A
char colname[35]; </FONT></P>
- e% K$ v# ^" n3 U T& k7 f<P><FONT color=#0000ff>/* initialize graphics and local variables */ + b8 W) d2 o; i# |+ g# l
initgraph(&gdriver, &gmode, ""); </FONT></P>& \: Z5 c$ S/ P! G6 `& p3 I
<P><FONT color=#0000ff>/* read result of initialization */
: I" R( _0 s" t3 Y! s, A. p- Terrorcode = graphresult(); 3 i8 I" k, ?8 }3 P
/* an error occurred */ & D. ^; I m3 |4 K" K& L
if (errorcode != grOk) L7 Y9 }3 C* E- t1 w* f& I& m3 T
{ ( L6 Z. J H9 q5 k
printf("Graphics error: %s\n",
' [' L" n4 _" Y6 n& C6 fgrapherrormsg(errorcode)); 1 E. g/ M" m/ M1 t1 {$ B) C
printf("Press any key to halt:"); 8 I" |2 E9 V8 W6 b% h7 n: Z& [
getch();
! N' v7 |) w. e/* terminate with an error code */
& l% n0 d! a& z3 S) ?# dexit(1); ' S2 A2 G+ ]. u2 ^" d" p' h* _/ ]( L
} </FONT></P>
4 r( N4 g, R* f<P><FONT color=#0000ff>midx = getmaxx() / 2;
( S# w! s k8 Z3 q) h7 P* Emidy = getmaxy() / 2; % z; c" F' v$ b% b" j
setcolor(getmaxcolor()); </FONT></P>
# T8 t* f' ?, U# A- Q$ M<P><FONT color=#0000ff>/* for centering text on the display */ 5 g7 ]+ e4 c9 ^! w$ Q# |3 e. j
settextjustify(CENTER_TEXT, CENTER_TEXT); </FONT></P> s6 M! q0 M/ o
<P><FONT color=#0000ff>/* get the current drawing color */ # r' ?% d0 k8 ~% d" j# ]9 z
color = getcolor(); </FONT></P>: F" B, ~( p* [* B: l( l! C; l9 a
<P><FONT color=#0000ff>/* convert color value into a string */ * k9 y3 e8 @; |/ W( o
itoa(color, colname, 10);
4 j! |3 n( F: k6 J4 Istrcat(colname,
' X" i% y# W9 [" is the current drawing color."); </FONT></P>
$ j4 w% s, d* D<P><FONT color=#0000ff>/* display a message */
) N0 ]$ ]$ Z0 u7 s5 souttextxy(midx, midy, colname); </FONT></P>) ?* v5 F5 f7 k- F: N
<P><FONT color=#0000ff>/* clean up */ / y$ l% W" D$ l" V
getch();
) v D+ D8 U3 i5 d( K: Y v6 mclosegraph();
' r$ x$ @' V! A( j, w# ]return 0;
1 q8 |+ y6 G4 H}
K& i* [- F+ Z0 B</FONT>
" T }4 N6 n& x& T+ P, l; O</P>6 Y; b( |' ^9 |+ h8 Q
<P><FONT color=#ff0000>函数名: getcurdir </FONT>* T2 r% I& O4 T
功 能: 取指定驱动器的当前目录 , g' m; Z s, _$ |8 M7 S
用 法: int getcurdir(int drive, char *direc);
7 V% A6 f& N* |$ `程序例: </P>: C9 \% Z; D9 ^( ~" S B m
<P><FONT color=#0000ff>#include <DIR.H>! L+ L/ K/ f) v+ |
#include <STDIO.H>8 k: G- x% V: B# ]8 V- n! o
#include <STRING.H></FONT></P>
+ L+ F5 g' }6 \7 V4 ?1 x( v: U<P><FONT color=#0000ff>char *current_directory(char *path)
/ {# T, @7 n4 K) u2 Q{
9 H2 O A' H0 K1 Dstrcpy(path, "X:\\"); /* fill string with form of response: X:\ */
4 _' T* ~ ?* `* J. Z( tpath[0] = 'A' + getdisk(); /* replace X with current drive letter */
: a( `* N, G5 N" o3 r/ Hgetcurdir(0, path+3); /* fill rest of string with current directory */
" J2 {# t8 ?4 l* _- I" ?return(path); * E" P* D. y' i8 o. Y+ m+ P
} </FONT></P>- ] _% p6 i1 A
<P><FONT color=#0000ff>int main(void)
9 |2 o4 \0 J6 R9 H. J$ y2 \7 _" G{ # O: W3 h1 e3 o2 E4 r5 O
char curdir[MAXPATH]; </FONT></P>, E6 Y* p0 H% H( j
<P><FONT color=#0000ff>current_directory(curdir); $ H/ ? o' U3 D8 d8 I
printf("The current directory is %s\n", curdir); </FONT></P>
" r- F3 I5 Y- O' L$ z% m k<P><FONT color=#0000ff>return 0; 2 U: h n2 i2 ~$ u8 o
}
% O6 y/ o( G: O' h# `</FONT>( {, b' x- _4 R2 f
</P>
# I( e) F* F( m( O; r$ V<P><FONT color=#ff0000>函数名: getcwd </FONT>
! A, q7 q0 |( t功 能: 取当前工作目录 $ {+ I+ I& J- s! m; v- l
用 法: char *getcwd(char *buf, int n);
3 s0 n( u* H( b/ a% ?& V程序例: </P>
: x3 d5 a8 p7 D7 @) S" l<P><FONT color=#0000ff>#include <STDIO.H>9 s1 e& F( j# x7 K( u/ N/ x: N3 H
#include <DIR.H></FONT></P>
' R5 ^" E O0 A6 c3 O3 b$ m<P><FONT color=#0000ff>int main(void)
, l5 p. A$ ~: T. ?3 g{
: N$ {, u& j3 A* O! w. W" Echar buffer[MAXPATH]; </FONT></P>
. T1 f, V: N* q9 T3 d' M8 E O1 m<P><FONT color=#0000ff>getcwd(buffer, MAXPATH); ' m$ G' g, @9 m& ]5 i2 v
printf("The current directory is: %s\n", buffer); 1 U3 g c5 T1 u
return 0;
0 {% U; E7 L2 o' t# S} </FONT>6 }- t+ z- T! S
6 |# Y9 T0 F4 p$ r% G</P>
% ]% q; H0 B! W/ s! M, H<P><FONT color=#ff0000>函数名: getdate </FONT>) Y9 ~ {% T5 q$ E F
功 能: 取DOS日期 8 R$ j$ E" N# c b) M. ^# {
用 法: void getdate(struct *dateblk); , ~; ~ F7 F3 Y7 d( h& s; |' V
程序例: </P>9 @( p* d( n8 X! d
<P><FONT color=#0000ff>#include <DOS.H>
% Y, p$ i2 Y+ @1 o1 l+ \" _% Z. ?; |#include <STDIO.H></FONT></P>5 Z" L8 n- e+ h, D5 z7 W! n5 Z! h
<P><FONT color=#0000ff>int main(void) ; v) B0 B% r4 r5 z3 _
{
+ @4 Z0 f2 A2 [' v' T$ f# c) Istruct date d; </FONT></P># {8 {8 Y/ l1 C3 x" l. g* B
<P><FONT color=#0000ff>getdate(&d);
2 r( ]% x: @/ @) ~. ?( Mprintf("The current year is: %d\n",
3 K( n& T2 C" p6 i. ?d.da_year);
& S( f! G5 w8 G" J; |8 rprintf("The current day is: %d\n",
% j7 |3 k. n/ `d.da_day);
5 J6 q8 `+ U" H6 [( e) `printf("The current month is: %d\n", 1 M( J* @8 b! E2 c: s+ d
d.da_mon); ; H7 L$ U5 m- V1 D
return 0; - {, ?% a# f B
} 6 `' I* `: s, y. t6 n
</FONT>
3 K- L9 @! u1 x6 i( t6 O</P>
! A9 _6 Y; M; k1 M h<P><FONT color=#ff0000>函数名: getdefaultpalette </FONT>: M" x, @' e8 A
功 能: 返回调色板定义结构 $ r/ p$ b9 g6 @5 u
用 法: struct palettetype *far getdefaultpalette(void);
. c- S- G, k3 C0 Q: I程序例: </P>4 m2 r& q3 C- s5 D9 E1 G$ c4 f% V! M
<P><FONT color=#0000ff>#include <GRAPHICS.H> `3 f+ x5 ^ L7 h* ^7 `
#include <STDLIB.H>
. I1 ^ X6 i) V#include <STDIO.H>
2 c/ x I2 |$ |$ y, H#include <CONIO.H></FONT></P>
# Q. v- F8 }, ~2 y# N<P><FONT color=#0000ff>int main(void)
0 [0 Z1 f2 r. S) R! T9 g* q{ ) ` \& V( d9 \( m' \; o+ x
/* request auto detection */
6 A* n( T- L4 y) X( Jint gdriver = DETECT, gmode, errorcode; - N) D& o' p' P5 d
int i; </FONT></P>
5 G3 c: G% O1 `6 q q3 t6 j& r2 \8 b$ [<P><FONT color=#0000ff>/* structure for returning palette copy */
( M5 Y* g, A6 v6 M4 {struct palettetype far *pal=(void *) 0; </FONT></P>; @; a0 O) `' A' a$ z6 j, ~
<P><FONT color=#0000ff>/* initialize graphics and local variables */
. O8 _5 E( Y0 J' [2 s3 V7 Zinitgraph(&gdriver, &gmode, ""); </FONT></P>
) G g" _, i* R! ?3 u<P><FONT color=#0000ff>/* read result of initialization */
7 z+ g" s# W; c/ A7 H) K9 Zerrorcode = graphresult(); 1 K8 N* V7 `5 P
/* an error occurred */ ! n' H! y. v0 d. t7 J+ x0 Z
if (errorcode != grOk) 6 c" T8 {# B; ?$ i, Z# C
{ ' r7 d- J- w) X9 t
printf("Graphics error: %s\n",
. Q V0 `& b/ D% ?; `grapherrormsg(errorcode)); 0 U- r* t5 S# m; q! y; W$ i6 J6 j& h
printf("Press any key to halt:"); % o4 v+ `, F$ Y/ Y4 l- R( w
getch();
! @/ _7 ]+ X$ X1 i/* terminate with an error code */
& `; D( z a+ f1 X! Vexit(1); A4 h O& k; u- ^0 x
} </FONT></P>: w( ?. u) N. E
<P><FONT color=#0000ff>setcolor(getmaxcolor()); </FONT></P>
! w* y% h: P( s: h! j" W2 c( S$ X<P><FONT color=#0000ff>/* return a pointer to the default palette */
8 m+ x: E% B2 i* d* Apal = getdefaultpalette(); </FONT></P>
& @! O- q+ e& ?! N( s<P><FONT color=#0000ff>for (i=0; i<16; i++) , _' h* J! x% l; |+ d. Z
{
3 A1 r8 i* y' M1 d- E2 ]/ K- `9 ~1 Sprintf("colors[%d] = %d\n", i, 8 f. {5 c0 P3 t! C& F4 P; j5 L* h2 D
pal->colors); * c# p" g+ d2 a; E
getch();
4 Q0 i& [) ~6 T8 s+ F0 n4 e1 [} </FONT></P> o4 K; u; x9 |7 H7 k* N
<P><FONT color=#0000ff>/* clean up */ # _! g1 U/ h! j9 {
getch();
9 C* T- @. g2 l" Aclosegraph();
, s9 _9 M" R* W# x, W3 greturn 0; : v8 P$ \& ?/ z& Y+ ?
}
5 U6 I5 m4 F9 G& J5 i, g</FONT>
: r- p2 y o) }9 _8 U! w</P>
$ O/ P5 {" c( B9 F<P><FONT color=#ff0000>函数名: getdisk </FONT># W& Y4 V2 m7 ^' W
功 能: 取当前磁盘驱动器号 ( R" R6 U T$ p g
用 法: int getdisk(void);
" R7 Y5 r; ?5 U7 Z程序例: </P># j `+ Y. c( _2 G
<P><FONT color=#0000ff>#include <STDIO.H>/ R; g" n3 t X- d
#include <DIR.H></FONT></P>
0 i3 h- x R! G0 ^! A) [. C0 Q* f# B<P><FONT color=#0000ff>int main(void) , ]8 L5 d* c7 y( @0 I3 F
{
# x2 W) v, b/ c7 ^* ^1 uint disk; </FONT></P>! Y$ S4 R$ X- k+ b
<P><FONT color=#0000ff>disk = getdisk() + 'A'; ; ~4 O! L6 {9 i0 j7 {3 W, z) P+ S
printf("The current drive is: %c\n",
' C% \5 s& x7 @4 Z2 Edisk); % o0 w$ I/ z/ J' j+ n
return 0;
- q3 H( ^$ P# r$ \) \7 d) {$ S) a} * Y3 x' f. ?, N5 C+ g/ ~
5 b, j, B' w) X: E$ a, J</FONT>
k; G5 q) A$ r" _9 m8 [</P>5 c4 y0 X4 C2 }6 ^
<P><FONT color=#ff0000>函数名: getdrivername </FONT>& v J' r4 d+ R! V, `; i) h% Y3 M
功 能: 返回指向包含当前图形驱动程序名字的字符串指针
+ e) r5 E! X$ K) w. C4 z/ a用 法: char *getdrivename(void);
) W" V* _( b/ E3 F4 q7 s程序例: </P>
8 a2 y/ H0 [0 P9 k<P><FONT color=#0000ff>#include <GRAPHICS.H>% z" q _. @, u8 }& w
#include <STDLIB.H>
' r4 @. `9 H2 H+ n$ n#include <STDIO.H>
2 X) j* T. x" j* m" s7 l#include <CONIO.H></FONT></P>* r! d4 [5 Q6 g3 u& y2 @
<P><FONT color=#0000ff>int main(void)
$ s# \; ?6 g1 w1 L/ W{
9 {: A4 G9 V4 W) C/* request auto detection */
% e7 ^* X- X7 e1 R( _) z, q0 t/ M9 k: Yint gdriver = DETECT, gmode, errorcode; </FONT></P>. D! {5 S9 J6 `; ]0 p2 ?
<P><FONT color=#0000ff>/* stores the device driver name */ ' H4 X7 l' F2 F, X7 W1 N3 z: C
char *drivername; </FONT></P>- @* _! i) r8 m. d- t2 A: {
<P><FONT color=#0000ff>/* initialize graphics and local variables */ ! Y3 V5 S' z" ?" _# g& f
initgraph(&gdriver, &gmode, ""); </FONT></P>
& s* t1 N8 T. {" e<P><FONT color=#0000ff>/* read result of initialization */ * l' C1 S$ _# X+ i2 H5 t
errorcode = graphresult(); & y' k- h! y. Z! K8 H
/* an error occurred */ 9 X5 }! k r7 P1 v
if (errorcode != grOk) ( D/ T8 k; d3 `! A
{
7 y$ e# W* T* [: g/ Nprintf("Graphics error: %s\n",
5 ?: m+ _% u( `- P" rgrapherrormsg(errorcode)); ) u4 V: O( G& ^7 B) e/ [" I
printf("Press any key to halt:");
1 k1 m2 H& W0 t ngetch();
& y5 x; F. e# i2 e$ o' N/* terminate with an error code */
9 x& l! q! ?: n7 l& }% dexit(1); ( e7 G% [# `& k9 o; l6 [$ l* L! w
} </FONT></P>
0 |+ J/ |/ B! b+ v3 S<P><FONT color=#0000ff>setcolor(getmaxcolor()); </FONT></P>
8 _' Q) [" E+ s3 ?7 a9 {5 u' X<P><FONT color=#0000ff>/* get name of the device driver in use */
% q u/ G6 |5 [; ~4 p- y5 d6 [drivername = getdrivername(); </FONT></P>
* I3 p3 p. h. T( B8 s6 g5 C<P><FONT color=#0000ff>/* for centering text on the screen */ ; D7 D7 x: c6 }8 F! n: c
settextjustify(CENTER_TEXT, CENTER_TEXT); </FONT></P>1 s5 s" J6 e V; S& c
<P><FONT color=#0000ff>/* output the name of the driver */
- Y, M$ v, j+ C* o; X8 Youttextxy(getmaxx() / 2, getmaxy() / 2, ) Q l) z. P/ a9 x( h4 r9 p
drivername); </FONT></P>2 [6 B/ u# C- ~
<P><FONT color=#0000ff>/* clean up */ 4 q" b! C/ y0 A1 i& Q- }
getch(); 8 t9 `: I" U4 p7 i% }: |
closegraph(); $ k( s/ v" Y. p9 o
return 0;
2 D; G( S! U& S! c( \}
# h3 V! z7 f- c4 i</FONT><FONT color=#990000>
H4 R% G0 r8 k</FONT></P>
8 y7 `0 e! I6 N. |# y' K* Q<P><FONT color=#ff0000>函数名: getdta </FONT><FONT color=#990000>
& H0 K+ g; y3 w/ ~( r: k; k" {" J: K<FONT color=#000000>功 能: 取磁盘传输地址 & B6 e4 Z/ v. H9 o* `
用 法: char far *getdta(void); 3 V# C) m. G5 ~7 f
程序例: </FONT></FONT></P>
& L* \" T3 |# g% l {, S<P><FONT color=#0000ff>#include <DOS.H>' \. }% g( a( i- i+ v$ w1 `& ~$ s
#include <STDIO.H></FONT></P>8 P' g# K" h+ S- _. R) @) x
<P><FONT color=#0000ff>int main(void)
6 q9 i; P. M' r) \1 C# ?: a{ , Q5 N' z% r! F2 H2 B
char far *dta; </FONT></P>
& z" @2 P6 v" M* i# o2 p<P><FONT color=#0000ff>dta = getdta();
! c. l% i8 I c- u$ W: p3 w1 iprintf("The current disk transfer \
4 l% Y, ]5 _( E# w% u& Yaddress is: %Fp\n", dta); + i6 v5 U7 O0 \9 k( z) y# o$ o
return 0;
& S( v' h& G& F k; e# V} , r1 \1 E0 W/ r3 d
</FONT><FONT color=#990000>% b' M9 H1 o$ Q/ z% C5 P, l- c5 r
</FONT></P>* e2 a, Q% k+ r
<P><FONT color=#ff0000>函数名: getenv </FONT><FONT color=#990000>: i! u9 h' x; Y- m6 Y5 ~
<FONT color=#000000>功 能: 从环境中取字符串 " U5 b8 ~! p9 X. \7 b' ^) m: P
用 法: char *getenv(char *envvar); : S9 S9 d4 f. l
程序例: </FONT></FONT></P>
, x8 L Q& n: R" |<P><FONT color=#0000ff>#include <STDLIB.H>
/ h# b) `6 H9 T% d+ b: L& x% W#include <STDIO.H>* r! [5 s7 W7 ~: {& j
</FONT></P>: g, f9 k$ o) A4 a, g% N$ s; S
<P><FONT color=#0000ff>int main(void) ! f4 k; U9 t# `4 A( Q0 l* l" F
{
! ~+ p5 V7 m0 ?3 Y$ v% n1 F( dchar *s; </FONT></P>6 M# _) G$ h# @/ D/ X
<P><FONT color=#0000ff>s=getenv("COMSPEC"); /* get the comspec environment parameter */
9 Z. l S" T% Z. Bprintf("Command processor: %s\n",s); /* display comspec parameter */ </FONT></P>
" e- }2 Z0 D% H<P><FONT color=#0000ff>return 0;
- B5 U* r; M& {+ n% O} </FONT><FONT color=#990000>$ {+ r# z9 M% x" w* s3 K! z
9 Z$ o6 X' N) e" T8 _. F( k
! _% x! a$ B6 I1 Y
</FONT></P>
2 g. F3 m+ C& y; V+ g( ]: q<P><FONT color=#ff0000>函数名: getfat, getfatd </FONT>
8 x9 k: g3 ]+ x: Z" C功 能: 取文件分配表信息
, b9 S9 a8 j# e( e& p用 法: void getfat(int drive, struct fatinfo *fatblkp);
4 {3 q0 q% L I: P程序例: </P>: @9 } b, T! ~$ I5 ~8 @* Z( e
<P><FONT color=#0000ff>#include <STDIO.H>
4 _6 k9 d. d# R& {8 L& x#include <DOS.H></FONT></P>/ v- r8 f6 o0 Y3 u
<P><FONT color=#0000ff>int main(void) ( o, X' F2 G& N9 [
{
% ~, M1 {9 T7 ystruct fatinfo diskinfo;
) X! J& v3 q7 l$ T. ~4 m( F# Cint flag = 0; </FONT></P>
; C: L# t, B9 Z( x% c+ e<P><FONT color=#0000ff>printf("Please insert disk in drive A\n");
: u6 l/ x, H; M1 ?2 K8 dgetchar(); </FONT></P>
5 T* Q9 P5 G* r: F8 I6 X<P><FONT color=#0000ff>getfat(1, &diskinfo);
/ t" f0 W8 F! d/* get drive information */ </FONT></P>! Y7 a" }" g% q+ A W/ X% {
<P><FONT color=#0000ff>printf("\nDrive A: is "); ' g! a" S: N& O, D M0 v
switch((unsigned char) diskinfo.fi_fatid) + i- \5 X; ~4 n6 S8 T
{ # A* O' {9 r) D; g: g2 E! ?
case 0xFD: & D; a0 a* U, b, }
printf("360K low density\n");
. z3 \( C* S- o. {' H1 o6 z) rbreak; </FONT></P>
- X/ X+ v) G+ w# B; p/ i% t<P><FONT color=#0000ff>case 0xF9: 8 Z" i! _% z- \' w! n' k
printf("1.2 Meg high density\n");
9 O6 B8 v) u6 F$ a5 K, l8 A8 a/ F# vbreak; </FONT></P>, ?" y4 p1 h9 M- A8 m, y
<P><FONT color=#0000ff>default: ( J% C9 k1 j% Y0 H
printf("unformatted\n"); 6 \, T' D6 @% M" Y9 H
flag = 1;
4 l% s3 Q' Q( g# g6 S. E1 X} </FONT></P>& _; W* r7 R6 C- E1 o8 j
<P><FONT color=#0000ff>if (!flag) + f/ X% n) ]6 h$ S; u
{ 8 I$ q8 n( Z- R6 ^
printf(" sectors per cluster %5d\n",
! O$ `: e! k4 u. V1 b% ], Mdiskinfo.fi_sclus); ; B9 W* W' H3 d/ M8 t4 V R: P
printf(" number of clusters %5d\n",
3 d7 @) u$ m: f# gdiskinfo.fi_nclus); . N V- l+ @" o3 ]2 W
printf(" bytes per sector %5d\n",
' d; P0 D v a7 ydiskinfo.fi_bysec);
% H. j# w1 _+ E- M0 e} </FONT></P>
7 @& A/ u) j2 Z" q<P><FONT color=#0000ff>return 0;
4 _/ @8 i- j9 N}
5 r2 \) g! a# t3 ?4 M0 l$ a' W</FONT>7 i: T" |9 W# j! j( k/ z$ [
</P>
% l% c+ {4 P8 y- ?9 Y<P><FONT color=#ff0000>函数名: getfillpattern </FONT>& W2 _! o6 q( g3 V) O8 H$ y
功 能: 将用户定义的填充模式拷贝到内存中
" E5 {8 U. L: ^9 A* k% I( z! T用 法: void far getfillpattern(char far *upattern);
( U% C- x3 o/ k4 {; G程序例: </P>& O" g2 g& m3 y3 P- i a
<P><FONT color=#0000ff>#include <GRAPHICS.H>' N' C# D6 ~% g3 i! _, w1 y- p
#include <STDLIB.H>
- `7 U6 W* c8 M#include <STDIO.H>
2 d! n8 _% T2 ?0 O9 D* _# P; h% H#include <CONIO.H></FONT></P>6 X( M$ y9 S7 S2 I: P
<P><FONT color=#0000ff>int main(void) ( t, m& x$ n. ~
{ ' s8 R8 X; A4 x7 _1 r9 E
/* request auto detection */ 6 W; O6 D& E* k, I C! n$ B
int gdriver = DETECT, gmode, errorcode; : l) m n+ \, J* V6 [' J: u
int maxx, maxy;
3 s* |5 [7 {# G2 z6 N( Q2 _4 Z9 |char pattern[8] = {0x00, 0x70, 0x20, 0x27, 0x25, 0x27, 0x04, 0x04}; </FONT></P>
( w7 q3 K$ P$ ~' D, \. O. w/ d, X<P><FONT color=#0000ff>/* initialize graphics and local variables */ & m6 Q! p& g, L& e; S
initgraph(&gdriver, &gmode, ""); </FONT></P>2 S, z. b: X v, C
<P><FONT color=#0000ff>/* read result of initialization */
$ _" r" w( u* a8 V4 o' f# yerrorcode = graphresult(); 0 S/ b7 y1 T9 v c& j) r
if (errorcode != grOk) /* an error occurred */
. J3 P ]6 ?( y" r# M0 B9 _{ 8 X6 F! o( k- n3 S! ]. s
printf("Graphics error: %s\n", grapherrormsg(errorcode));
( T! P( s+ Q3 Y; V, X! T: dprintf("Press any key to halt:"); # Y4 L2 ]% q. |: { x2 H! ^% S$ [1 {& a8 h
getch();
: \5 ~: k! ?0 x0 _/ ?8 Yexit(1); /* terminate with an error code */
! ^2 y5 s$ E- T$ y/ d7 \} </FONT></P>' @8 v! X8 ~% o# ^) d5 A9 P
<P><FONT color=#0000ff>maxx = getmaxx(); 9 s, x% C+ {& V: X& C& K
maxy = getmaxy(); * X4 U ]2 s; y' H8 P
setcolor(getmaxcolor()); </FONT></P>
2 i; s8 o# j3 Z3 { v B% u<P><FONT color=#0000ff>/* select a user defined fill pattern */
+ M" M" d$ b8 Q' j# G* esetfillpattern(pattern, getmaxcolor()); </FONT></P>
8 J" R- ~+ L( `+ V7 g<P><FONT color=#0000ff>/* fill the screen with the pattern */ r1 j* J; D2 W! C
bar(0, 0, maxx, maxy); </FONT></P>" U% i6 ^! m1 ~% p
<P><FONT color=#0000ff>getch(); </FONT></P>+ L J* u/ E1 ?
<P><FONT color=#0000ff>/* get the current user defined fill pattern */
! f- ^* H0 o! o/ Egetfillpattern(pattern); </FONT></P>$ F0 }) P8 {, I# Z& g, {& O+ N
<P><FONT color=#0000ff>/* alter the pattern we grabbed */
$ c. m4 s& t. Tpattern[4] -= 1; 0 s3 a" [; ?& Z5 M M3 n
pattern[5] -= 3; / t3 }0 O9 f) C a) O" p
pattern[6] += 3; ; z: M# @. p: h
pattern[7] -= 4; </FONT></P>
1 ]3 u9 i# b4 x0 _# m- E: B* r<P><FONT color=#0000ff>/* select our new pattern */
, H2 r* I* Y, g- wsetfillpattern(pattern, getmaxcolor()); </FONT></P>" E" H& j' p# K! `/ T" E$ j3 {
<P><FONT color=#0000ff>/* fill the screen with the new pattern */ & s6 e/ M1 a# O
bar(0, 0, maxx, maxy); </FONT></P>1 G! n7 l( E% E8 n9 l& z
<P><FONT color=#0000ff>/* clean up */ ) x& x* q# r* R: ^, O4 v% s, d
getch();
$ M4 [6 K1 v; Nclosegraph();
+ G6 q" O) _! [0 u4 Y nreturn 0; ) E6 Y$ R8 n/ I& K9 H1 F
}
1 |7 ^+ x6 A+ F9 L7 E</FONT>
1 p6 O: e" e+ l1 c</P>
# c9 W- W* w( |4 ~3 |: |<P><FONT color=#ff0000>函数名: getfillsettings </FONT>
7 f0 h& \5 b- K( x' `& r6 Y功 能: 取得有关当前填充模式和填充颜色的信息
, o7 E5 x- R& I5 r2 W$ W用 法: void far getfillsettings(struct fillsettingstype far *fillinfo);
- A) {% |& h6 x- M程序例: </P>
8 {2 X6 e" }( d# `# ~<P><FONT color=#0000ff>#include <GRAPHICS.H>" \: K% b" p. H5 h( y- g5 }5 H7 _
#include <STDLIB.H>
" V# T; X7 D) T* {+ _; Q#include <STDIO.H>; v# h9 w) G" s
#include <CONIO.H></FONT></P>6 G' G3 d/ @- R- a5 w0 u3 S! x% y
<P><FONT color=#0000ff>/ the names of the fill styles supported */ % D' @( B b! e0 P4 b
char *fname[] = { "EMPTY_FILL", 0 Z0 Q8 ?# M- K; E% J
"SOLID_FILL", - B+ N; H" Y1 G+ R, Q
"LINE_FILL",
- @7 N% R" B" [. a: ~* H, }& o/ |"LTSLASH_FILL",
( g3 E4 \7 A- H"SLASH_FILL", : L& x' L( P1 m
"BKSLASH_FILL",
/ _3 ~" t6 w7 Q$ n* L! F5 o"LTBKSLASH_FILL",
. I4 }0 e7 b }"HATCH_FILL",
4 Y- A" }: a# x* p t# P"XHATCH_FILL",
# N' B% r& Y1 @"INTERLEAVE_FILL",
: W1 m3 Z+ D2 A8 j+ B# z"WIDE_DOT_FILL",
" I w4 |2 a, q# V"CLOSE_DOT_FILL",
# ]$ q6 P: f; a% q1 F"USER_FILL"
5 Y% u4 L( f( N+ v6 C2 _}; </FONT></P>
2 M5 T( G [$ v: ~7 x1 ^5 u1 o4 y3 p' h<P><FONT color=#0000ff>int main(void)
- V/ O3 d* L6 k( c/ Y6 y# O{ 7 i2 i; b; a6 W) Q9 o; g
/* request auto detection */ + v Q9 a# n# L" G. t
int gdriver = DETECT, gmode, errorcode;
% w' x" ?; K% ]9 Rstruct fillsettingstype fillinfo; 8 l- [* H) A3 l, L4 L# U& R5 z
int midx, midy;
) }2 }" Z$ y6 I2 A" ` Dchar patstr[40], colstr[40]; </FONT></P>- Y: \ k2 I5 k0 X
<P><FONT color=#0000ff>/* initialize graphics and local variables */
' Q; i$ K7 u1 f6 A2 V6 ?initgraph(&gdriver, &gmode, ""); </FONT></P>& I# {* c6 m$ H1 z8 \8 v
<P><FONT color=#0000ff>/* read result of initialization */
3 G1 y6 L' v/ U5 A1 T$ terrorcode = graphresult(); # h% F" A0 Y9 v) x. y
if (errorcode != grOk) /* an error occurred */
}6 }) U( k! {+ P" ~+ B! z{ 5 Q* X m! A K/ z0 f& @. \
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 1 Z7 o+ u W' m+ g. E- P( @
printf("Press any key to halt:"); 1 z# O9 \3 f) p: d
getch();
# Z3 c& @/ c7 M* K- I/ s- g! v5 v7 Eexit(1); /* terminate with an error code */ 5 I: \, L4 o- t* ^5 {% V5 l/ J) ~
} </FONT></P>" d7 n, _0 u1 T" P3 Q
<P><FONT color=#0000ff>midx = getmaxx() / 2; : [1 R L5 e, ~% c
midy = getmaxy() / 2; </FONT></P>, K$ _) L9 b3 ~9 ~ U
<P><FONT color=#0000ff>/* get information about current fill pattern and color */ - f0 l L' n2 y
getfillsettings(&fillinfo); </FONT></P>
+ u* A$ Z- E/ {+ P- C# m7 J<P><FONT color=#0000ff>/* convert fill information into strings */ ! f9 K9 k3 ?; k1 Y6 c
sprintf(patstr, "%s is the fill style.", fname[fillinfo.pattern]); . q2 E9 F4 F% x) q& F; {' t" |
sprintf(colstr, "%d is the fill color.", fillinfo.color); </FONT></P>
, q0 f+ F7 w" k! W- E4 ?9 v<P><FONT color=#0000ff>/* display the information */
# j! _( H- ^" r# R2 x- y _settextjustify(CENTER_TEXT, CENTER_TEXT);
" @- w+ h' {$ g# Douttextxy(midx, midy, patstr); 4 g; j0 `, \, f0 P
outtextxy(midx, midy+2*textheight("W"), colstr); </FONT></P>
; ]% V2 K$ p- l" Z. p/ t9 r<P><FONT color=#0000ff>/* clean up */ ( b/ i. r) E% ?& o. n
getch(); 8 t: w2 g+ X( B" e- h
closegraph(); ' P! X T$ y* v$ _; B$ ^& Y; }
return 0;
3 [9 y3 I; y- X, g# _} 6 M% H: N! O" z; a$ S$ J! ?
</FONT>
$ y U: r; R( O
# q* s$ ]( M: h# e</P>! V2 U% v9 Z7 r5 R( \( \5 ]
<P><FONT color=#ff0000>函数名: getftime </FONT>& b1 W( J: P, @* [. n: T
功 能: 取文件日期和时间 ( V0 v( a) [( d- `
用 法: int getftime(int handle, struct ftime *ftimep); ( R# M2 F3 [/ g4 c. y# K8 U
程序例: </P>$ ^8 }0 {# S* O( D" w4 E) d
<P><FONT color=#0000ff>#include <STDIO.H>
" l: N! G* q! W0 [( l2 I#include <IO.H></FONT></P>2 r! Y" B6 E& U) F9 q1 u( ~
<P><FONT color=#0000ff>int main(void)
5 p1 |2 i6 o6 f6 M' ~& Z& G{
0 q. b }8 ]( X- n/ K9 r- D* i% J& |FILE *stream;
; f: D6 A: \( C( z+ q0 g5 S Zstruct ftime ft; </FONT></P>
1 P+ p7 T# U5 M<P><FONT color=#0000ff>if ((stream = fopen("TEST.$$$",
3 @) [6 i+ m9 y"wt")) == NULL)
) p* @- ]6 h& r3 Y$ r{ / q% y. b, v/ l
fprintf(stderr, 8 i2 h' s2 x# d' k1 K; ~6 q4 z
"Cannot open output file.\n");
1 T0 v8 X/ |6 dreturn 1;
3 S' w; I$ q. c% u}
, ]6 h' M' v( }" qgetftime(fileno(stream), &ft); - z8 s' b0 u$ q
printf("File time: %u:%u:%u\n", 3 A) _, j8 _7 }) R2 d3 L+ j
ft.ft_hour, ft.ft_min,
; J4 J* G6 |: Aft.ft_tsec * 2); 5 m1 M8 j0 _! H
printf("File date: %u/%u/%u\n",
. y0 t, o7 |- i( ~" P: Lft.ft_month, ft.ft_day, - c' ^- @6 ^6 B) w% M
ft.ft_year+1980);
+ ?" I! Y7 M0 Xfclose(stream); * X7 B) F+ C" {$ K8 J5 _' K
return 0;
% K; n+ C m+ G9 D2 k6 [( B+ v! U} 6 g: E' W7 N; X) Z8 E. _7 J
</FONT>0 w3 }" Y7 N" y# f; P# Q8 f
* R5 v& c5 p5 q3 X; ?
</P>. |% r) X; p9 H6 h5 s+ T
<P><FONT color=#ff0000>函数名: getgraphmode </FONT>! b' {& \1 Y3 [/ t
功 能: 返回当前图形模式
* t' E+ J" s. M2 p8 W n用 法: int far getgraphmode(void); ) h! A3 v# `9 m& l. `
程序例: </P>
: Q7 @/ X ?5 [5 b' J9 D$ K<P><FONT color=#0000ff>#include <GRAPHICS.H>
) y- ~# d/ @1 v#include <STDLIB.H>
) A( D* L7 o e1 H#include <STDIO.H>
& p% s' { T# F& b" i2 d#include <CONIO.H></FONT></P>
0 @! x1 u% e" F7 I7 o* C. y<P><FONT color=#0000ff>int main(void)
8 o6 G" A# H4 p \/ c* h{ 5 x" Y0 X( ]* T/ y0 m4 ?
/* request auto detection */
% A6 n' R' G4 O) l" K( Zint gdriver = DETECT, gmode, errorcode;
N+ {- G, R# L M% o$ i$ g2 L8 dint midx, midy, mode;
5 O, r+ a! q2 l& d: P! O% Mchar numname[80], modename[80]; </FONT></P>' h! n. q- x! |& g2 V
<P><FONT color=#0000ff>/* initialize graphics and local variables */ 1 N% H. Z* Q s) ?, y6 a
initgraph(&gdriver, &gmode, ""); </FONT></P>; h. c6 ~$ K3 ~/ X
<P><FONT color=#0000ff>/* read result of initialization */
" u% L6 z+ C/ C! G9 c" E+ j. Rerrorcode = graphresult();
; K3 A& Q: \0 E8 a2 g9 Q6 z/* an error occurred */ 4 {! T, n3 i" M. J8 d/ A) K6 Z" I! g
if (errorcode != grOk)
* c+ d5 ^4 U: v9 I8 e{ : L' ], j' [, P6 T& {7 Y
printf("Graphics error: %s\n", & z! D/ A+ A- T+ f) a6 R8 I
grapherrormsg(errorcode)); & [: g7 a* [& t# l5 Y, m
printf("Press any key to halt:"); 1 Z! M/ b _0 n; a! I6 h# Q
getch(); 3 w9 _1 z, I: P1 j1 }0 i: e9 B* [9 n. X
/* terminate with an error code */
# L3 x. h( B9 b. m( P& `exit(1);
5 z4 U4 O& |0 K- n B8 Y} </FONT></P>) O. A' V1 e6 _6 k7 q9 o8 |: d; ~
<P><FONT color=#0000ff>midx = getmaxx() / 2; ' `- {3 V# i) _6 |4 m4 c, m
midy = getmaxy() / 2; </FONT></P>: Z6 u/ J: F2 _) p; ~, m2 |
<P><FONT color=#0000ff>/* get mode number and name strings */ * m- E2 v* [& H+ [
mode = getgraphmode(); # K& X$ S1 U. x3 S2 q2 Q
sprintf(numname, ( g6 u9 H" e; w( m
"%d is the current mode number.", ( n" A% Y. Q/ X; k- y
mode); 3 G* {0 x$ w: `# K
sprintf(modename, 1 N P7 }3 M) l" j, L
"%s is the current graphics mode", 0 `- l# l6 A+ R0 l+ T# B
getmodename(mode)); </FONT></P>0 l7 h4 U0 O' }* I& |( G
<P><FONT color=#0000ff>/* display the information */
: m+ a% x$ K# Y3 v( J2 @* ~settextjustify(CENTER_TEXT, CENTER_TEXT); 8 u! C, @7 R' P- w1 J( C
outtextxy(midx, midy, numname); 4 x! r3 }" B8 v! [2 j
outtextxy(midx, midy+2*textheight("W"), ' g( Y p' V" r) O2 k4 ^
modename); </FONT></P>" G: s3 g* L5 o, X* B4 `9 H" Z
<P><FONT color=#0000ff>/* clean up */ 0 {9 f* y- V- I
getch();
9 H3 }8 X, e+ l: wclosegraph();
0 a) Z H* Z+ l- P& Nreturn 0;
( c6 }# |6 n4 ~5 |5 f} </FONT>, w( K! V7 G5 A& z
' ~2 Z2 `8 J$ u; D6 @ `/ F
</P>, N. Q' \5 r& j+ N7 A4 @" J
<P><FONT color=#ff0000>函数名: getftime </FONT>
4 I) E, o1 N6 J5 z3 H功 能: 取文件日期和时间
! d3 ~5 D3 @3 V% H1 U4 V用 法: int getftime(int handle, struct ftime *ftimep);
! Y4 u: [) Z' e1 ?程序例: </P>7 Z" k* e' `* r7 H5 l& p$ U4 y
<P><FONT color=#0000ff>#include <STDIO.H>
% Y6 o+ p, a) T$ o2 u+ k9 J#include <IO.H></FONT></P>5 ~4 }" H/ @* {) y! I" L$ X
<P><FONT color=#0000ff>int main(void)
( b5 _0 L9 x0 j2 a$ ?{ " P2 F: [# W! P4 w' G" F) k3 `
FILE *stream; - @& \7 S7 Q0 o+ b
struct ftime ft; </FONT></P>
5 k5 Z, G ^9 _5 Z- X8 T5 W<P><FONT color=#0000ff>if ((stream = fopen("TEST.$$$", ; @! n7 g( t6 Z
"wt")) == NULL)
/ W$ n5 e7 A0 C$ k! \) {7 m{ 3 ], g, K7 H# }6 r" y3 W( Q- |
fprintf(stderr,
3 D3 w5 [3 t/ @& a0 L q: j* j"Cannot open output file.\n"); ) I/ C" U& e) O% ? K6 T; F5 p* L9 ]5 P
return 1;
3 [+ v7 h$ W2 ~1 E2 I}
0 m- ^0 i7 s& q9 Ugetftime(fileno(stream), &ft);
% Q+ l3 n# z4 n3 N9 fprintf("File time: %u:%u:%u\n",
+ o# }! @& |0 \% S _ft.ft_hour, ft.ft_min,
( l( q/ X- Z8 h) S" F. jft.ft_tsec * 2);
, X3 q; d: e- B- E# E4 S8 zprintf("File date: %u/%u/%u\n",
' t4 C- Z- m9 P* k# ^ Mft.ft_month, ft.ft_day, 8 |. U* r4 x' ^, [9 m3 d
ft.ft_year+1980);
; U3 r5 g8 c5 [+ [2 Yfclose(stream);
9 P l) A1 W+ n/ w( U1 ?9 Dreturn 0; 4 \$ L1 S% x2 c# [7 p4 `+ J
} </FONT>7 _% w/ b, S i ?' ^: f# }9 }
6 z9 L; V) L. E' b/ j
9 s8 f, [3 g- F& _& l0 q" G</P>0 m& E" f7 I' j
<P><FONT color=#ff0000>函数名: getgraphmode </FONT>7 i5 O& d% C) [; K, m
功 能: 返回当前图形模式
2 u+ F0 e2 G: _- u9 B$ a用 法: int far getgraphmode(void);
" Q/ |0 s0 \. Z/ G- @, d程序例: </P>
. [8 T9 Y: Y& t% ?7 @, {* O<P><FONT color=#0000ff>#include <GRAPHICS.H>6 I8 X. r" O& Z0 l% q! _ r
#include <STDLIB.H>3 B, C+ T: M7 l; m" S, z+ e
#include <STDIO.H>
2 f5 @: C; J1 U+ f K#include <CONIO.H></FONT></P>( `! I& a8 _" y% |( P: [
<P><FONT color=#0000ff>int main(void)
* x( p$ _& p8 @; M# x4 ?# g{ . G a" P S% r
/* request auto detection */ 2 m5 |# U* D7 S @% T% O* Q9 C
int gdriver = DETECT, gmode, errorcode; 0 i4 \6 G( k8 m3 T, c
int midx, midy, mode;
9 d- P& X, {9 h U4 O* [) kchar numname[80], modename[80]; </FONT></P>
3 [" b7 V' g8 ~: V8 o<P><FONT color=#0000ff>/* initialize graphics and local variables */ % Q# m2 u' s# \: X$ J% T
initgraph(&gdriver, &gmode, ""); </FONT></P>8 _4 e$ c$ I/ q5 p! Y+ G
<P><FONT color=#0000ff>/* read result of initialization */ 2 z! K7 m% C9 ?3 ~
errorcode = graphresult(); 5 O( [4 k% P9 {& Z, V/ A
/* an error occurred */
/ `: S Z# x' cif (errorcode != grOk)
3 L+ A8 D! }* O5 c{
0 B, j0 [' p- Z: Hprintf("Graphics error: %s\n",
- L' D4 q8 h9 `! Ographerrormsg(errorcode));
) g/ @5 _: ~; Z/ O7 i% Z# Pprintf("Press any key to halt:");
: \: \9 I! [% S* k7 O Igetch(); & y" Z3 {4 o: R$ g. R0 w/ e1 J
/* terminate with an error code */
, ]/ w% M f+ ?% W9 t) k9 ?& @exit(1);
8 y: @5 U" x0 f0 |3 o1 S7 a- i# p s. }4 \} </FONT></P>. [0 F8 q: d5 s$ {) ^' _" I& e( Y
<P><FONT color=#0000ff>midx = getmaxx() / 2;
: [ l& O' T5 d# Z: L% \9 q2 h# fmidy = getmaxy() / 2; </FONT></P>$ |( Z T- ~7 u6 q; g
<P><FONT color=#0000ff>/* get mode number and name strings */ + u! f0 ~- e q% S
mode = getgraphmode();
8 W+ I* Y5 f" q5 `7 B3 gsprintf(numname, , S* x/ j$ Z: v/ L
"%d is the current mode number.",
$ F0 Z$ ]# w( m5 J1 @mode); + |4 B; s6 u2 Z; @1 o! b
sprintf(modename, ) m# x5 _8 L6 ~: X4 q1 `
"%s is the current graphics mode", , q/ M3 j" C1 T( h! v
getmodename(mode)); </FONT></P># v# a) J* G) w% x) \ e- E, b/ X% |
<P><FONT color=#0000ff>/* display the information */ & V- \& O' h0 H9 r
settextjustify(CENTER_TEXT, CENTER_TEXT);
; B3 j% F- y% y; y! Nouttextxy(midx, midy, numname);
5 Y% B A: J7 ^outtextxy(midx, midy+2*textheight("W"),
* }; c: O% V6 x) e; B0 A: W3 Zmodename); </FONT></P>& z4 j3 l9 s5 z) ?$ v% ]- g
<P><FONT color=#0000ff>/* clean up */
2 t4 g0 e3 o5 T0 n3 ygetch(); / X& [0 Y7 g7 G, s; C
closegraph();
' U- G4 S$ S# L" R: c9 b6 V+ u8 v- F8 Jreturn 0; ( P4 P4 I, J. ?. }& O
} 7 a r: D' C+ S. \
</FONT>
# a2 ~2 n# ^, V2 m& `</P># a$ p. k1 O0 n n0 Z
<P><FONT color=#ff0000>函数名: getimage </FONT>3 ~/ j, D. o8 C8 N/ l- ^
功 能: 将指定区域的一个位图存到主存中 7 h4 V$ p$ n/ \$ U7 N
用 法: void far getimage(int left, int top, int right, int bottom,
1 ~8 l7 }" ^; A2 B! wvoid far *bitmap); 2 t- @; b! c# J4 z
程序例: </P>' @' \: u) D, O4 A9 f
<P><FONT color=#0000ff>#include <GRAPHICS.H> @1 s1 u: X& ~1 u' v
#include <STDLIB.H>
, t2 O' X$ t8 E+ @#include <STDIO.H>7 a9 ?/ e8 B# G# _ [$ N
#include <CONIO.H>
0 q9 k9 e& H5 [#include <ALLOC.H></FONT></P>! Y* a |4 \5 B' }7 p# B
<P><FONT color=#0000ff>void save_screen(void far *buf[4]);
: M* @3 v* X6 U0 q. m9 V8 p: o7 ^/ Bvoid restore_screen(void far *buf[4]); </FONT></P>
( O a( i) f ]- A0 m<P><FONT color=#0000ff>int maxx, maxy; </FONT></P>
Y4 A) R% G, l2 A<P><FONT color=#0000ff>int main(void) ! I# o8 j9 Q$ }9 e. Y) ^* H7 ^! R
{ 3 a8 c+ e0 l$ ]: w$ G
int gdriver=DETECT, gmode, errorcode; # x0 P! Y* D8 S7 l6 k r, P R0 Z% {
void far *ptr[4]; </FONT></P>2 R* b, j" B- R
<P><FONT color=#0000ff>/* auto-detect the graphics driver and mode */
+ a) i$ x. }* i: D, Pinitgraph(&gdriver, &gmode, ""); - D1 X4 P6 ~: E, e# \
errorcode = graphresult(); /* check for any errors */ " l0 g' ?* I4 Y! i
if (errorcode != grOk) 6 \: `- i# |5 b6 G5 V+ t$ W
{
9 ^9 j4 l3 d0 y# h) F2 qprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 8 I) X" t1 }% ~" I; G
printf("Press any key to halt:");
9 j- e ~5 x) U) G" Z8 q- Igetch();
0 Y! u0 X5 {8 ]8 Oexit(1); $ Y( S5 S9 k w, `! x0 c0 i6 H
}
' S. z( p( h) i9 T; u3 y4 Nmaxx = getmaxx();
2 P) g( w6 q" [$ d6 ^# \; kmaxy = getmaxy(); </FONT></P>2 B9 g- {: A8 X3 Q
<P><FONT color=#0000ff>/* draw an image on the screen */
" P& m( j4 X* n v( Brectangle(0, 0, maxx, maxy); 5 i) Y% t- N1 `* p& K9 z0 ?/ B
line(0, 0, maxx, maxy); 5 w+ D* g) V6 ~, s/ d+ K( s
line(0, maxy, maxx, 0); </FONT></P>
+ {) F2 Z3 K5 G8 L7 @; O& v<P><FONT color=#0000ff>save_screen(ptr); /* save the current screen */ / `' y( K; e2 L+ N& a( J5 g% D ~- U5 W
getch(); /* pause screen */
9 t% o1 a: e! {; u+ F m0 qcleardevice(); /* clear screen */
2 }1 {2 m$ M/ ?9 a3 N4 |! Y prestore_screen(ptr); /* restore the screen */ ) B2 ^4 d+ H( O5 u( w. i
getch(); /* pause screen */ </FONT></P>
( A- J% Q5 U8 m) m& \ A0 e* }& M5 I<P><FONT color=#0000ff>closegraph();
) E+ w) V+ [1 ^- rreturn 0;
+ ^3 f- n! j0 m} </FONT></P>
8 g+ o# L' b) t( y/ ]7 r t<P><FONT color=#0000ff>void save_screen(void far *buf[4])
/ q9 ^# i0 x( T) r a1 ]4 w) u{
3 Q% \" y& |7 S4 O( `unsigned size;
1 m' i, p' s2 T$ d: vint ystart=0, yend, yincr, block; </FONT></P>
" g8 y' Q( B4 J: J) s0 }$ @<P><FONT color=#0000ff>yincr = (maxy+1) / 4; : p# o2 j3 ?' L3 W; F5 ^
yend = yincr;
- b7 d$ C2 o! {) Csize = imagesize(0, ystart, maxx, yend); /* get byte size of image */ </FONT></P>
+ a+ j& N( s$ p) |# G j0 b<P><FONT color=#0000ff>for (block=0; block<=3; block++)
" R% v+ S/ `% [( X+ q9 @+ V{ 5 y8 ~+ u" |+ H4 S4 T
if ((buf[block] = farmalloc(size)) == NULL) 0 @+ w1 U3 x1 B/ R. m2 a: a& t( h; Z2 C
{
% P2 ~! K! q4 Eclosegraph();
8 _7 A, ?! p/ T$ ?5 H& ]printf("Error: not enough heap space in save_screen().\n"); , h3 f7 I; `& W. C/ S3 Z5 s) E7 _
exit(1);
& \7 d, O+ L7 ^( n} </FONT></P>7 G4 u6 Z+ Z- J5 h* H; a1 W
<P><FONT color=#0000ff>getimage(0, ystart, maxx, yend, buf[block]); ]- p$ n% \& _3 L
ystart = yend + 1;
3 ] w* m3 T& q4 _6 ?0 oyend += yincr + 1; 7 u( U% Z9 i+ W
}
" ^- h; \) H0 x} </FONT></P>
$ _& v$ t# C9 S# T; Q0 }3 @1 B<P><FONT color=#0000ff>void save_screen(void far *buf[4])
$ c( w( S# e) n7 r{
0 h% [/ q' N0 } d; C# ]unsigned size; / k; y% M2 a5 T! J% ^+ A
int ystart=0, yend, yincr, block; </FONT></P>
) \3 n* A1 u' Y' H; |<P><FONT color=#0000ff>yincr = (maxy+1) / 4; % J& Y0 o$ g2 F5 K9 C9 a2 S! x
yend = yincr;
6 r: K2 P# N5 P1 ?; T9 d- c7 [size = imagesize(0, ystart, maxx, yend); /* get byte size of image */ </FONT></P>' J4 R- q1 J/ Z; |& [! e4 D: @6 \
<P><FONT color=#0000ff>for (block=0; block<=3; block++)
1 ~& l6 n$ |7 Q# d' o8 g/ [{ / J1 v2 ~2 n. u, Y* u) r5 a
if ((buf[block] = farmalloc(size)) == NULL)
6 p6 O$ g! R$ G1 N' @* h" `' n7 x{ 1 t2 }. [2 r! K. c' S
closegraph(); & n1 ]0 M2 y4 y2 R
printf("Error: not enough heap space in save_screen().\n");
2 m- I# j- x' e" Dexit(1);
4 m# Y% _5 _6 j4 u0 _} </FONT></P>
- l) R4 _7 U/ k! V7 n<P><FONT color=#0000ff>getimage(0, ystart, maxx, yend, buf[block]); 9 |# k' q- v$ n5 F( d2 O
ystart = yend + 1; ( U1 `/ j# C4 E L( t u& {9 N% P
yend += yincr + 1;
7 O2 Y2 k, N8 C' f} , h% q# o/ W2 w3 q4 Q
} </FONT></P>% Q& K' Q4 r, l5 E
<P><FONT color=#0000ff>void restore_screen(void far *buf[4])
, ~, ]" d( f6 s# G- K* \! |{
1 R- w) E" I0 u+ Lint ystart=0, yend, yincr, block; </FONT></P>
3 b+ V& x4 I y% B1 M8 E# {<P><FONT color=#0000ff>yincr = (maxy+1) / 4; $ v3 J# A) B8 D
yend = yincr; </FONT></P>
5 Y6 b* v% `& u' L/ c<P><FONT color=#0000ff>for (block=0; block<=3; block++) % m F" `" k5 U( c, q/ \
{
( o& x7 u- z5 A+ m+ J, V& }putimage(0, ystart, buf[block], COPY_PUT);
' z* _- V) R! I7 K2 W+ F. qfarfree(buf[block]); + q5 I9 O2 v2 @4 S; n
ystart = yend + 1; ! X7 d0 y/ @ U/ @- j* o
yend += yincr + 1; # Q( f3 b% ~6 H4 c
} # H; [, W: C+ t
} </FONT>
, o3 ?- x: Y. G<FONT color=#ff0000>) M5 w# s& j& D* T" \
</FONT></P>9 O8 I4 b, \: X2 g1 ]
<P><FONT color=#ff0000>函数名: getlinesettings </FONT>
& M! Y9 L$ [$ X c功 能: 取当前线型、模式和宽度
- L+ B; G9 f! i. T+ J. F) B用 法: void far getlinesettings(struct linesettingstype far *lininfo): 5 F( E8 P% z4 y+ P
程序例: </P>
# o. V% J/ f& K: {/ {<P><FONT color=#0000ff>#include <GRAPHICS.H>
* d9 {8 t; K* l1 j9 b* F; o#include <STDLIB.H>
& |( ]* K% ~! H" E/ b#include <STDIO.H>+ h3 V7 f+ b O6 R1 P5 a5 g8 y
#include <CONIO.H></FONT></P>
" @5 D. k+ L' `9 r3 P; Q5 R) h<P><FONT color=#0000ff>/* the names of the line styles supported */
# s3 ~9 Q7 M2 W9 X- Z _' ychar *lname[] = { "SOLID_LINE", 8 y ^- m5 q) s+ M. w ?" Q3 q
"DOTTED_LINE",
. Y3 Z; D+ P% p: N) W0 j/ b8 U4 H"CENTER_LINE",
' N- ~! Q- e- T4 N3 g% x' p! K"DASHED_LINE",
) Q b! F( E4 S9 l"USERBIT_LINE" 1 ?" j4 @6 z* Z# M% f- y
}; </FONT></P>
5 C2 E' L3 t$ h0 ^; n6 L2 M<P><FONT color=#0000ff>int main(void)
$ O9 K( f% D0 z8 T* B2 u$ V{
1 [5 K) P7 @! a/* request auto detection */
; v2 B7 v2 q6 Bint gdriver = DETECT, gmode, errorcode;
4 K$ N0 F! f* h0 }; ~7 O% t# hstruct linesettingstype lineinfo;
' L& U! x; Q7 {( f) sint midx, midy;
- ]) ^7 A- B8 R$ L, ]! [ c: achar lstyle[80], lpattern[80], lwidth[80]; </FONT></P>
3 k; {$ R: G+ c/ C+ `% @' E<P><FONT color=#0000ff>/* initialize graphics and local variables */ ' k* l* y& r1 Y: _8 e; T2 ?3 Y
initgraph(&gdriver, &gmode, ""); </FONT></P>% s) }0 B; d* }4 n5 F& a
<P><FONT color=#0000ff>/* read result of initialization */
% F+ }% x2 j$ r4 ^# z" W6 Z" Z6 y0 Lerrorcode = graphresult(); * f8 r0 M& I; E4 S; W) I9 H/ B: `
if (errorcode != grOk) /* an error occurred */ ; {( Y W, `$ H$ C( D* | O: j
{
: z$ K( s! X3 ^4 ]. G$ yprintf("Graphics error: %s\n", grapherrormsg(errorcode)); & f' g$ j. k9 {6 \
printf("Press any key to halt:"); * e o# L% e" m& }7 w9 \$ y4 e8 }
getch(); ' X- p. `0 Y! m, Y
exit(1); /* terminate with an error code */ - l# O/ b0 s( n/ o
} </FONT></P> k2 y: u+ O. D' Y. G
<P><FONT color=#0000ff>midx = getmaxx() / 2; ' o* r( e3 }6 m3 l+ {; N6 p4 A
midy = getmaxy() / 2; </FONT></P>
. U* @/ V* g6 X; b, D4 B<P><FONT color=#0000ff>/* get information about current line settings */ : f' G- e$ C. u& O+ I+ ?7 F
getlinesettings(&lineinfo); </FONT></P>
U* I; J4 r( s4 ~8 F<P><FONT color=#0000ff>/* convert line information into strings */ # Q1 w) T) j! j
sprintf(lstyle, "%s is the line style.", 4 s. D3 N9 {( R
lname[lineinfo.linestyle]);
" x3 C4 i0 G1 E8 T" Zsprintf(lpattern, "0x%X is the user-defined line pattern.",
3 B" Y/ Z- b3 K: S7 ulineinfo.upattern);
0 P, k6 x! K* U Q2 Csprintf(lwidth, "%d is the line thickness.", - j( X; k2 j X
lineinfo.thickness); </FONT></P>
! C1 S: s! d2 |9 {# _. c) Y<P><FONT color=#0000ff>/* display the information */ : C5 {9 D& R9 p7 A1 U0 W6 w
settextjustify(CENTER_TEXT, CENTER_TEXT); ! ^+ r9 |+ T9 o( }' u T7 J1 J' E$ K
outtextxy(midx, midy, lstyle); 4 a9 K5 c3 U3 z6 x
outtextxy(midx, midy+2*textheight("W"), lpattern);
8 y @# ]+ B& O' \6 A; Louttextxy(midx, midy+4*textheight("W"), lwidth); </FONT></P>& ^# [1 R, `- N( Y: v& |& [
<P><FONT color=#0000ff>/* clean up */
2 V9 P! C, i5 Y: r8 Y( ?4 H5 jgetch(); # M8 ^1 \0 o0 _3 O
closegraph(); . h8 F1 r7 p7 {- k' \5 }7 f2 b
return 0; 3 `6 C. G4 J9 ~) o; d
} </FONT>7 u; [: H0 `+ t/ z: g) Y: s% c
! ?3 R1 a% P2 ^: P2 `+ W7 {
</P>
# k0 j! R, E) ?# B( r& G<P><FONT color=#ff0000>函数名: getmaxcolor </FONT>
7 K0 o" @8 x6 N/ o3 K功 能: 返回可以传给函数setcolor的最大颜色值 ! z2 f4 t- J+ E! h% t. A
用 法: int far getmaxcolor(void);
: ]* A9 L; `4 `2 \( G9 I程序例: </P>! `4 q0 A' O7 V8 Z; Y I- i) U: }
<P><FONT color=#0000ff>#include <GRAPHICS.H>) D/ p+ r4 q. }+ ]6 J" ~
#include <STDLIB.H>, S& T4 b0 g& V4 a \- B
#include <STDIO.H>$ Z" O7 N- l4 R; I, b; Q6 k% H
#include <CONIO.H></FONT></P>- R$ R# ~2 `! K- R! {, z0 z( s, \! E
<P><FONT color=#0000ff>int main(void) 1 R9 s3 w; Q9 d: j* L2 y
{ _: W% |' L. v5 k5 _% P
/* request auto detection */
. l8 \ W* z' x9 x" U, N( wint gdriver = DETECT, gmode, errorcode;
I$ I$ {! k* m* x7 N2 Q" Eint midx, midy; 3 A6 _* s& f* O
char colstr[80]; </FONT></P>0 _' D. l7 T% d
<P><FONT color=#0000ff>/* initialize graphics and local variables ) G" w7 ~* G3 O& K
*/ initgraph(&gdriver, &gmode, ""); </FONT></P>1 D2 [7 ~" z0 i7 R" S- l
<P><FONT color=#0000ff>/* read result of initialization */ 3 z2 z) M7 B A7 s
errorcode = graphresult(); * F' z0 W0 V/ y+ Q d" L
if (errorcode != grOk) /* an error occurred */
" l. E. j( b8 o& E+ ]8 J2 c{ + Z$ r# U6 I1 W
printf("Graphics error: %s\n", grapherrormsg(errorcode));
( B( A) l, F- Q) qprintf("Press any key to halt:"); 2 n# J% o* _0 b$ a; j
getch(); 3 U9 A; e& t; o, W* L6 v) d
exit(1); /* terminate with an error code */ . a& S0 F, u( ], Z& J% N5 k
} </FONT></P>
& }. M1 E) I4 v<P><FONT color=#0000ff>midx = getmaxx() / 2;
$ q3 E& P8 ~/ M& A! Y3 V$ m( cmidy = getmaxy() / 2; </FONT></P>
) V; m1 P# @+ x) {<P><FONT color=#0000ff>/* grab the color info. and convert it to a string */
w+ `. ]$ ?( g4 ?0 J% d( f0 Dsprintf(colstr, "This mode supports colors 0..%d", getmaxcolor()); </FONT></P>) }/ }* p. j2 Z
<P><FONT color=#0000ff>/* display the information */
5 f( W3 H4 r; {7 @- |1 W5 y5 Lsettextjustify(CENTER_TEXT, CENTER_TEXT); ; v3 U* \3 A* G1 D3 {
outtextxy(midx, midy, colstr); </FONT></P>
! T' H5 `) [, F8 j5 c% @! l( x/ r<P><FONT color=#0000ff>/* clean up */
! W }/ n( Y" x# Q/ `7 t( n7 Rgetch();
# p* v" |% ?( B, Jclosegraph();
2 k7 [6 R4 G- areturn 0;
/ |! [4 p1 } T5 U: r5 u} </FONT>: v, j+ B' k2 V8 J# f7 Y J b) M
2 S t; P5 H0 C
( A! m- S) B' E1 h</P>. X+ u2 s. l' l9 D8 E' }
<P><FONT color=#ff0000>函数名: getmaxx </FONT>
; p0 ]4 q0 z; }8 }7 e6 \% T" A3 o功 能: 返回屏幕的最大x坐标 ' ^6 L _. n& b3 u" u4 U" L
用 法: int far getmaxx(void);
5 j2 c3 d8 p5 i8 p3 P2 D+ m程序例: </P>
6 O5 H2 q' M; J& y0 o<P><FONT color=#0000ff>#include <GRAPHICS.H>
- I* F$ C' o- M#include <STDLIB.H>
* w( `+ ^; q* F) E; r ]2 L#include <STDIO.H>7 g. ^! d: N+ x& Y/ i5 b
#include <CONIO.H></FONT></P>( o7 n% X- o) V3 I+ s" D% Z
<P><FONT color=#0000ff>int main(void) - ]' H2 k5 c3 O
{ , t: x0 B1 m2 Z2 D
/* request auto detection */ 7 ]4 \' p* ~: S" Y t, w4 g
int gdriver = DETECT, gmode, errorcode; 3 T- i) K0 s. g/ J& w$ S
int midx, midy;
+ g8 W6 T6 {6 x! X' R! _& Ychar xrange[80], yrange[80]; </FONT></P>
0 D1 E1 z+ Y) Q& H( V' R0 @<P><FONT color=#0000ff>/* initialize graphics and local variables */
6 v- n, F9 T' o* K9 {initgraph(&gdriver, &gmode, ""); </FONT></P>
/ C; L; [7 \7 o' W+ b6 Z$ R<P><FONT color=#0000ff>/* read result of initialization */ ( u0 u& y8 a2 m& C7 {
errorcode = graphresult(); ' d2 o. w+ @: K# I& ~5 O
if (errorcode != grOk) /* an error occurred */
6 H# }( Q0 Y; `/ V{
S/ g0 V, u4 s, s6 k; Y' u' kprintf("Graphics error: %s\n", grapherrormsg(errorcode)); : k# d# L8 G8 _ M8 z) j8 q
printf("Press any key to halt:"); ; v5 l1 T# J0 f( G
getch();
3 I* [& n3 e+ `2 V+ m' vexit(1); /* terminate with an error code */
. G/ _$ b4 R" e} </FONT></P>; k6 Y$ L! G _9 ^
<P><FONT color=#0000ff>midx = getmaxx() / 2; * X- c3 n- Q: v2 ]- v7 a3 I
midy = getmaxy() / 2; </FONT></P>& c8 F% ]" T1 }- b. x3 q
<P><FONT color=#0000ff>/* convert max resolution values into strings */
3 W: A i5 [5 |! \sprintf(xrange, "X values range from 0..%d", getmaxx());
+ \2 \% {( \; v4 asprintf(yrange, "Y values range from 0..%d", getmaxy()); </FONT></P>
0 H5 Q* @4 |/ Q<P><FONT color=#0000ff>/* display the information */
; P4 N) d$ `6 A% Fsettextjustify(CENTER_TEXT, CENTER_TEXT); : D" m' u7 O8 m' j0 K6 @
outtextxy(midx, midy, xrange);
7 K! g/ S& h6 X) s: Touttextxy(midx, midy+textheight("W"), yrange); </FONT></P>& B |" V* t2 H. w
<P><FONT color=#0000ff>/* clean up */ ( V: [0 Q3 O$ {
getch(); 5 |. G* g1 ~, h w Z+ N5 Q5 G/ e, _
closegraph(); ( Q+ V4 o( E* P6 W. m
return 0; 5 g7 w3 [; C; q$ f1 m# N
}</FONT> $ `) E* [9 z; `7 |+ y" t+ V
5 l/ |/ Y) F% r</P>
8 h/ B# w" J+ O<P><FONT color=#ff0000>函数名: getmaxy </FONT>, m$ [* T! Y: z
功 能: 返回屏幕的最大y坐标 # s$ C" [& X* s6 d9 D; U( h
用 法: int far getmaxy(void); & o& U" @8 Y! ]- W
程序例: </P>9 H9 M/ J8 u1 |2 H* i
<P><FONT color=#0000ff>#include <GRAPHICS.H>* Q4 f) q! h! k
#include <STDLIB.H>
0 H: h4 A0 F( L' E1 n#include <STDIO.H>4 B* Y% L D, i% E8 }7 f
#include <CONIO.H></FONT></P>: B6 ` ?& c9 X& C% V2 K. V6 @ a
<P><FONT color=#0000ff>int main(void)
( ^- [9 x2 l3 p{ 9 \4 Y8 n/ w8 ]
/* request auto detection */
) f6 F4 E# u1 S/ |" ^/ Gint gdriver = DETECT, gmode, errorcode;
$ g' L) y+ L* u+ H" g4 m* }5 Kint midx, midy; + r, Q9 q% l' |) b# _" x8 @; p
char xrange[80], yrange[80]; </FONT></P>
. |5 [# E6 V y) _<P><FONT color=#0000ff>/* initialize graphics and local variables */ / b) l- U% |# L* L. D$ x: b4 W N
initgraph(&gdriver, &gmode, ""); </FONT></P>
! P/ C- E- [9 J) x" h; G Y9 c<P><FONT color=#0000ff>/* read result of initialization */
- {9 @2 O, m* z' }0 L( Derrorcode = graphresult(); # `: M; c$ u9 N" s6 e: } j9 K
if (errorcode != grOk) /* an error occurred */ 0 R5 k/ x, l* {: c' p+ B
{ 3 n. B0 ~7 {$ p1 D5 S& e
printf("Graphics error: %s\n", grapherrormsg(errorcode));
6 ~0 F; O0 R0 R" d, Tprintf("Press any key to halt:"); 8 l( V1 f+ `' A7 v1 O0 x& ] m I
getch();
: O4 o' _6 h' s7 q! w6 k- Cexit(1); /* terminate with an error code */ / l& N" T( m8 w. N
} </FONT></P>
{; a( {$ @5 Y: L, z1 F3 O. S5 M<P><FONT color=#0000ff>midx = getmaxx() / 2;
7 j4 j2 S6 b, dmidy = getmaxy() / 2; </FONT></P>7 n" ?) x$ h0 p: U& f: N: D; q
<P><FONT color=#0000ff>/* convert max resolution values into strings */
+ X2 ^0 ?$ e# t4 U8 }# D' Fsprintf(xrange, "X values range from 0..%d", getmaxx()); 2 p4 p( u* n- v( ^" b5 H( S( ?
sprintf(yrange, "Y values range from 0..%d", getmaxy()); </FONT></P>
$ V* `% a9 t8 t/ t# I+ R<P><FONT color=#0000ff>/* display the information */
/ N& C5 W6 @8 M& s. j8 @settextjustify(CENTER_TEXT, CENTER_TEXT);
5 J* }9 X+ g+ a7 \outtextxy(midx, midy, xrange);
% w/ a" X8 S `- Gouttextxy(midx, midy+textheight("W"), yrange); </FONT></P>! U) p J, [ E4 F7 M
<P><FONT color=#0000ff>/* clean up */ . [$ E5 N% _& N. t p9 L) B. D, Q
getch();
`; L' s8 ~7 \0 O; L1 X$ X hclosegraph();
: K& ]- V4 e/ k8 d& greturn 0;
$ ]- R6 l7 R: o. S, L4 }% ?} </FONT>
/ @# B3 E4 ^: }; y! U</P>
: l1 O" @0 q/ j4 d; N. J<P><FONT color=#ff0000>函数名: getmodename </FONT>+ Y, `" z4 ?) E8 h& z
功 能: 返回含有指定图形模式名的字符串指针
3 U h: q# z3 S用 法: char *far getmodename(int mode_name);
0 n4 ~% Z* u# T6 w+ B- Q) L程序例: </P>7 j4 v. S. E" X7 r7 _( O1 C' ~
<P><FONT color=#0000ff>#include <GRAPHICS.H>' ]& ?" }' @0 l! r
#include <STDLIB.H>
6 E& Y* L: X% P2 x: v! H#include <STDIO.H>& U0 |4 h4 _. h; |1 t( d( a n
#include <CONIO.H></FONT></P>
7 r7 G* U8 _" ]$ D+ d<P><FONT color=#0000ff>int main(void)
5 z: m) q; _6 Y4 l* ^0 U{
0 e d" Y7 f2 e. f" }/* request autodetection */ 6 q) b- Y) B# z3 Y3 F. l8 V
int gdriver = DETECT, gmode, errorcode; $ z; a! v1 | g6 M3 }4 j
int midx, midy, mode;
3 {' e1 s& D# z6 {# bchar numname[80], modename[80]; </FONT></P>
) l4 [% x8 Q! z' x1 R<P><FONT color=#0000ff>/* initialize graphics and local variables */
5 u- s% x+ E+ [! I. @2 ^initgraph(&gdriver, &gmode, ""); </FONT></P>
; X( ` W$ z2 X2 P, _<P><FONT color=#0000ff>/* read result of initialization */
3 l% [) N0 q( Aerrorcode = graphresult();
! s1 U) B6 e c1 U! Rif (errorcode != grOk) /* an error occurred */ $ a) P N- h3 C; `2 I( q
{
2 i4 [0 N- C3 ], b. V% l- Vprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 5 z5 @% H/ y5 H* w+ i
printf("Press any key to halt:");
, z2 {/ P+ c! E9 ]- z' R6 mgetch();
# d% f5 K/ j) e/ u! n3 H) Gexit(1); /* terminate with an error code */ 7 l* s* B: \( [. w/ T
} </FONT></P>
% u/ m* e# I1 M7 t; x<P><FONT color=#0000ff>midx = getmaxx() / 2; / }/ x' z8 \( m* |7 w4 a' `
midy = getmaxy() / 2; </FONT></P>% O) d: F7 _1 H
<P><FONT color=#0000ff>/* get mode number and name strings */
' l# F/ f" T* L" E c$ x" vmode = getgraphmode(); - s$ J7 C6 d& h, a0 v) D, W
sprintf(numname, "%d is the current mode number.", mode); 1 R7 ` t; d* `! o7 @/ M8 a: F
sprintf(modename, "%s is the current graphics mode.", getmodename(mode)); </FONT></P>5 \2 H, n. K5 E9 W6 a1 s+ `3 ?% z6 ?
<P><FONT color=#0000ff>/* display the information */ 0 t. M+ d( c3 V$ \( V* z
settextjustify(CENTER_TEXT, CENTER_TEXT);
* m2 m/ |! `* V+ H" ?6 `outtextxy(midx, midy, numname);
; b8 `) P9 ~+ }, q& d1 K/ Wouttextxy(midx, midy+2*textheight("W"), modename); </FONT></P>8 \2 s1 R$ z* r Y. _
<P><FONT color=#0000ff>/* clean up */ 4 l" X- C# y& \/ h
getch();
" x1 t L: L( | z8 I- z( s2 uclosegraph();
2 ?% L8 G9 N% q) Dreturn 0; 2 i( O% U5 |+ R& u
} </FONT>
+ v! x }- K0 z3 f
+ b: R: r0 F) x0 H5 P</P>, h% A% d3 i7 [* o
<P><FONT color=#ff0000>函数名: getmoderange</FONT> . k/ i9 h% z! \1 Z8 `* i
功 能: 取给定图形驱动程序的模式范围
! F5 U! [* D G. n4 W用 法: void far getmoderange(int graphdriver, int far *lomode, 3 b6 |- s3 Q' G; o! v1 Q& F& {& N' y
int far *himode);
+ Z u2 E6 L. C3 d6 R& |程序例: </P>7 o" u' i! [0 f* k/ B) ]6 j3 f) y
<P><FONT color=#0000ff>#include <GRAPHICS.H>7 n" t1 r: Y5 _& \% @* X8 b
#include <STDLIB.H>
t* c! v* [- f8 Y1 P#include <STDIO.H>0 e$ r% G2 a1 \. n% |
#include <CONIO.H></FONT></P>
+ o# w+ k7 B; k# Q5 {2 ~<P><FONT color=#0000ff>int main(void) * M- k4 S# Y( ~8 l* L6 Q' e
{ ! C; [" z9 v, a; G) C5 W! b, ^
/* request auto detection */
% ]1 I6 r* m7 d- u" m. ?( t& a# hint gdriver = DETECT, gmode, errorcode; ' p, T& F5 A1 ]' I
int midx, midy; : m3 w4 K8 p- Z7 B$ G
int low, high; * q" E* e7 k( E9 N. C1 j
char mrange[80]; </FONT></P>( m$ w' y' B( Q% w) p; U
<P><FONT color=#0000ff>/* initialize graphics and local variables */
0 A8 W* S* d7 N, C! R2 J7 V8 E- {initgraph(&gdriver, &gmode, ""); </FONT></P>
- y) H/ \3 l" U<P><FONT color=#0000ff>/* read result of initialization */
. i/ y3 I" o% ^1 h3 A Nerrorcode = graphresult();
" {* a$ |1 D1 U! S1 D! Z T5 Tif (errorcode != grOk) /* an error occurred */
& N1 \* O, j+ w- [+ a" `{ $ c7 u- M0 o5 H
printf("Graphics error: %s\n", grapherrormsg(errorcode)); / U4 h+ |8 `+ A6 {! w
printf("Press any key to halt:"); ) c# o4 R- f9 _+ D9 [! K- K: |
getch();
" M: x. M( ~# a; k+ N+ w+ h$ iexit(1); /* terminate with an error code */
P" w2 \7 h# t& m/ n} </FONT></P>: }& h0 x* Y5 p/ v/ W
<P><FONT color=#0000ff>midx = getmaxx() / 2;
7 W( a( s3 |8 Y) H! ` Tmidy = getmaxy() / 2; </FONT></P>0 ?5 `, ^+ c" K9 J
<P><FONT color=#0000ff>/* get the mode range for this driver */ ( v4 ~+ | k$ m# B8 B8 j7 ?
getmoderange(gdriver, &low, &high); </FONT></P># K( i& B& K2 _4 f3 B3 J
<P><FONT color=#0000ff>/* convert mode range info. into strings */
# h0 @' I/ w2 r, B% Y; L+ F+ c5 ]sprintf(mrange, "This driver supports modes %d..%d", low, high); </FONT></P>& `7 d7 e. ] m8 b5 H- p* [* r* {
<P><FONT color=#0000ff>/* display the information */ ; Z9 U$ |4 r4 i
settextjustify(CENTER_TEXT, CENTER_TEXT);
. Q. j/ ~2 L# j5 p3 t; Jouttextxy(midx, midy, mrange); </FONT></P>/ b3 }0 w0 y0 _2 p/ ?2 k* ~4 r9 d; a- e
<P><FONT color=#0000ff>/* clean up */
3 w8 c* u- S3 Ngetch(); . U- \1 E5 p- l; v# D) o
closegraph(); 6 D% H9 @+ K, H
return 0; $ M& g7 Z0 h+ c7 y9 C9 e( m
} . F1 ]7 i0 q+ {( F( p" w
</FONT>
L+ q8 f3 V3 _4 M8 S2 c</P>9 @2 u' Z$ f; U, g
<P><FONT color=#ff0000>函数名: getpalette </FONT>
$ B5 I/ S }3 g# \* a+ }5 d. d功 能: 返回有关当前调色板的信息 7 Q B2 w/ Z6 G$ T2 s
用 法: void far getpalette(struct palettetype far *palette);
3 D6 q% U( O7 y2 L+ e/ _程序例: </P>
- i. R9 r" O& ]<P><FONT color=#0000ff>#include <GRAPHICS.H>
+ A9 f& ^. S0 B, W#include <STDLIB.H>- u$ G; x" N# U7 z: M- X
#include <STDIO.H>6 j, d' K% U# K5 l
#include <CONIO.H></FONT></P>
. J! Y n. F- k! J+ ]: @<P><FONT color=#0000ff>int main(void) + P5 g( ~! U7 r- d5 u
{ ( }9 I4 v& |% g6 h& {
/* request auto detection */ ' X4 p* g d0 C# H8 _
int gdriver = DETECT, gmode, errorcode;
! m, t0 i+ K8 k) D( F) {: Bstruct palettetype pal;
- Y5 g3 @4 s+ Y5 O2 w, A: Rchar psize[80], pval[20];
7 N( Y: R @! D* Bint i, ht; % H0 f+ O, j1 W
int y = 10; </FONT></P>
3 f9 L' A$ j2 V3 D. g0 U<P><FONT color=#0000ff>/* initialize graphics and local variables */
0 U) t/ ?. L6 |7 ainitgraph(&gdriver, &gmode, ""); </FONT></P>
B7 L1 X- T" \8 r( [' C2 n: g<P><FONT color=#0000ff>/* read result of initialization */
* K. V* v2 \( d v& herrorcode = graphresult();
+ x* s" a+ t" X0 J) [' J/* an error occurred */
2 j: E7 X U4 q4 Q1 T' P# }if (errorcode != grOk) & m* C" J( ~2 q! a
{
. y- b/ ]7 ?7 F. c3 b' K ?& w# y/ a+ bprintf("Graphics error: %s\n",
. T: x4 R# P* [( Z: U4 [grapherrormsg(errorcode)); 4 {- G0 {; r4 \( s& \
printf("Press any key to halt:"); ( S* l/ {" m8 s
getch(); J# m# D& F/ b$ F
/* terminate with an error code */
! e/ h+ m' Z5 xexit(1); * N3 I& N- p# b8 A( E
} </FONT></P>6 \* B3 b" m1 Z* ~; l
<P><FONT color=#0000ff>/* grab a copy of the palette */
E1 b y* j# m. l6 _1 fgetpalette(&pal); </FONT></P>1 w' Z/ X. ^/ G' e4 A! [
<P><FONT color=#0000ff>/* convert palette info. into strings */
$ b9 N* A2 t7 @& |2 r1 P! qsprintf(psize, "The palette has %d \ : M* W$ E% B% @5 Z" _, P
modifiable entries.", pal.size); </FONT></P>
& J4 ?2 c/ l& I$ X2 w" G% h4 x5 ^9 Z<P><FONT color=#0000ff>/* display the information */ ( G+ G& m9 p8 e
outtextxy(0, y, psize); / t4 l4 g! G, G/ z
if (pal.size != 0)
4 ?) {6 e. B% N n{
5 a# p) N u# p% B* k: aht = textheight("W");
( w$ m& J2 g' x4 m }2 ^$ [y += 2*ht; 2 |6 C) \0 j" e: ^: V- r
outtextxy(0, y, "Here are the current \ 7 H& W+ V# f% }1 i
values:"); ( R# Y7 k Y# q- ^. d6 { a
y += 2*ht; / ^& x' ?' q: z2 N4 }
for (i=0; i<PAL.SIZE; <br i++, y+="ht)"> {
7 U; g- L* V$ X. u' [1 ysprintf(pval,
. i0 c- ~ ~& v" c"palette[%02d]: 0x%02X", i,
V( W% p6 r9 G& ^7 d" a$ Tpal.colors); ; w1 p' _& g0 G* O* O
outtextxy(0, y, pval);
& m' H, O1 D; N2 @ u} % R! o5 u, F% X, Q* Z! q1 Y
} </FONT></P>
, i- j" _& P U; ~* z) J<P><FONT color=#0000ff>/* clean up */
- M2 m1 Y$ h" S9 Ngetch(); K8 x6 `, ^6 @
closegraph(); </FONT>
, M0 H& G7 [$ ~) q* r# s3 V<FONT color=#0000ff>return 0;
! K; V3 u L: X: h; e9 z} 4 B) f, Y: `% g, v3 a: ~4 l' k* ^
</FONT></P>
# H+ T( G2 `* K) i<P><FONT color=#ff0000>函数名: getpass </FONT>
1 f1 V. w1 @$ y功 能: 读一个口令 5 x( u# k7 f- k) c$ q
用 法: char *getpass(char *prompt);
" b. P: y- L+ N0 c* U程序例: </P>
+ t! ^, p& c; M. U" p<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
6 m, |+ _' `* N8 J; m! Y<P><FONT color=#0000ff>int main(void)
/ g3 O* P4 V H6 H& Y: {{ 6 _, e. r# S4 [# L+ s
char *password; </FONT></P>
1 n$ K, a0 K, @1 t<P><FONT color=#0000ff>password = getpass("Input a password:"); $ X' l. L4 p( t" O
cprintf("The password is: %s\r\n",
! k: c( Y7 M7 f5 r) Cpassword); % C1 g# N! l! l6 \! Z4 O4 j
return 0; * A) J8 J8 @& }' Q% p, c" G
} ! S9 a0 z+ M6 ~8 R: }& Z
</FONT>
6 B$ M+ i4 W' H9 x% o7 L& T" G# m$ _9 |8 s" W1 I( k7 G Z
</P>
9 R* t [( t q% N; @5 g<P><FONT color=#ff0000>函数名: getpixel </FONT>
2 x7 p; u$ B/ |% ?; y功 能: 取得指定像素的颜色
0 t- D0 X: L2 _用 法: int far getpixel(int x, int y);
4 y. o5 w! ?; o+ \6 l$ D6 G( i程序例: </P>
2 M0 ^2 k" D* e1 A( l3 v<P><FONT color=#0000ff>#include <GRAPHICS.H>) I v( u* z+ X8 M0 |$ X" K$ u
#include <STDLIB.H>
5 q/ U- x* }1 x3 x! Q" s( \#include <STDIO.H>; R7 ^+ U. C; w& h5 y4 Z U2 X
#include <CONIO.H>
* P2 a& Q7 O& X- ^+ ~#include <DOS.H></FONT></P>
/ r+ }6 K/ N$ u( f" ^<P><FONT color=#0000ff>#define PIXEL_COUNT 1000 ! L& B* j8 ^+ k, }- X2 v
#define DELAY_TIME 100 /* in milliseconds */ </FONT></P>/ s- W) R9 a- N6 ~& X
<P><FONT color=#0000ff>int main(void)
: Q; E# H8 k. E: I{ % \) s s- Q6 r+ h5 y4 c; ]
/* request auto detection */
) f* V: w3 |" M5 V* eint gdriver = DETECT, gmode, errorcode;
$ _5 u! {" W1 r7 m. d# {5 Mint i, x, y, color, maxx, maxy,
9 v) v( x2 I, g3 T; Y0 a* `maxcolor, seed; </FONT></P>
7 e4 h2 }0 H: y5 ^* k u<P><FONT color=#0000ff>/* initialize graphics and local variables */ $ ^$ y+ C8 z& u( W1 ]6 T
initgraph(&gdriver, &gmode, ""); </FONT></P>1 W* A* j/ K( X3 j5 B
<P><FONT color=#0000ff>/* read result of initialization */
% W8 H4 ^& x m. ` p# U) g" O7 s5 yerrorcode = graphresult();
$ d* d9 ]* D2 E8 G) E* k( C/* an error occurred */
) |/ {0 X# r4 K Wif (errorcode != grOk)
/ y0 ?. Z& f. `+ b. w- T{
$ _/ |& G4 w$ D5 v! d- @' h5 ]# Hprintf("Graphics error: %s\n",
/ V8 A4 ?& I' g8 p. H* e' Kgrapherrormsg(errorcode)); ) S/ h6 K L( x6 d" m4 v5 w2 f8 }
printf("Press any key to halt:"); 1 |, B9 e/ {0 k$ o3 J9 h. e
getch();
' R7 G j) G2 a/* terminate with an error code */
1 N3 w/ I! k, ~/ o' i" iexit(1);
" d: C0 g& ~% x8 d0 J5 z- W} </FONT></P>
T. ^" D* r2 p" {( W$ g2 e& ^<P><FONT color=#0000ff>maxx = getmaxx() + 1;
1 D9 [, k+ K" r& O3 zmaxy = getmaxy() + 1; " t4 ~9 P" g- u: |: b" M! q9 N
maxcolor = getmaxcolor() + 1; </FONT></P>
; f( h4 i2 e# A* z5 Y<P><FONT color=#0000ff>while (!kbhit()) 0 j3 y$ K/ S G; n& B( v
{ 4 h2 L9 ~4 N6 K# Y3 q7 u( ?
/* seed the random number generator */
% o5 V1 v% O& s8 |1 xseed = random(32767);
1 o m- b; g- g _* G; xsrand(seed);
4 Q, k! x+ T+ Rfor (i=0; i<PIXEL_COUNT; <br i++)> {
. u& m* n# n; g* C1 Ax = random(maxx);
3 I2 Z1 O* q$ \& G# Y$ Py = random(maxy); 9 ~0 s- V2 b# K8 M! S3 s9 V" F! s
color = random(maxcolor);
. b( o4 ]% Z4 H+ F- Hputpixel(x, y, color);
) X9 X, j# {" c& @4 I} </FONT></P>
6 u3 ~; T. q0 ~. M+ `! d; F: |8 w$ i<P><FONT color=#0000ff>delay(DELAY_TIME); - }/ _- E$ c$ D$ x8 ~) n
srand(seed); 6 B5 E+ w; N! N* Q+ g! V/ T- ?
for (i=0; i<PIXEL_COUNT; <br i++)> { 3 B8 }4 z! w- R" g P( x
x = random(maxx);
9 n! w1 G6 r$ u0 x6 M3 gy = random(maxy); / L$ y/ N6 }& E+ K
color = random(maxcolor); + Y! L- E) D& s- k) ]4 k
if (color == getpixel)</FONT> </P>: G4 n' }9 p' S, a/ i
<P><FONT color=#ff0000>函数名: gets</FONT> 1 d' M9 i: o0 v
功 能: 从流中取一字符串 + R. F/ z1 r4 a' H0 K
用 法: char *gets(char *string);
2 x: z5 n) Z2 X# [, e/ I% N程序例: </P>) `) S, j; D) P! h6 X6 C
<P><FONT color=#0000ff>#include <STDIO.H></FONT></P>
2 I1 G( r/ M4 L& d E6 Z* b<P><FONT color=#0000ff>int main(void) & W% i5 U: E- X# ~1 F2 p
{ , O2 T* n! v, S/ u8 K( u
char string[80]; </FONT></P>
* K5 Z* z8 i5 w<P><FONT color=#0000ff>printf("Input a string:"); ! y" e; w% @6 t
gets(string); 1 U* M, X H) j4 k
printf("The string input was: %s\n", 2 y# Z- D; ?! v0 P" J' y* u+ B
string); / ^, |* r; A0 i
return 0; : U" Z7 N0 d4 M
}
( }$ a7 w+ H: v$ Q+ A& }
& L+ E; s1 S7 z</FONT></P>
% Z4 q- S( f3 t: n* W<P><FONT color=#ff0000>函数名: gettext </FONT>& O9 T* r9 g3 X0 o! S2 \" l
功 能: 将文本方式屏幕上的文本拷贝到存储区 9 [" v! ~& [! G: o' X6 K. h
用 法: int gettext(int left, int top, int right, int bottom, void *destin);
1 [' _5 z2 B9 E" c0 @, L程序例: </P>
5 Y4 w- `; S8 H& G% ?3 p<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
; y* r4 p6 U |8 G. w" V<P><FONT color=#0000ff>char buffer[4096]; </FONT></P>
$ P9 r2 [+ r: N* z<P><FONT color=#0000ff>int main(void)
: m+ @: G) I; j2 d5 ~{
) P2 y, g+ ~! A9 xint i; 5 z5 C' j1 A1 P# M5 ?8 n& m
clrscr();
( `$ U9 i; e+ i$ N; t$ cfor (i = 0; i <= 20; i++) ) L2 [7 y# d* Q1 \- m. _& f
cprintf("Line #%d\r\n", i); ) Y- P# y1 q7 L. J+ O+ h
gettext(1, 1, 80, 25, buffer);
# ~# F+ q1 ?9 y. G7 A% t Vgotoxy(1, 25); F7 } c' W, L0 W4 H
cprintf("Press any key to clear screen...");
# b' e4 \& r& u7 tgetch();
4 U9 i. Q7 U4 P" L2 hclrscr();
c) y, N% x) a* Y0 p# B: d0 Tgotoxy(1, 25);
4 b& V! U7 E. U. g2 Y. F; w& z! Acprintf("Press any key to restore screen...");
" d( {7 E$ [1 `& K4 {4 Kgetch(); 2 G% c- P9 g& u8 T3 H3 |- A
puttext(1, 1, 80, 25, buffer);
4 b A9 B, c' n( egotoxy(1, 25);
- O8 S. q7 T, N" e2 d$ Acprintf("Press any key to quit...");
& ~+ N; F8 ~# ^$ Rgetch();
) K; T* J5 Q( C3 {return 0; 2 `1 g2 T* a, z7 r
}
) f( m( z- R5 S& K8 J</FONT>
; U' p# j8 R, E. f2 J</P>
$ O8 x% `5 K0 q% W) N: F) L" n5 z<P><FONT color=#ff0000>函数名: gettextinfo</FONT> - v8 W6 S5 L$ [, U
功 能: 取得文本模式的显示信息
- \3 K; B+ x0 }4 \. B& V9 G1 _$ \用 法: void gettextinfo(struct text_info *inforec);
# z g' H u2 p0 E4 c0 o% x( ~0 A程序例: </P>: {% d* F# ^: {) ]
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>7 n8 V7 |7 U B' O
<P><FONT color=#0000ff>int main(void)
6 `% d1 C8 R+ {3 L9 t7 G{ & E$ r g2 \* o& t9 ?* {
struct text_info ti;
& Q% c8 m; g# D- f2 k5 H1 pgettextinfo(&ti); ( Q" z* q" o/ D6 U* }; N
cprintf("window left %2d\r\n",ti.winleft);
2 h/ P. k; T; s2 Bcprintf("window top %2d\r\n",ti.wintop);
* T. _$ X' K# s( v0 b( E& Ccprintf("window right %2d\r\n",ti.winright); _ N% F2 _6 Q
cprintf("window bottom %2d\r\n",ti.winbottom); 9 Z1 S9 s, |0 ]3 W
cprintf("attribute %2d\r\n",ti.attribute);
) |! \" ?) ^, C; r0 a# B6 l* W2 Acprintf("normal attribute %2d\r\n",ti.normattr); ( M5 Y! H! q9 F7 \% H
cprintf("current mode %2d\r\n",ti.currmode); + L+ a1 x5 ]- L) A
cprintf("screen height %2d\r\n",ti.screenheight); ' E6 l* A! v; Y$ ~! v/ q# a
cprintf("screen width %2d\r\n",ti.screenwidth); $ M+ O5 W& a& l% ^6 O
cprintf("current x %2d\r\n",ti.curx);
0 e1 T8 P* o4 c- [: Ccprintf("current y %2d\r\n",ti.cury); 1 h$ z* c# C# W! d2 B, T; |
return 0; $ N% P# K# J4 y7 s6 f6 L
} 5 `" B& `+ {- h s% y g
</FONT>
5 M1 V1 O/ p# j. U</P>! m0 E) @& Y1 A# W! X
<P><FONT color=#ff0000>函数名: gettextsettings </FONT>; \7 ?; M" M& P2 ?+ p$ y2 w6 a6 r/ P
功 能: 返回有关当前图形文本字体的信息
( }* \, B8 p4 `# Z, _用 法: void far gettextsettings(struct textsettingstype far *textinfo);
0 `0 h( |: V D- }* t3 H) [: X5 C程序例: </P>9 \5 P2 J2 s4 ^ V" @& X7 P6 W
<P>#include <GRAPHICS.H><FONT color=#0000ff>" s+ d) ?6 i } l& P# L
#include <STDLIB.H>
* y( {8 l: ]" I6 l; V" E9 f0 N9 O#include <STDIO.H>1 C5 ~/ g8 d* @* f# [) h5 G
#include <CONIO.H></FONT></P>
5 M/ p) Q$ D7 [3 p<P><FONT color=#0000ff>/* the names of the fonts supported */ 5 A2 X+ j1 Q; r. s# }
char *font[] = { "DEFAULT_FONT",
; |! t. g5 A3 l4 \ f3 e$ k"TRIPLEX_FONT", 1 Z; h: N0 X& n; ]* ]8 b& g; e7 z
"SMALL_FONT",
3 o9 [8 Q" H$ [5 w"SANS_SERIF_FONT", : v2 f, S! @, O
"GOTHIC_FONT" ! a2 W" G# t9 R; e2 j* t
}; </FONT></P>
" X+ C+ f, B$ ]<P><FONT color=#0000ff>/* the names of the text directions supported */
' `" r0 y* s& y: N0 r; @1 tchar *dir[] = { "HORIZ_DIR", "VERT_DIR" }; </FONT></P>' M3 Q* S' K Q T
<P><FONT color=#0000ff>/* horizontal text justifications supported */ . i" W% U1 M' B) A: Y
char *hjust[] = { "LEFT_TEXT", "CENTER_TEXT", "RIGHT_TEXT" }; </FONT></P>: ~3 L7 V' |' z$ @* u- `
<P><FONT color=#0000ff>/* vertical text justifications supported */
5 O2 L+ D- v6 \" }7 K( P H/ Ychar *vjust[] = { "BOTTOM_TEXT", "CENTER_TEXT", "TOP_TEXT" }; </FONT></P>4 U' F! @9 R2 |& E/ ~
<P><FONT color=#0000ff>int main(void)
5 i7 W$ \# P& ^& m T- T{
" ~4 N* j) b& L* O0 h0 T/* request auto detection */ 1 E0 a9 U8 j; b1 w- T
int gdriver = DETECT, gmode, errorcode;
5 T, {9 Y. ]* [, Wstruct textsettingstype textinfo;
, n! n* p8 g; B6 uint midx, midy, ht; 8 n0 f3 n: a2 I' ~; e
char fontstr[80], dirstr[80], sizestr[80]; ~: o# `; n4 w% O
char hjuststr[80], vjuststr[80]; </FONT></P>2 G* B; Z5 `4 y
<P><FONT color=#0000ff>/* initialize graphics and local variables */
) V- k5 d& q2 u+ W; binitgraph(&gdriver, &gmode, ""); </FONT></P>& G* A0 F7 j7 Y+ w: v
<P><FONT color=#0000ff>/* read result of initialization */
, q2 S' j7 [' jerrorcode = graphresult();
# }" }" F; c' @0 q5 @if (errorcode != grOk) /* an error occurred */ ; p1 ~8 G0 r# w' }5 [5 N
{
. ?; [' i N1 p8 C6 Uprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 8 U+ z5 |8 ^9 x! W- L) j; I* s
printf("Press any key to halt:"); / c- D0 n6 M5 {( L8 M7 I
getch(); ) D1 W( r& o' F0 {0 {5 Q0 n
exit(1); /* terminate with an error code */ $ B6 h) k7 |/ y
} </FONT></P>, p1 T/ V" F" y9 i$ k9 |
<P><FONT color=#0000ff>midx = getmaxx() / 2; / {* F* G0 s% Y+ E: @
midy = getmaxy() / 2; </FONT></P>
% w* ~0 {3 F# r4 L* L6 @6 z<P><FONT color=#0000ff>/* get information about current text settings */
( U# {, e) v# N L" h+ c- Pgettextsettings(&textinfo); </FONT></P>9 X/ q$ o/ Y! s+ V" u( L
<P><FONT color=#0000ff>/* convert text information into strings */
# `* @$ j! t% P: y6 `sprintf(fontstr, "%s is the text style.", font[textinfo.font]); ( X3 B) |' s' m/ X6 t1 C
sprintf(dirstr, "%s is the text direction.", dir[textinfo.direction]); 8 e P9 a5 X9 z: G2 i* |+ U3 B
sprintf(sizestr, "%d is the text size.", textinfo.charsize);
& X3 o; R/ z* H% b6 ~; |) T7 O& usprintf(hjuststr, "%s is the horizontal justification.",
) {0 H7 `( V1 Y% m: Mhjust[textinfo.horiz]);
- N* m5 Y) Y7 Y7 p- asprintf(vjuststr, "%s is the vertical justification.", 9 N. V1 G4 M' q
vjust[textinfo.vert]); </FONT></P>
; J' R: _" y' ^5 R; n<P><FONT color=#0000ff>/* display the information */ ' q/ V5 o7 X, O& e3 |6 C
ht = textheight("W");
) R' e0 L! i/ j- a# R! J3 R( {9 Rsettextjustify(CENTER_TEXT, CENTER_TEXT);
4 o. B7 P1 ]0 N5 touttextxy(midx, midy, fontstr); + u+ W: U& F4 A2 V1 O# Y2 B3 ?0 C1 O
outtextxy(midx, midy+2*ht, dirstr); . O. Z6 O( h9 l. s9 X0 w5 _) A" _1 ], e% B
outtextxy(midx, midy+4*ht, sizestr);
# K6 G# c! d6 j. O, Louttextxy(midx, midy+6*ht, hjuststr);
+ O$ }: z3 y$ D& w& ?, }9 X touttextxy(midx, midy+8*ht, vjuststr); </FONT></P>( [# E9 L5 ?( g' u5 ^2 J" n
<P><FONT color=#0000ff>/* clean up */
0 I* z. ^. i7 K8 G- Z Hgetch();
# c6 f' i2 G; s* R; n' E, }8 v4 aclosegraph(); " N) G4 I% ]' Z8 F/ t
return 0;
8 p6 J! M6 B- Q6 a7 |} </FONT>
' w" \7 y% V# m" |: I$ R</P>" D5 V5 b* L+ J# g
<P><FONT color=#ff0000>函数名: gettime </FONT>, i! y# S5 A) R. N* j% x
功 能: 取得系统时间 7 p8 g; W, y" a; {7 O2 F0 N
用 法: void gettime(struct time *timep); ) L$ Y& q" @$ H& U) w
程序例: </P>
, P D, I5 ~* P) D5 b% n5 z<P><FONT color=#0000ff>#include <STDIO.H>
2 N. b T1 z9 ?#include <DOS.H></FONT></P>
; X( F0 N( @) C! R. z: B3 L<P><FONT color=#0000ff>int main(void)
4 Y" e8 l/ M) | e2 m{
: @$ w: M, E9 C6 N1 tstruct time t; </FONT></P>& W# K. g" p; C9 N
<P><FONT color=#0000ff>gettime(&t);
`$ j! h9 \' ]4 l' ?3 I+ B5 nprintf("The current time is: %2d:%02d:%02d.%02d\n",
/ }$ G4 Y" d1 ^0 i: U# ~+ p0 B2 `t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
6 t. G* e, e9 S) S# treturn 0; : V- {1 C& x Q! L( B, `
} ; c1 Q/ G* L8 @
( ]& U3 W z: v+ n* K</FONT>
. p0 e, I% B5 a! M; {+ E</P>
2 n& M" C# p1 g5 ]4 i- e0 X<P><FONT color=#ff0000>函数名: getvect </FONT>1 ~3 ~( `' P1 h1 H5 ~; o
功 能: 取得中断向量入口
: V0 h& e0 n6 M, I7 ?用 法: void interrupt(*getvect(int intr_num));
1 i& r" z. b8 _9 i' h! I0 t' Q' ?1 ~程序例: </P>
4 b( w5 u& l% M# d3 {- k<P><FONT color=#0000ff>#include <STDIO.H>
3 q7 M. }7 D& D) A$ {) ~9 h& l: ]1 X#include <DOS.H></FONT></P>: {+ S% x/ S9 G* q
<P><FONT color=#0000ff>void interrupt get_out(); /* interrupt prototype */ </FONT></P># j Q$ b/ [ o% m, u& t
<P><FONT color=#0000ff>void interrupt (*oldfunc)(); /* interrupt function pointer */ ; }8 p* w* F, ?+ w: |+ Q0 U& U3 V
int looping = 1; </FONT></P>3 a# r9 {8 L, q- g- c; `& ?4 A$ \
<P><FONT color=#0000ff>int main(void) . N& }# F1 `. g* t2 J: A$ z: K
{
# Y: n1 n4 c2 U" M5 e; h' Cputs("Press <SHIFT><PRT Sc>to terminate"); </FONT></P>
6 V& R1 B( h( l9 @) a<P><FONT color=#0000ff>/* save the old interrupt */
7 t; @* |4 j7 x F: b& U2 \: roldfunc = getvect(5); </FONT></P># v5 A% S! J( B% Z3 V o, n
<P><FONT color=#0000ff>/* install interrupt handler */
! l+ d" ~( J- G, n# msetvect(5,get_out); </FONT></P>
S6 F$ K3 g( _3 A9 c4 t<P><FONT color=#0000ff>/* do nothing */
& o3 D' M& D- ]/ B! b) hwhile (looping); </FONT></P>
% M) p+ r: A5 D- f<P><FONT color=#0000ff>/* restore to original interrupt routine */
" w! _; ?+ v5 f1 z. esetvect(5,oldfunc); </FONT></P>9 U+ P ~; ~4 z, e2 A
<P><FONT color=#0000ff>puts("Success"); 8 ^# ]$ V7 R5 b f0 k. S9 T8 y
return 0; 1 y; \( B9 w0 Z
}
/ f4 d% b# k0 b% Evoid interrupt get_out() : A8 v% h' u5 J `
{
5 }- }% r4 @6 U9 _2 Klooping = 0; /* change global variable to get out of loop */ 5 X7 T- p8 L) I3 E9 \
}
" j9 @/ W. v% m3 ]2 ?8 h</FONT>- c0 x5 i9 K& i# c+ C0 {; W, Y! P9 u
</P>9 F5 j& k5 |! V% Y: b
<P><FONT color=#ff0000>函数名: getverify </FONT> A' W' C7 N' z4 n* g, s2 |" a7 u3 [. o
功 能: 返回DOS校验标志状态
6 ~! g$ t/ a" \ g$ I# X. B9 |用 法: int getverify(void); " S0 a) N6 B: @7 l6 {8 [
程序例: </P># D* ^6 `- Z% q6 V" E& c
<P><FONT color=#0000ff>#include <STDIO.H>
5 b; x8 D3 W* O9 U* E+ N#include <DOS.H></FONT></P>
, E2 i7 c3 |7 E! N0 O) d( B% R* I<P><FONT color=#0000ff>int main(void) $ L* O% z8 [) j: @
{ & S* W- Y q% k3 c c+ N0 k
if (getverify())
: U& v! J1 j, ?: rprintf("DOS verify flag is on\n"); 5 R' k4 s8 E- O1 B+ x) t5 F
else j6 c8 r x" K" X) N
printf("DOS verify flag is off\n"); . [* ~ t4 u& h$ {! l8 F6 S
return 0; 1 E& [$ I; U* @" ]% z$ r
} 7 B; e& M x( j& b/ b
</FONT></P>/ K C8 Z- w: O2 i) R6 |% @/ D* V* _
<P><FONT color=#ff0000>函数名: getviewsetting </FONT>* M+ o: G1 a% T* Q2 [. }* Q# ~
功 能: 返回有关当前视区的信息
. {: h" u* `4 W! L5 g$ t+ |用 法: void far getviewsettings(struct viewporttype far *viewport);
" B' l m$ \9 ]. p8 o0 B程序例: </P>+ I3 k2 i( l+ s/ P: `! ^. G0 w7 G
<P><FONT color=#0000ff>#include <GRAPHICS.H>
5 y: H9 N2 A/ v" m7 s( [#include <STDLIB.H>9 @' l! H# n& W R' I% a: M5 k
#include <STDIO.H>1 U2 B) u* K9 \# P$ p
#include <CONIO.H></FONT></P>
( V9 @2 F4 {3 x1 K/ J3 A<P><FONT color=#0000ff>char *clip[] = { "OFF", "ON" }; </FONT></P>
& `. X0 Y4 C' N) t r s<P><FONT color=#0000ff>int main(void) / | i9 W8 R1 h) K- {; z) i4 C/ e
{ " Q4 [; a9 b- N; O( Y5 u8 L
/* request auto detection */ & Z5 u7 y$ E, F; q2 V1 \+ N
int gdriver = DETECT, gmode, errorcode;
: F# K5 k5 h U! D1 N2 Nstruct viewporttype viewinfo;
! g A5 E- O+ a% tint midx, midy, ht;
. E# x( e/ l/ e; Y" Echar topstr[80], botstr[80], clipstr[80]; </FONT></P>5 e/ r& L% g, L' }4 I g; }5 t& i6 ?
<P><FONT color=#0000ff>/* initialize graphics and local variables */ ! e& e2 [ Z# ^* c( i" j* ^
initgraph(&gdriver, &gmode, ""); </FONT></P>3 b7 A# a# ?) X, l4 }+ A3 C# X0 b
<P><FONT color=#0000ff>/* read result of initialization */ " t' r: p, w- B6 y- E- l/ q
errorcode = graphresult();
. Y% U( H9 e3 p( iif (errorcode != grOk) /* an error occurred */
# w) o8 [* `% }, Y$ Q# K{ ' z+ w' `1 h3 r0 L
printf("Graphics error: %s\n", grapherrormsg(errorcode));
" _! H& F& t/ ^) b- Vprintf("Press any key to halt:");
' n( }2 {" E7 L9 c. [getch(); * _" s8 \3 z4 j1 E- K
exit(1); /* terminate with an error code */
1 X+ s( w& P" q6 \8 l* V+ @} </FONT></P>+ V. N3 K( M `# \3 e+ z$ m% K
<P><FONT color=#0000ff>midx = getmaxx() / 2;
- q0 p2 |4 r5 u. [* B4 Vmidy = getmaxy() / 2; </FONT></P> A$ l! o# h; K2 m
<P><FONT color=#0000ff>/* get information about current viewport */ 4 Y5 c1 ]' l1 s$ P4 X
getviewsettings(&viewinfo); </FONT></P>) I0 f7 Y7 s- P6 g& c: E, E
<P><FONT color=#0000ff>/* convert text information into strings */ + [$ X6 \: h( V9 q! ?% }
sprintf(topstr, "(%d, %d) is the upper left viewport corner.",
$ S8 n7 g0 h: \, X/ e* ?3 K2 Hviewinfo.left, viewinfo.top); ) C: B# M# z+ r# X2 w. ]/ j
sprintf(botstr, "(%d, %d) is the lower right viewport corner.", 9 c; j* G/ y5 I z8 f' ^/ ]& N
viewinfo.right, viewinfo.bottom);
" O, i! y2 { M* A7 V8 m Dsprintf(clipstr, "Clipping is turned %s.", clip[viewinfo.clip]); </FONT></P>) O" G& f) L) {% `# K3 i
<P><FONT color=#0000ff>/* display the information */
$ ^& Y3 f9 ]/ R& I7 \: t5 D$ Gsettextjustify(CENTER_TEXT, CENTER_TEXT); : B) S" k( I* }; \- @0 q2 u
ht = textheight("W");
, d( x' s: T9 n! x3 ~1 Fouttextxy(midx, midy, topstr);
7 ?9 N B" m& ?6 Kouttextxy(midx, midy+2*ht, botstr); # N( x/ D+ N" u) P5 O' s7 N! K
outtextxy(midx, midy+4*ht, clipstr); </FONT></P>. j! S7 _" `6 k% ^1 e
<P><FONT color=#0000ff>/* clean up */
2 h# i6 T4 P8 [3 w* zgetch(); ' L- K! v5 \+ j$ i( |6 m
closegraph();
1 e: V" q7 b" [5 C$ Hreturn 0;
v- n! }8 K# b" J} </FONT>
8 i* d6 M/ B- g% s8 _2 \7 n, x! f2 @
</P>
3 j8 d4 q# r8 k" X5 d6 T<P><FONT color=#ff0000>函数名: getw </FONT>! L. X6 t, G! e8 K- F* `8 z
功 能: 从流中取一整数
9 N, {( u& B9 J用 法: int getw(FILE *strem); 1 H( f' y+ r9 F; q( o
程序例: </P>
3 v4 o; |" J, \6 a<P><FONT color=#0000ff>#include <STDIO.H>
- v$ d A% ^' O& G, ~4 {, L#include <STDLIB.H></FONT></P>* v) u) p: s: v& P7 d
<P><FONT color=#0000ff>#define FNAME "test.$$$" </FONT></P>7 t6 D1 w/ O1 I _2 k9 L9 k3 w
<P><FONT color=#0000ff>int main(void) 3 }% [2 u* C1 i4 S/ f
{ & V. d# e u% [
FILE *fp; " k" m' k' y& B( |; J: [
int word; </FONT></P>0 K! ?& o* Q+ W' P/ x
<P><FONT color=#0000ff>/* place the word in a file */
: v" d2 d# j: Z$ y* g$ o) Qfp = fopen(FNAME, "wb"); 0 g2 q, K" E, s! x9 C; E
if (fp == NULL)
" }7 T: w4 d* n2 q0 m{
) a: L& Y/ `) x, j0 C) ^printf("Error opening file %s\n", FNAME);
; w5 N( _1 f. d9 c& X; {exit(1); * m5 ^4 a& Q9 R0 [
} </FONT></P>
+ r5 W0 x8 P. B2 b8 `+ a<P><FONT color=#0000ff>word = 94;
& Q9 _+ d# {1 c' n" g. Oputw(word,fp); 6 K$ b, s L" h3 m0 I+ ~
if (ferror(fp)) 1 }$ y' W' p! R0 M7 K3 n: d) u# X
printf("Error writing to file\n");
; T' G& h% |9 ]0 w' U2 T" a) t0 Selse . x0 M' V1 I7 G' g" j% x& m
printf("Successful write\n"); 6 L9 Q; g/ `* u3 n; G& e, _ ?3 m
fclose(fp); </FONT></P>
- O( p* v0 C3 a) n4 i<P><FONT color=#0000ff>/* reopen the file */ ' M2 ^# v) _/ c3 z, o
fp = fopen(FNAME, "rb");
' v& i* J8 s7 [1 C, o8 D1 `% Q: lif (fp == NULL)
5 w: o5 y4 N- ^ X( k3 O{
5 E3 F7 H ^; @- J/ t" i9 Dprintf("Error opening file %s\n", FNAME); ) b7 p6 f/ k% @, U A% V' B/ r# D
exit(1);
" y% h9 g$ Z! b2 C. V* Y} </FONT></P>
! R, \. s, i' P7 p+ ~3 {! K<P><FONT color=#0000ff>/* extract the word */
\6 }" [" R) l) C( jword = getw(fp);
) f& m1 O7 _, f+ Vif (ferror(fp)) ; E% x# K/ a8 ]# F# j! g. m4 E
printf("Error reading file\n"); * h' M4 E D4 h. u$ k" d, H! @1 }9 t
else
, x# ^; z3 Q' U# r( g4 {printf("Successful read: word = %d\n", word); </FONT></P>
, q3 W/ M- N: J<P><FONT color=#0000ff>/* clean up */ h% n1 l1 t9 g- H, v
fclose(fp);
8 ^) \9 C% y4 D$ g3 o3 punlink(FNAME); </FONT></P>, z% J$ H _8 x. q
<P><FONT color=#0000ff>return 0; 5 l3 p7 z- g0 {
} </FONT>
' A! y2 U, L5 S5 ?5 ^& N0 v/ [! l: a9 C7 F* ^. V7 A
1 N; S. @! C4 Q0 V0 _4 L
</P>5 s" L3 D+ E* e& ]* _0 H
<P><FONT color=#ff0000>函数名: getx </FONT>; D5 R4 p0 `' E, k" r1 F' I8 y% e! J
功 能: 返回当前图形位置的x坐标 2 i0 K8 a, t& a% I
用 法: int far getx(void);
9 {8 p# p ~7 I& e程序例: </P>
+ ]3 L0 }$ k6 X<P>#include <GRAPHICS.H><FONT color=#0000ff>
; S6 a7 b" p+ i#include <STDLIB.H>: h6 V# m) z- w: x9 k' O9 X3 ?6 V0 b
#include <STDIO.H>
8 |' Y( E0 N6 K: j#include <CONIO.H></FONT></P>% [. s: Y# X; H1 l: f+ a
<P><FONT color=#0000ff>int main(void) + L. h2 W7 k+ A% R, o
{ . {9 n+ O$ }+ U. t5 h! H/ h
/* request auto detection */
& Y% m5 k2 z3 M7 o+ [0 p. iint gdriver = DETECT, gmode, errorcode;
3 t7 N/ x7 i5 u* Y6 a) achar msg[80]; </FONT></P>
( Q1 X" d+ ~" q* j<P><FONT color=#0000ff>/* initialize graphics and local variables */ , k# l0 t! r3 |. E1 T: [$ m
initgraph(&gdriver, &gmode, ""); </FONT></P>. { o0 J' o( }. m) Z6 [
<P><FONT color=#0000ff>/* read result of initialization */ 9 p& `) I2 g2 t
errorcode = graphresult();
7 P6 M4 I) W1 k1 F5 M" U+ tif (errorcode != grOk) /* an error occurred */ 3 N3 h0 D0 a1 J4 S4 R
{
/ m, |" ? H7 u6 T' j4 Fprintf("Graphics error: %s\n", grapherrormsg(errorcode)); * N& ?6 \9 ]/ v4 z
printf("Press any key to halt:"); $ o7 v" D% K' Y. m1 `( f: G
getch(); 1 |: J5 M! X2 R& s$ J
exit(1); /* terminate with an error code */ . ~! x' R& y. B+ L7 b/ j* u
} </FONT></P>7 a, S! J8 P3 P% _, n. _
<P><FONT color=#0000ff>/* move to the screen center point */
4 H/ I2 Q4 t# ^3 E* n: umoveto(getmaxx() / 2, getmaxy() / 2); </FONT></P>& y; V) n4 F! b0 ]
<P><FONT color=#0000ff>/* create a message string */ 5 T4 d3 P, w/ m% p3 o! R/ I
sprintf(msg, "<-(%d, %d) is the here.", getx(), gety()); </FONT></P>/ e, T Q0 N4 P5 \4 c
<P><FONT color=#0000ff>/* display the message */
) w, S* |1 o7 S7 ?+ M) kouttext(msg); </FONT></P>6 a0 f% r. o, [. l
<P><FONT color=#0000ff>/* clean up */
$ G9 y3 S* M5 w- G- X* D1 W* \getch(); " n9 e+ b V7 S4 j4 S& Z* Q: e
closegraph();
4 y6 D8 u4 O# W, D. Q8 }0 c# w* L& nreturn 0; 3 t6 ]( {, ^% X- |# \" t: l" w
} </FONT>* z* D" R4 C- r& r
5 ]/ y9 W8 a6 `( Z7 J6 Z</P>
/ B7 h& f) \' w7 C, l<P><FONT color=#ff0000>函数名: gety </FONT>( d( F8 h: U" W& g1 t9 T
功 能: 返回当前图形位置的y坐标 , \1 o9 c4 W1 J2 e, `: U1 N) K) r
用 法: int far gety(void);
4 V; e4 R/ `4 Q! F* d0 Y程序例: </P>
/ i2 x* ]. L& a- B<P><FONT color=#0000ff>#include <GRAPHICS.H>- ]) n- v5 f* M9 Y
#include <STDLIB.H>0 T$ x! q7 E! f( r* v, C* C- L7 z
#include <STDIO.H>2 \5 \. I2 h' M! R4 V& B4 h
#include <CONIO.H></FONT></P>3 y& O7 \' W5 Y- Z% n$ C) \. B
<P><FONT color=#0000ff>int main(void) ; C& L& F* u0 L8 Z4 p
{
7 H" n/ [! x3 x; L& l# t( O/* request auto detection */ 9 Q0 [4 ?" |# D
int gdriver = DETECT, gmode, errorcode;
. a# u3 }7 D8 T3 Xchar msg[80]; </FONT></P>
! l e; ^0 W/ g! `# t+ b<P><FONT color=#0000ff>/* initialize graphics and local variables */ 4 U7 q, F7 B/ f) S
initgraph(&gdriver, &gmode, ""); </FONT></P>
$ W) ^0 c; f5 T9 S: r<P><FONT color=#0000ff>/* read result of initialization */ / L' L2 { j& [1 c8 e0 A0 y, u8 J+ @
errorcode = graphresult(); & E# ^: _+ y/ b+ Z0 Z$ [
if (errorcode != grOk) /* an error occurred */ + u. e- R O q4 T- f" ?. A
{
: D! m0 N0 `0 vprintf("Graphics error: %s\n", grapherrormsg(errorcode)); " |* _( P# x+ M. X$ }- O
printf("Press any key to halt:"); % h/ b6 Q) \8 M9 b1 J% k
getch(); 1 p C8 o3 y3 t0 C" e1 c# ~" ^
exit(1); /* terminate with an error code */ 3 G! z$ I& X7 i! t
} </FONT></P>0 K! Y2 ]1 \" |& q; h: R8 v
<P><FONT color=#0000ff>/* move to the screen center point */ 7 ~+ H5 j7 K6 k7 |/ f
moveto(getmaxx() / 2, getmaxy() / 2); </FONT></P>* E- j/ ?7 P0 t: X
<P><FONT color=#0000ff>/* create a message string */ ; L! I" w. R# P- }1 o
sprintf(msg, "<-(%d, %d) is the here.", getx(), gety()); </FONT></P>
, O2 y* A( b# f F; k<P><FONT color=#0000ff>/* display the message */
2 N; D- @. {2 k" }4 |1 p8 L0 eouttext(msg); </FONT></P>
* E7 v. t4 i6 a: z) u4 [<P><FONT color=#0000ff>/* clean up */ , V! F7 H- a& Q
getch();
2 M4 a. q6 z2 v3 Lclosegraph(); 8 n9 s0 ?$ u% O5 m J7 ]
return 0;
6 H5 R3 z8 k8 n+ f r} </FONT>% @4 D( l: x% l3 ?
: U0 H; q8 k: i2 \. h0 q* t* X</P> Q! O8 ^- R9 S% h
<P><FONT color=#ff0000>函数名: gmtime </FONT>
) G# n% i. A0 q功 能: 把日期和时间转换为格林尼治标准时间(GMT)
3 B7 A1 J) Q# B用 法: struct tm *gmtime(long *clock); / ~+ p+ _5 m, H+ b, S, i9 k
程序例: </P>
& f8 g+ X; H( ?' P$ Q3 a$ c, O<P>#include <STDIO.H><FONT color=#0000ff>
# Q8 z9 ^) ?8 B2 P# c#include <STDLIB.H>" r7 Z# _: R. n1 L9 \6 B
#include <TIME.H>( S0 Q7 `/ J+ w+ J) u" }
#include <DOS.H></FONT></P>
! R. a) E/ y' v) P) r<P><FONT color=#0000ff>/* Pacific Standard Time & Daylight Savings */
% x" t+ b' {. k) v$ o6 G% Z; cchar *tzstr = "TZ=PST8PDT"; </FONT></P>
3 E+ e: Q4 S2 P" B, s* w<P><FONT color=#0000ff>int main(void)
5 t5 C8 g+ l: Z+ q{ 1 z: Y8 [- K8 I1 ` ], x5 f
time_t t; . p- a2 e! D2 t( s
struct tm *gmt, *area; </FONT></P>
/ ]7 @+ ]- R/ H- d' O' n5 F<P><FONT color=#0000ff>putenv(tzstr);
@& J' b1 d* G% s+ _/ L% Htzset(); </FONT></P>
% r! ~; h* d' p5 D<P><FONT color=#0000ff>t = time(NULL); ) ~* e* e! `* x# A/ Q
area = localtime(&t); , u* A8 m n+ o9 f0 a2 r
printf("Local time is: %s", asctime(area));
2 B" B0 j# [5 R/ y% igmt = gmtime(&t); ) V% r7 n( p; g
printf("GMT is: %s", asctime(gmt));
( N+ s! Z/ O& m( `) Zreturn 0; 3 h2 y" G# [3 |3 K
} </FONT>
5 j5 `' C. o3 A) r: q/ [8 W% s+ c2 r6 ^9 D! _7 n. J% {
</P>1 r7 B, N6 j9 k
<P><FONT color=#ff0000>函数名: gotoxy </FONT>
& `6 Q1 u; _6 F( y3 a. i# A l功 能: 在文本窗口中设置光标 7 a4 L+ J, E. C3 T8 G5 a K% }6 `
用 法: void gotoxy(int x, int y);
" T. U6 [! \8 z/ X/ G+ X' u" I程序例: </P>8 L$ _/ m3 X: _$ i; g" J
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
1 `! [$ Y2 O/ D5 y* _4 a<P><FONT color=#0000ff>int main(void) 4 x$ ~) C% n; L$ M# }9 y! @
{ 4 I% M1 h4 N9 y8 [/ }4 s
clrscr();
* _! K5 D) V' D2 b7 C# {& qgotoxy(35, 12);
% Z7 S& H1 b: e o4 hcprintf("Hello world"); + o2 h! B. L% e/ B
getch();
* O& U' c) R/ x9 h W3 P# \# `return 0; 4 N( c& k0 a/ v! Z8 E3 d$ p
}</FONT>
' H+ y G, s# b& a+ G% E. J, O) v, U9 ~8 l" U7 n; m8 b! B
</P>2 I( X+ I; H) o! K
<P><FONT color=#ff0000>函数名: gotoxy </FONT>
n; y% g+ [% T1 k- [, V# [功 能: 在文本窗口中设置光标 4 e# B' n* T9 l, o8 R _4 q
用 法: void gotoxy(int x, int y); # P8 h. z5 [( r# q) h% r# Y3 }
程序例: </P>
' L( Y/ T4 H# ~/ U<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
& M/ m, o6 o+ O, f( k" ~<P><FONT color=#0000ff>int main(void) ; ^! g5 ?# B8 r$ L/ E/ C
{
" j& ]+ } z0 _2 r4 k Yclrscr(); 9 q$ N. C% {% Z+ O! Y$ n& X9 N7 e2 M
gotoxy(35, 12); - l/ }+ O/ F# N9 w4 D. k# P
cprintf("Hello world"); ( s2 [9 V u) c6 {4 q1 x3 X! U
getch();
6 l6 z& I6 E4 a! [; S9 Y) Zreturn 0;
5 d* l* C' W: t, v2 [, I! S6 F2 ]} . i+ [! C8 M; F- S9 S
</FONT>
" v9 K) R( F/ s) ^ d: L</P>
$ W# Y4 O* Q2 J/ v6 G% d- e<P><FONT color=#ff0000>函数名: graphdefaults </FONT>
/ H$ o9 N! {3 l6 O8 w, o功 能: 将所有图形设置复位为它们的缺省值
9 G3 s/ {9 f$ ~* Z# F4 R用 法: void far graphdefaults(void);
5 N; a! t/ G. `1 h- l4 O& ?) u- I" k0 `程序例: </P>
: u3 x, f) u2 \# U4 ?4 g<P><FONT color=#0000ff>#include <GRAPHICS.H>5 p! _4 r u/ y* Q% T
#include <STDLIB.H>
+ [ M8 o3 G; k! Q/ D1 |9 u' M% s#include <STDIO.H>% Y3 |5 B0 ]0 P# n
#include <CONIO.H></FONT></P>
( z$ _, r9 k9 d* Y<P><FONT color=#0000ff>int main(void) $ Z: H7 M7 K1 F. ]: O9 \( M, S% g
{ / S8 q' V: r+ X" y9 J
/* request auto detection */ ' e7 J4 Y, R& L- ^8 @( l" D' _
int gdriver = DETECT, gmode, errorcode; 8 [& x' C: a3 a( L$ T; p/ W# N
int maxx, maxy; </FONT></P>
+ [( T1 G `4 Y( v& ~$ f8 V<P><FONT color=#0000ff>/* initialize graphics and local variables */ ! J; D X, e1 k6 h, T# i& V8 z
initgraph(&gdriver, &gmode, "c:\\bor\\Borland\\bgi"); </FONT></P>8 B8 o ~" X# f% A4 G/ J4 M
<P><FONT color=#0000ff>/* read result of initialization */
9 M( S) P( t4 X$ H6 T8 i# E) serrorcode = graphresult();
% v8 E7 t' l1 n* R4 s3 t2 ~$ S4 }if (errorcode != grOk) /* an error occurred */ 1 K: B: e* @& g% c0 w% b
{
- b- \( m1 g q) bprintf("Graphics error: %s\n", grapherrormsg(errorcode));
- i" A! R$ ^3 M$ F" Tprintf("Press any key to halt:"); , @ k$ O+ q, U1 d& D
getch(); + P/ {0 f# w% d4 C$ w/ ?3 C
exit(1); /* terminate with an error code */
# g1 Z$ c8 j5 H. L/ K} </FONT></P>8 ?% L0 h9 P# S1 ^' W& [; e
<P><FONT color=#0000ff>maxx = getmaxx(); / c& F8 L! |6 B; k
maxy = getmaxy(); </FONT></P>! Q) P: i0 l* E* A! S
<P><FONT color=#0000ff>/* output line with non-default settings */ - Y! e9 r9 N% d) Q8 u
setlinestyle(DOTTED_LINE, 0, 3); ( _0 }/ W4 v5 ?
line(0, 0, maxx, maxy);
7 l" E) f0 {5 T; ?; ]4 S7 jouttextxy(maxx/2, maxy/3, "Before default values are restored.");
* T1 J6 x1 j+ X b1 f' M" v2 Pgetch(); </FONT></P>
8 K2 e" n) u' k0 z' n# S9 v0 ^<P><FONT color=#0000ff>/* restore default values for everything */ 8 l5 t: E: u/ l5 v! E
graphdefaults(); </FONT></P>
& s' a, p1 ?0 u. ]" _' Q<P><FONT color=#0000ff>/* clear the screen */
( x% A+ X9 e% J. W6 wcleardevice(); </FONT></P>
3 C0 O$ ^! ?, s6 Y! a<P><FONT color=#0000ff>/* output line with default settings */
8 O; \, m6 P$ D3 P7 k; H1 mline(0, 0, maxx, maxy);
& g8 E F. D7 xouttextxy(maxx/2, maxy/3, "After restoring default values."); </FONT></P>
3 r5 I7 V* C e: R0 s<P><FONT color=#0000ff>/* clean up */
R2 V+ {6 A8 a* x3 S5 `' o3 f, cgetch(); % }( O0 m6 f" l, ~2 o
closegraph();
+ s% b# Q, d8 C) i m7 c% u- {return 0; , F$ F8 D! l% h! C( [# g5 e7 n
}
8 k- l6 o. i: H# [# g: {/ G</FONT>2 {7 g1 v: V. x2 }
</P>
7 w' ]: z9 A- x<P><FONT color=#ff0000>函数名: grapherrormsg </FONT>
8 m: r: e' N$ B) V1 _% d; X功 能: 返回一个错误信息串的指针 D1 z: B! Y# M$ v
用 法: char *far grapherrormsg(int errorcode);
4 }1 B k' q; P2 ?8 I程序例: </P>
! l' _- E1 B; Z; m8 w, Y- r- I<P><FONT color=#0000ff>#include <GRAPHICS.H>
" r1 v% m' Y3 V$ ~7 |; `#include <STDLIB.H>0 P p5 q9 q! ~2 O/ e" E
#include <STDIO.H>3 w9 _7 f$ m& \( f3 W% p
#include <CONIO.H></FONT></P>
. d w% Z% L a1 j' {& _# ~<P><FONT color=#0000ff>#define NONSENSE -50 </FONT></P>
$ ~% Y2 r: h- Y. l- r<P><FONT color=#0000ff>int main(void) ( u) v1 Q* K( m5 e$ u, c
{ # ^3 c f" J8 R/ \8 j& C! g; O$ t! r
/* FORCE AN ERROR TO OCCUR */ ) z7 q( C/ V# [% o# U" u
int gdriver = NONSENSE, gmode, errorcode; </FONT></P>
; D* F- Y" ~! m, T, D, }4 v<P><FONT color=#0000ff>/* initialize graphics mode */ 0 T, f3 C: f% M0 @
initgraph(&gdriver, &gmode, ""); </FONT></P>1 j1 Y* f! P( J) w+ b& y" B
<P><FONT color=#0000ff>/* read result of initialization */ % x4 }( X& l" ~' o% q( l2 u
errorcode = graphresult(); </FONT></P>
) o8 f5 s% w, o# ^<P><FONT color=#0000ff>/* if an error occurred, then output a */
* i( z% i$ P7 V) o( Z4 l/* descriptive error message. */ ! _% H A4 o) u; K
if (errorcode != grOk) 6 j7 J- Q4 U2 Y* q, L8 @
{
6 Y) |9 k+ n8 m) m& M% mprintf("Graphics error: %s\n", grapherrormsg(errorcode)); - i0 o2 l# M' B' s5 r: _/ A. J
printf("Press any key to halt:");
6 K" F- Q8 c6 R3 a: E/ o% x; ygetch(); 0 g( J9 N& r$ F) I2 O# @
exit(1); /* terminate with an error code */ : {& P2 e2 t1 ]6 b: _
} </FONT></P>) V1 k' t0 z6 x: M& ]- n
<P><FONT color=#0000ff>/* draw a line */ , y$ S {: x- ]
line(0, 0, getmaxx(), getmaxy()); </FONT></P>, L- E& u+ N3 |9 z# T
<P><FONT color=#0000ff>/* clean up */
4 u8 X) {% Z, wgetch();
+ I: i& t! J4 U$ M+ zclosegraph();
5 w2 L2 P4 W( V3 ^return 0;
% i) f; x3 j4 { ^} . b9 ^" F2 s2 z8 D* [ ?
</FONT>
, q. b/ G3 j9 P3 {/ r( t</P>1 p4 p7 }/ N$ q4 O# f B- @# [4 K
<P><FONT color=#ff0000>函数名: graphresult </FONT>
4 a. z: Q& n$ f) h/ p功 能: 返回最后一次不成功的图形操作的错误代码
3 e! B1 A% C$ [* o用 法: int far graphresult(void);
$ [; h: r$ G- v, D程序例: </P>
/ c% S w" E! N K2 e2 m1 t+ r<P><FONT color=#0000ff>#include <GRAPHICS.H>
' [' u2 `& y8 @#include <STDLIB.H>
1 _( { i- w+ g* i/ @9 a: q#include <STDIO.H>8 p6 Z/ s9 n! e5 \1 L+ g, _
#include <CONIO.H></FONT></P>) E0 @" i) e/ X2 X
<P><FONT color=#0000ff>int main(void) 0 S% o( U" @1 B8 I) `3 u7 T
{ 9 N) I' ]0 i* g H) z; b" Y6 A. j
/* request auto detection */ / `- a; B7 E1 }* @
int gdriver = DETECT, gmode, errorcode; </FONT></P>
4 ^* } p, g1 z* X<P><FONT color=#0000ff>/* initialize graphics and local variables */ 7 i0 G* Y3 { x3 w5 W/ P) `
initgraph(&gdriver, &gmode, ""); </FONT></P>
. b2 H0 C" X$ L6 r0 L4 x: L<P><FONT color=#0000ff>/* read result of initialization */
% Z, n9 u! ~6 Q) }6 M9 C" {errorcode = graphresult(); </FONT></P>
8 n8 j& {/ f8 J<P><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */ ; ^- H/ O8 M3 y6 b& x
{
8 I- {: k: e! K$ P' |printf("Graphics error: %s\n", grapherrormsg(errorcode)); , l8 p6 @+ g" Q+ c
printf("Press any key to halt:"); 7 S5 u/ I9 o4 H
getch();
: Z: T0 u5 e4 ?1 g! Rexit(1); /* terminate with an error code */ " `+ \8 f+ W( ?3 u5 }, G3 @
} </FONT></P>* f0 ^' s8 k9 E
<P><FONT color=#0000ff>/* draw a line */
+ w' ^( W, x$ ^0 \1 |# D6 uline(0, 0, getmaxx(), getmaxy()); </FONT></P>
* ~: W1 ~7 y1 M& Y0 d<P><FONT color=#0000ff>/* clean up */ - Q; @5 I2 r! X: a6 [
getch(); . U6 Y- ~: e+ b
closegraph();
O0 H2 I' q0 X8 n- Z% \1 lreturn 0;
9 k- g m5 ~! {- \, Y, X}</FONT>
( n4 a- B0 F) X2 d) w' v6 }1 t</P>3 s% U( y% i9 y5 s
<P><FONT color=#ff0000>函数名: _graphfreemem</FONT>
* I2 P& b- p: u6 J% z# h5 p4 e功 能: 用户可修改的图形存储区释放函数
! O' S; W3 O0 I. `/ L2 F用 法: void far _graphfreemem(void far *ptr, unsigned size); , q0 J6 x% e/ g$ m& S! G$ S/ S
程序例: </P>
1 d1 _6 ~$ O+ i& Z8 f<P><FONT color=#0000ff>#include <GRAPHICS.H># U+ P$ M- x; `1 W* j4 o
#include <STDLIB.H>
0 p/ \6 L3 d% }4 Z0 G! ^8 g#include <STDIO.H>
) O! F1 n, P$ ~7 N8 T#include <CONIO.H>' f- P+ K8 X: N$ T5 L0 M
#include <ALLOC.H></FONT></P>4 _' |/ I5 g3 U5 c& |
<P><FONT color=#0000ff>int main(void) 1 e( ^5 d) k! `
{ ( V% {/ U, @9 _" b) T% t ^' f
/* request auto detection */
# C8 T0 O2 t* [3 E/ _. Y& s% q: zint gdriver = DETECT, gmode, errorcode;
2 x( S6 |1 S6 ~4 Iint midx, midy; </FONT></P>
P" s5 y0 B' `& A/ z+ ?# S9 H7 F<P><FONT color=#0000ff>/* clear the text screen */
+ _3 Q8 f' H" P5 a: a3 e" G" Pclrscr();
' j; _9 H0 H' W+ e' S- ?printf("Press any key to initialize graphics mode:"); . L" c# d9 E/ T" T, t
getch();
; Z0 f7 L5 G* ^clrscr(); </FONT></P>
" j% f4 C3 C; o<P><FONT color=#0000ff>/* initialize graphics and local variables */
, h" @0 y8 U+ S) s# T; t& Ginitgraph(&gdriver, &gmode, ""); </FONT></P>
! N* T9 k9 @* S( j0 g& p" Y<P><FONT color=#0000ff>/* read result of initialization */
9 \& r: x) [% e0 eerrorcode = graphresult();
8 B3 R% @7 r1 ~! \6 \3 hif (errorcode != grOk) /* an error occurred */ & [: u3 |2 S1 |3 V- y1 W8 z9 a
{ & ~' d( ?; r* M
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 0 P5 M- J1 |( Y" q
printf("Press any key to halt:");
$ w+ C( n* P9 M% x! P( kgetch();
: D5 m& D4 H% e6 U6 B2 _8 N$ Texit(1); /* terminate with an error code */ % M j* ]' |" v8 a6 A i1 F% H
} </FONT></P>$ M& E; i8 f9 V, {, X5 a3 G
<P><FONT color=#0000ff>midx = getmaxx() / 2;
c7 P* T4 C" Z. y: H0 Xmidy = getmaxy() / 2; </FONT></P>
/ y% f/ F- ] c3 Y<P><FONT color=#0000ff>/* display a message */
4 L3 `4 Z" z; Y R8 hsettextjustify(CENTER_TEXT, CENTER_TEXT);
5 x. d- f/ J! ~) ^6 t2 eouttextxy(midx, midy, "Press any key to exit graphics mode:"); </FONT></P>0 }; v. o. y! H5 t5 i s" M
<P><FONT color=#0000ff>/* clean up */ p: e" Z# X3 N' V7 ` i
getch(); & [6 K! a3 O7 e% {3 [
closegraph();
_# F" P8 O- {5 treturn 0;
: i6 A7 z" D4 G2 [0 i* u# w} </FONT></P>
' b6 h. L. [) Y1 O4 u. h<P><FONT color=#0000ff>/* called by the graphics kernel to allocate memory */ 4 q: W% h H0 P3 T- J# ]! R# w
void far * far _graphgetmem(unsigned size)
4 g3 J( O3 L$ h# i: Q7 d) A{
! ~7 V6 B2 L1 x \ cprintf("_graphgetmem called to allocate %d bytes.\n", size);
% `2 F" h) y1 q+ a* |- T7 g( P, zprintf("hit any key:"); 7 U( a4 M% G! c( L+ A7 d
getch(); ) w0 T8 l* w7 ^5 h
printf("\n"); </FONT></P>8 p* m' E" I0 C: e
<P><FONT color=#0000ff>/* allocate memory from far heap */
% }$ x& \ `8 j9 K( I9 q- y* Breturn farmalloc(size); # f* r3 w* t' x% j) v# p
} </FONT></P>
; A( C1 W: E# f* ]! o" _ K9 i) l<P><FONT color=#0000ff>/* called by the graphics kernel to free memory */ 2 `- J- E' @0 }1 }" J3 _! [
void far _graphfreemem(void far *ptr, unsigned size)
% N, e% O S. d) D7 n* \% K7 a3 l{ 9 I- R' Q2 q. |7 O$ E# C2 R2 m
printf("_graphfreemem called to free %d bytes.\n", size); / j; U8 ^6 X7 S8 p& d
printf("hit any key:");
% H. s$ x% \& j' y& P- X6 Bgetch();
6 t. n( W$ @0 [+ n5 lprintf("\n"); </FONT></P>
) V+ Y# {8 c& b<P><FONT color=#0000ff>/* free ptr from far heap */
1 r/ K& N) s0 w0 v8 o) Nfarfree(ptr);
/ O2 }: W' b, \) Q# u @1 J}
: N, _* \! z6 _' u! u* Q, g! e</FONT></P>
7 o* o" x2 o, J$ m<P><FONT color=#ff0000>函数名: _graphgetmem </FONT>8 n5 q: h# f2 C4 o
功 能: 用户可修改的图形存储区分配函数 # V; }6 M9 o; f- N: B( V" j& B
用 法: void far *far _graphgetmem(unsigned size);
! H7 v7 O5 Q! l+ |/ G程序例: </P>
- ]$ J' Y: k8 Y7 t0 w<P><FONT color=#0000ff>#include <GRAPHICS.H>
+ P. v( @# @) I B+ }9 e; ^0 N#include <STDLIB.H>$ d6 P1 v/ a4 r7 k) x
#include <STDIO.H>8 h; m8 g/ U( a3 [/ x. j- q4 A
#include <CONIO.H>2 M6 I" T( c8 z9 e% s. n
#include <ALLOC.H></FONT></P>" P ~3 m% U _
<P><FONT color=#0000ff>int main(void) 0 u4 P. N. G, M. K0 V. R
{
$ K3 \; ?% {; L) a3 }9 b2 k! k/* request autodetection */ ( o5 B; f# V' X
int gdriver = DETECT, gmode, errorcode; ' N* }; _; g1 q5 d# d$ m! d
int midx, midy; </FONT></P>
8 b7 w @+ O7 a6 P5 ^; L<P><FONT color=#0000ff>/* clear the text screen */ : M$ I& [! H& Q/ }; j
clrscr(); : g/ ~& Z3 `- n2 f2 j; h
printf("Press any key to initialize graphics mode:");
% F8 m c0 D6 i7 k& H/ Zgetch(); % h5 B& A1 E" p2 j9 |( S* ?: \* t9 g
clrscr(); </FONT></P>+ }0 E% T" Q, I( W9 j o U. L+ s
<P><FONT color=#0000ff>/* initialize graphics and local variables */
$ @/ ?" y" Y0 Q0 I7 r2 Jinitgraph(&gdriver, &gmode, ""); </FONT></P>& `1 n4 y: W) ^' u8 a
<P><FONT color=#0000ff>/* read result of initialization */ $ |% B: k2 C) }8 G9 _- N' i
errorcode = graphresult();
4 p, y% |- W) eif (errorcode != grOk) /* an error occurred */ 2 `. Q7 M0 D9 J8 V6 q2 M3 @
{ 9 s B* ], u# Y& i) G _
printf("Graphics error: %s\n", grapherrormsg(errorcode)); - M/ q" p6 F1 f0 Z
printf("Press any key to halt:");
% ^! [- U( @9 e8 g2 \getch();
0 s& _* x& f+ H( _( m) x: nexit(1); /* terminate with an error code */ * W: D" g0 m' T
} </FONT></P>
( a/ ] o/ P5 o2 E9 [# Q$ W<P><FONT color=#0000ff>midx = getmaxx() / 2; ' C$ d! C& B+ B3 ~8 L/ k& C% J
midy = getmaxy() / 2; </FONT></P>' L* F" y5 b! T/ I
<P><FONT color=#0000ff>/* display a message */
4 m- X5 `) F- B: b6 E. i$ Xsettextjustify(CENTER_TEXT, CENTER_TEXT);
7 I0 z) _: l+ ^outtextxy(midx, midy, "Press any key to exit graphics mode:"); </FONT></P># N) |$ o5 A9 o& {" e
<P><FONT color=#0000ff>/* clean up */ ) ^3 N3 J, X. V- s) |. W
getch(); 9 K4 G; r# C+ i5 W( R& p
closegraph();
6 d0 @' n! t; B; B7 y: F# p8 L* }return 0; 2 W/ l, P. ]2 t2 k
} </FONT></P>2 M8 ~5 K8 a2 S3 A% R
<P><FONT color=#0000ff>/* called by the graphics kernel to allocate memory */
. q- \5 ^' ?) ^% nvoid far * far _graphgetmem(unsigned size)
. P% m; P! |; A{ 4 g2 A7 \2 t( G7 }0 ?
printf("_graphgetmem called to allocate %d bytes.\n", size);
! W* z$ \) J3 d0 D6 ~0 Tprintf("hit any key:"); ; q: u" L/ X" o% T
getch();
3 A! P* y6 D" {; Z' Sprintf("\n"); </FONT></P>8 z8 H) } X4 n3 B% P2 p8 @9 U
<P><FONT color=#0000ff>/* allocate memory from far heap */
6 W) H1 f# l; X0 ^return farmalloc(size);
2 s( g1 _( `; c( j' E} </FONT></P>
6 p- r$ Q% p, \7 x4 H<P><FONT color=#0000ff>/* called by the graphics kernel to free memory */
/ z1 V# L3 h: M O/ Pvoid far _graphfreemem(void far *ptr, unsigned size) K4 B+ ~- B _& N$ x
{
. C& r+ u: O6 E* zprintf("_graphfreemem called to free %d bytes.\n", size); 3 i4 n* A" p# i# w
printf("hit any key:");
6 a" P) }4 z, U+ Mgetch();
; U V5 g- U1 i% r: Q4 lprintf("\n"); </FONT></P>
; }; Y% L6 V# h k" ^<P><FONT color=#0000ff>/* free ptr from far heap */ , e: `/ {. h2 J' f6 |
farfree(ptr);
8 w% d" `4 D! i5 Z7 `' f. ?}- P) z- I+ ^+ B% G3 ~
</FONT></P> |
zan
|