- 在线时间
- 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># \- f9 X! @ s# p; f
< ><FONT color=#ff0000>void normvideo(void );
8 ^ n( O* h0 [9 ^' I* y. p</FONT>选择正常亮度字符。( m9 f4 n$ Q" I. E) e. j
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>* W0 J, L# u1 ?9 @
/ O3 t6 r$ T7 C9 ~$ l) X
" Q* ?' J+ I4 v6 U4 Z< ><FONT color=#ff0000>void nosound(void );8 U; i6 r% A0 {' n
</FONT>关闭由调用 sound而发声的扬声器。
9 G) F# M0 M( r$ ?* c( C</P>; x( i# o/ M+ w4 k0 T& s7 @
< ><FONT color=#ff0000>函数名: open </FONT>
% o0 D7 W1 t6 I# n9 z3 J3 ] O功 能: 打开一个文件用于读或写
' Q% _% @$ K) Z3 k7 [/ e3 y用 法: int open(char *pathname, int access[, int permiss]);
# {( u0 f8 a% q) K/ t$ N8 C# v1 I程序例: </P>% ~2 F4 o: V- M+ U0 M* b4 p
< ><FONT color=#0000ff>#include <STRING.H>
/ g% x* ]$ ]2 @3 N# Y#include <STDIO.H>
& J/ F2 r( d8 _2 b0 @#include <FCNTL.H>! O- S! q2 E4 T9 q$ T5 _) f; R
#include <IO.H></FONT></P>/ m) I; B9 e4 p
< ><FONT color=#0000ff>int main(void) 7 S. q5 }' |* a( Z, @' |
{ 9 f$ @" ^: O _/ l' C$ N
int handle; $ J% T3 @+ E. B. b
char msg[] = "Hello world"; </FONT></P>% k3 r6 J1 t- p& j* U+ f) _' y
< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
3 ] S! y7 _' y! L. P7 Q+ X{
. ?3 @) @3 r9 [6 i% T+ zperror("Error:"); ! b' d* k u& x3 h [* C
return 1; 3 g6 L- |, j7 q; z# K# }0 Y8 h& ^6 Y
} % q) q9 e R8 Q' Y9 ?/ f
write(handle, msg, strlen(msg)); ' f+ J E2 B% P! j& {/ ^2 ]
close(handle);
. u! d* ]/ M8 l* T' \# K \return 0; ) N' G3 {& X) V3 F z
} 0 ?! g/ Q% H0 A" Z
</FONT>
$ B. V4 ^8 r( ^3 p$ A! X</P>8 l" A+ v+ `7 ], o+ m; u
< ><FONT color=#ff0000>函数名: outport </FONT>
6 w- ?. A1 U. D7 `8 M, Y5 l5 l功 能: 输出整数到硬件端口中 7 D% M% x0 `8 e9 C& ^) d& i
用 法: void outport(int port, int value);
# b% @% ]4 D V程序例: </P>8 I1 x9 z1 A& ]1 c* V6 v; }- E
< ><FONT color=#0000ff>#include <STDIO.H>) c+ o1 b2 ~* g8 ]3 }
#include <DOS.H>
0 n4 @, l: x) i9 e- a e</FONT><FONT color=#0000ff>int main(void)
4 H$ I5 n+ }& V7 Q: S1 `! }{ 2 D* ^2 G7 D$ K4 [) e# Z* I; a Q2 u
int value = 64; ( x5 _: k3 v3 U' |% f( n) f8 N$ k; _
int port = 0; </FONT></P>
3 K: R! O, q7 p1 y3 V2 e< ><FONT color=#0000ff>outportb(port, value);
, o6 A, c6 k0 s# f; jprintf("Value %d sent to port number %d\n", value, port);
2 p. k% p" G3 s+ C: Yreturn 0;
' T% b! O% g* ]3 `: F' a}
5 V- n% }- a: b2 `. _* M8 R- w. P</FONT>
0 m9 @6 o; @4 j; c2 P) @</P>
$ o7 D+ |: D# T' N, N9 ?< ><FONT color=#ff0000>函数名: outportb </FONT>8 u9 L% K* W# }1 F/ J
功 能: 输出字节到硬件端口中
8 q( g. D% {8 I$ M/ z用 法: void outportb(int port, char byte); {8 `4 Q! O2 H% d) g
程序例: </P>' j* t3 e/ j' e: _& }
< ><FONT color=#0000ff>#include <STDIO.H>+ D, j9 y# w a* N) E
#include <DOS.H></FONT></P>
- {" I; @! N! Z. S< ><FONT color=#0000ff>int main(void)
. o8 D2 |% W2 X# D1 y{
# l+ s5 d3 g# Z8 u5 p5 ]: e; \- Cint value = 64;
/ ?9 b9 l* q ?' N% s, Eint port = 0; </FONT></P>1 O6 K2 U" z) w# \
< ><FONT color=#0000ff>outportb(port, value); 4 A+ D" m6 Z7 y5 C3 n, M
printf("Value %d sent to port number %d\n", value, port); 2 s7 B t# \* e
return 0; 5 N: `' j4 C8 R. m3 Y) ^
}
- {, F5 H* P- D, l</FONT>
% Q7 r+ _: m: O! W1 R</P>
, M0 m3 k4 F2 C, C' }7 ~. ?- ]* y s< ><FONT color=#ff0000>函数名: outtext </FONT>
; M# v. _# B: `; `功 能: 在视区显示一个字符串
( ^! r( ~$ V \4 s1 a& k用 法: void far outtext(char far *textstring);
+ t, q/ B; V! A3 Q: t$ T: o4 f程序例: </P># K k! l4 D4 m( P7 r$ l: _
< ><FONT color=#0000ff>#include <GRAPHICS.H>
# M( E% A/ E2 c) M F; _8 w#include <STDLIB.H>6 U. {3 {! l6 B
#include <STDIO.H>
3 }$ j( r( C5 m9 x f, J#include <CONIO.H></FONT></P>
* n% k6 g* X# l7 T7 q( a7 V o< ><FONT color=#0000ff>int main(void)
0 O8 D# l; \9 t& m! a{
1 C, g: F4 B# t) n7 R/* request auto detection */
6 D4 D( F: k8 u6 h2 u& }- Nint gdriver = DETECT, gmode, errorcode; ( L6 w. J" f8 ^5 i8 H c% J5 C
int midx, midy; </FONT></P>% s9 h+ Z8 y5 ~8 u0 p+ P
< ><FONT color=#0000ff>/* initialize graphics and local variables */
' Q2 V+ h, G0 P5 ]* g/ ninitgraph(&gdriver, &gmode, ""); </FONT></P>
! @! f6 o# J6 `< ><FONT color=#0000ff>/* read result of initialization */ & L% Q( V: r1 U8 t7 g
errorcode = graphresult();
) k9 f9 ~ `- e7 O: L' rif (errorcode != grOk) /* an error occurred */
W: R1 t! @# z2 o9 f( O# ~& [{ " |3 f/ T- F: D
printf("Graphics error: %s\n", grapherrormsg(errorcode));
% x+ v+ p, R, [. l0 |2 B. eprintf(" ress any key to halt:");
! N( Q6 H) H, u, M+ J% P" Zgetch(); 8 E7 m- V) X0 ]1 N3 Z& j
exit(1); /* terminate with an error code */
9 Q9 b; Y- k4 T1 S1 E7 F} </FONT></P>
+ | }, J. B$ D4 c0 V( l& F< ><FONT color=#0000ff>midx = getmaxx() / 2; - u4 ?# y; c r- q1 j
midy = getmaxy() / 2; </FONT></P>' n; X( e; K" t4 T, {) z
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */
+ m* J* u& ?9 [/ c/ q8 Ymoveto(midx, midy); </FONT></P>; b, f2 b6 N0 S- s' i# u
< ><FONT color=#0000ff>/* output text starting at the C.P. */ 9 j1 ~8 v/ n7 Z( y
outtext("This ");
" b! b5 m! @% d' I% fouttext("is ");
8 n* Q8 y( \% D' Mouttext("a ");
, K+ ?: @" h3 h- _$ _outtext("test."); </FONT></P>
4 | V( O6 v9 T) E# E< ><FONT color=#0000ff>/* clean up */ . Z2 S# W0 h! G
getch();
. s! z4 C; U0 r! j* _( }closegraph();
. m. ^0 k" z- D3 v# S) o3 Xreturn 0; 7 _1 l9 M0 ?( ] I' M9 j
} </FONT>) l- B% H3 k9 A! D5 ~" R
, [# @- I, o% o, H4 \
</P>
4 E% N# l9 X1 Z: Z6 k J7 M< ><FONT color=#ff0000>函数名: outtextxy</FONT>
6 ?4 `$ |- q0 W3 w% P& V% l功 能: 在指定位置显示一字符串
0 ~. ^, J9 n+ }, g用 法: void far outtextxy(int x, int y, char *textstring);
6 L' \4 t5 u4 {" f6 C- T程序例: </P>
* h2 `# Q/ o" l& v2 S< ><FONT color=#0000ff>#include <GRAPHICS.H>: Y: ?7 W Z0 w# h% U" a
#include <STDLIB.H>7 t4 h5 g1 Z6 ^, P, d4 `; E9 C
#include <STDIO.H>
: z6 F' e% ^2 D/ I) A4 l; X. l: a#include <CONIO.H></FONT></P>
( ]7 v/ {* f5 l- r- e< ><FONT color=#0000ff>int main(void)
/ _! r! G& R8 R4 X{ # k" k/ E% S! L
/* request auto detection */
7 L; B% `; ? s, F% Oint gdriver = DETECT, gmode, errorcode; * S2 ^1 q( _( ?$ s4 M
int midx, midy; </FONT></P>* ^6 [7 Q) B- h- q
< ><FONT color=#0000ff>/* initialize graphics and local variables */
" J1 S9 R8 Q( j5 j0 Yinitgraph( &gdriver, &gmode, ""); </FONT></P>
- H2 p/ z D# O3 i/ y< ><FONT color=#0000ff>/* read result of initialization */
. y& y2 y U Y( g- Z5 Kerrorcode = graphresult();
D' S. I' I& Iif (errorcode != grOk) /* an error occurred */ ( u9 \* x- A$ r$ N3 W+ z# C# o
{ 2 c }0 J6 @9 n7 Z% ~
printf("Graphics error: %s\n", grapherrormsg(errorcode)); # H6 J, r. s2 y4 N8 n& S, [
printf(" ress any key to halt:");
6 Y A+ R5 ~+ qgetch();
! }# R$ f" o* G1 b& b. iexit(1); /* terminate with an error code */ 3 u/ ]: y8 W3 ?/ U U
} </FONT></P>$ n" M% ^. @) v8 ~
<P><FONT color=#0000ff>midx = getmaxx() / 2; `4 P- D/ h( G3 q4 b: h$ g
midy = getmaxy() / 2; </FONT></P>
: g0 \( r- T5 m& ~<P><FONT color=#0000ff>/* output text at the center of the screen*/ p8 m, {6 \# S; @2 l
/* Note: the C.P. doesn't get changed.*/ ) o2 L6 t2 e. h9 l: A4 H8 R7 F
outtextxy(midx, midy, "This is a test."); </FONT></P>; U( @' V/ F8 J( J- y2 b
<P><FONT color=#0000ff>/* clean up */ 4 X+ D U& g9 W# i
getch(); ' @" J% W4 f0 g% t% A4 v
closegraph();
5 H; | i$ s% ]8 ?( x$ lreturn 0;
0 N) k$ o6 Z" R+ A! A} </FONT></P> |
zan
|