- 在线时间
- 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>函数大全(n ,o开头)</FONT></B></FONT></P>% w: _3 Y' p1 o8 e
< ><FONT color=#ff0000>void normvideo(void );( c" O% c' b3 V9 h
</FONT>选择正常亮度字符。
5 \3 H0 _. [+ m7 b将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
) Z- v$ F) {; ~: i4 g1 m% u B4 L+ I3 z! O4 R7 K: f
2 B$ `% _" |& X( O< ><FONT color=#ff0000>void nosound(void );
) X7 Q" R/ G% x0 h0 W5 ~ ?# f1 }</FONT>关闭由调用 sound而发声的扬声器。8 N% \0 r4 x: [& Y& V. G* y1 F
</P>+ d, ]- \& P) Z5 ~
< ><FONT color=#ff0000>函数名: open </FONT>- }; q4 ]( D; D6 b
功 能: 打开一个文件用于读或写
1 D9 p/ A" {5 N& a' L3 F* _, S用 法: int open(char *pathname, int access[, int permiss]);
( b5 y, ?0 D+ M5 x0 m程序例: </P>7 L; t% v4 \9 U9 I. H0 P( z
< ><FONT color=#0000ff>#include <STRING.H> g4 E! } N/ Q2 H& r0 M% ^4 m
#include <STDIO.H>
8 g, b0 W: [/ u) g) y) u+ g- c#include <FCNTL.H>; z4 c2 `" L' G
#include <IO.H></FONT></P>: l" ?7 v* h, e1 a- ?
< ><FONT color=#0000ff>int main(void)
3 c! J, u5 h2 x# w- M9 U5 A{
6 o+ a; ?; M4 jint handle; 3 d9 m; I3 o9 _) `. f9 P2 w
char msg[] = "Hello world"; </FONT></P>
4 Z4 N# d6 H( ~5 w b' d* P2 v9 o4 {< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) ) d7 s: ^% T; o9 X1 t3 G# c
{ + w x- `) t& E+ X- Y+ \: i6 V: X
perror("Error:");
0 p/ o. S5 w7 f( o3 Jreturn 1; + q& h v( r& H1 b& G, o1 M9 }+ O
}
7 {' ]) s; f/ s$ @# O0 d7 `write(handle, msg, strlen(msg));
7 n6 S& w6 c7 m0 ~0 ]close(handle); ' x6 h+ q& \( Z t# n/ P( Q: [% C
return 0; 6 h3 q0 J5 p/ L
} ! }/ l8 u" H7 n9 F
</FONT>
* s5 C/ G# v9 T( B3 A4 ]4 c+ f</P>9 S- s) b# w5 a6 q
< ><FONT color=#ff0000>函数名: outport </FONT>
! h, F3 v1 Q. K* T( R- ~* m功 能: 输出整数到硬件端口中
2 B# ]* h+ B' Y' w: ~) p- ]用 法: void outport(int port, int value); , |: \( F1 x3 ^1 N. P: f
程序例: </P>2 n7 u) D$ f4 b9 S" ]1 r
< ><FONT color=#0000ff>#include <STDIO.H>
% X3 k3 U( K# e# j% i. P#include <DOS.H>
x! G& X! z2 q+ }: y</FONT><FONT color=#0000ff>int main(void)
) _. S# x; \8 h, N, x I5 u{ ! C4 K5 r% r/ O: p6 j
int value = 64;
3 f- v+ W: l( N/ y5 r/ Uint port = 0; </FONT></P>
+ i, z! L3 ?* I* [) N/ H; \7 I< ><FONT color=#0000ff>outportb(port, value); + m% M9 w5 q5 h' b" Z$ ]2 O
printf("Value %d sent to port number %d\n", value, port); " ~. {0 D/ _, \6 `9 t
return 0; 8 @0 y1 k6 g# g- }6 l
} + s6 P0 S; L3 u" c0 h
</FONT>8 o. Z( \$ Z" D) p; c
</P>, Z5 M( I& ^# Z M! d
< ><FONT color=#ff0000>函数名: outportb </FONT>
1 m8 B* F" h; D4 N1 _; n/ ^% d) E功 能: 输出字节到硬件端口中
8 b0 D2 K7 }& S+ l* B1 h用 法: void outportb(int port, char byte); " _, T9 f9 o3 _# r$ v9 \( P, `6 S5 f
程序例: </P>
^0 V& w; P b/ K5 y, |< ><FONT color=#0000ff>#include <STDIO.H>
9 O. D: c( K" h$ i$ C#include <DOS.H></FONT></P>0 ` Y& @2 ?8 m" e: B& Q6 B. Q4 ~
< ><FONT color=#0000ff>int main(void) 9 f8 x) L+ ?) k9 b g, i
{
% p% z* V9 g9 o) f: V% s' B- K9 pint value = 64;
4 w$ a' E: Z2 M" D l+ rint port = 0; </FONT></P>1 f- z9 h% a" t
< ><FONT color=#0000ff>outportb(port, value);
( Z& L% G% d1 S: I1 T( Uprintf("Value %d sent to port number %d\n", value, port); , Y3 I- Z+ g" s6 A* L, m0 w7 @) ?
return 0; / {3 m: u% x. {* A
}
4 g$ E, k( m- W4 {9 `8 S6 {</FONT>6 p4 Z. O, U% L2 U E
</P>/ ^! Z4 X( k V% N
< ><FONT color=#ff0000>函数名: outtext </FONT> T$ B- Z& Y: t$ y" [0 s5 u
功 能: 在视区显示一个字符串 # C6 f2 U$ I5 M- F
用 法: void far outtext(char far *textstring);
9 J. D$ a3 x$ s P/ y! p程序例: </P>
7 \/ `6 ?' a0 B< ><FONT color=#0000ff>#include <GRAPHICS.H>1 ]) |! T7 ~! b/ K( ~" X
#include <STDLIB.H>
8 r0 U3 W9 J l2 B5 U: @% b! z+ A: {#include <STDIO.H>( r) n; r% R& V& H& M
#include <CONIO.H></FONT></P>
* }7 r3 ?* V* r2 I< ><FONT color=#0000ff>int main(void)
5 _, p& T& ]* `# D{ ' l& n) S) f& |8 J3 S4 I7 G. d
/* request auto detection */
% a1 x# D) }- o) \int gdriver = DETECT, gmode, errorcode; 3 J: e. A$ g; m% u) S
int midx, midy; </FONT></P>. P/ K7 E+ S+ `) v) v9 \! \' T
< ><FONT color=#0000ff>/* initialize graphics and local variables */ : `" j; E) ~% E8 x3 l9 r- Z6 n
initgraph(&gdriver, &gmode, ""); </FONT></P>. b* m; C7 k- l Z/ W' u5 _
< ><FONT color=#0000ff>/* read result of initialization */ 7 |9 Z; z/ {& j- c, r
errorcode = graphresult();
( _* e$ D( `$ g$ y# S& hif (errorcode != grOk) /* an error occurred */
2 ^; S1 V, J8 b( Y1 r, |# x0 \{ + P y: l: P7 g
printf("Graphics error: %s\n", grapherrormsg(errorcode));
7 P Y2 {- r8 Q" ^# B6 Oprintf(" ress any key to halt:");
. z- E! y J9 U+ C2 |' d' e" Wgetch(); ; k$ ^! p4 V1 D. q& l# y8 q
exit(1); /* terminate with an error code */
1 [2 ?. b# D/ ~6 ?; i- z} </FONT></P>7 P% ]# S4 P. J' v/ W+ h! A- s
< ><FONT color=#0000ff>midx = getmaxx() / 2;
# H9 |$ r# }, U. ymidy = getmaxy() / 2; </FONT></P>
9 k! G/ `5 {4 V$ |* h2 s! B4 z7 c. ]< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */
6 A) Q+ x8 a- b- lmoveto(midx, midy); </FONT></P>
+ B6 c( N. G5 _* `0 i< ><FONT color=#0000ff>/* output text starting at the C.P. */ ) _; ]3 V8 O- W A- {8 r7 _
outtext("This ");
! [- O, T1 b$ b& j; U0 t! D$ `5 eouttext("is "); % ~+ t1 s! v. G$ g' z8 p2 Q4 T$ m2 v
outtext("a "); : B" L p# |% o/ O5 v; m0 j4 x% d
outtext("test."); </FONT></P>7 W$ C0 a5 w2 p# U* y
< ><FONT color=#0000ff>/* clean up */
: A6 s' U3 U5 i4 W+ qgetch(); 1 f1 l/ M5 g3 V
closegraph();
5 ~' q/ T1 Z- k8 b4 m8 Xreturn 0; 9 ]: f8 \4 v4 |0 x, y
} </FONT>
# Q1 ^3 m0 S$ R& Q& f% I6 I. t$ N: b( U. u" ?; a6 N& u* W; v1 M5 A
</P>( o0 D) @5 U. l" E
< ><FONT color=#ff0000>函数名: outtextxy</FONT> 1 @ \6 }6 T& F; J7 t, q
功 能: 在指定位置显示一字符串
2 Z# N. ^4 ?4 _' L用 法: void far outtextxy(int x, int y, char *textstring); $ I- G5 l% _2 H1 `: d
程序例: </P>( V; B3 f2 k6 L: }. ]6 \+ A
< ><FONT color=#0000ff>#include <GRAPHICS.H>2 ]- A) v+ d8 E5 i
#include <STDLIB.H>
2 x. l4 k( ]9 l# {5 {#include <STDIO.H>- `3 n3 }# k- z4 N% l% m$ [
#include <CONIO.H></FONT></P> _ i. c4 K8 f, ~1 S( \7 p* u/ H
< ><FONT color=#0000ff>int main(void)
9 L7 { Z! x7 Y% u6 ?4 l7 c{ # P. P% D3 w; X
/* request auto detection */ + q8 e" x4 g% O. p1 c8 m
int gdriver = DETECT, gmode, errorcode;
% L" R: s ]. q% Xint midx, midy; </FONT></P>
( ?& X4 G+ S- k& y< ><FONT color=#0000ff>/* initialize graphics and local variables */
X9 c, k6 ~0 W% Xinitgraph( &gdriver, &gmode, ""); </FONT></P>
) J( \) i6 I' r R' S; s/ g< ><FONT color=#0000ff>/* read result of initialization */ * Y3 `! W( D, g2 @3 m6 ^& M
errorcode = graphresult();
- g# H' P# O. e% i- m: a/ Dif (errorcode != grOk) /* an error occurred */
. N5 j2 W. { n2 _{ & y6 s$ O( O+ ?) a! R( E0 _7 a
printf("Graphics error: %s\n", grapherrormsg(errorcode));
4 |% v- m: {+ C& ?+ Vprintf(" ress any key to halt:");
8 G) } ~+ t! k u$ v4 \2 Y4 ~getch(); + k9 W6 ^/ Q) @+ X
exit(1); /* terminate with an error code */
$ T6 c+ d* e4 a1 d5 G; n} </FONT></P>
0 \! }! {5 Z8 |8 V% ]# v<P><FONT color=#0000ff>midx = getmaxx() / 2; + P* q/ O: E9 B# _- g8 y
midy = getmaxy() / 2; </FONT></P>/ L1 u W9 M1 Q
<P><FONT color=#0000ff>/* output text at the center of the screen*/ $ W+ Z. O e7 n. ~# P
/* Note: the C.P. doesn't get changed.*/ 1 t9 o' ^+ E9 }. R6 Q
outtextxy(midx, midy, "This is a test."); </FONT></P>2 @+ z, f( K% C# S3 u) s/ Z, m6 E
<P><FONT color=#0000ff>/* clean up */
z- d( |" a% G% p. wgetch();
7 v5 L6 j# ^2 M$ X9 p, d1 Y dclosegraph();
8 l9 G) z: g L& p7 vreturn 0; - [9 _$ k7 _2 H$ Y
} </FONT></P> |
zan
|