- 在线时间
- 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>
* u5 m, h0 p. J1 P) v< ><FONT color=#ff0000>void normvideo(void );& K2 f! r% b" c5 b0 Y. D7 X
</FONT>选择正常亮度字符。 T4 M2 ~0 Q4 l/ m3 I- L
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>; k' [" X1 {# i
8 D$ ?$ ]1 f- y# X2 q. ^/ i. k- ^4 z/ u8 N+ X& c
< ><FONT color=#ff0000>void nosound(void );
* E! b: W) {5 s</FONT>关闭由调用 sound而发声的扬声器。
2 I$ x1 }& Y, F9 |- O% y: v8 A</P> w2 o, @1 u" h% z
< ><FONT color=#ff0000>函数名: open </FONT>) m x7 w. m5 Q4 S% f I
功 能: 打开一个文件用于读或写
( L+ a% U c1 [1 ?, f& n用 法: int open(char *pathname, int access[, int permiss]);
) p% Q- P" Q- _1 @& _程序例: </P>+ E1 g' @. b: ^( z( {& L' i
< ><FONT color=#0000ff>#include <STRING.H>: Y0 o: R: E% W- u4 U
#include <STDIO.H># o7 P) D. e+ t5 f5 [
#include <FCNTL.H>& l" F v0 D' u3 x: j$ D
#include <IO.H></FONT></P>
7 k; v9 q9 P% r< ><FONT color=#0000ff>int main(void)
$ { M- B3 P/ n) S{ 5 C9 p6 a5 u9 @+ r# K4 s
int handle;
4 K& U& k1 A' k1 {7 W/ Z* z% s: p% uchar msg[] = "Hello world"; </FONT></P>
, p) Y l+ m' U! Z+ B L2 D0 e< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) # _6 ^& U9 j6 F
{ 9 m2 w$ h- X' k. x. X8 ]- Z1 E8 I
perror("Error:"); # N" X5 I* B& a7 c* J
return 1; + }* T- B4 ?8 S$ d7 t
} ! g- A/ b7 L, E/ u
write(handle, msg, strlen(msg)); V2 K. b& z( f" B* A1 a/ q
close(handle); & D" f" t3 {3 M! K
return 0;
) E( G6 Z( v8 v; ~}
; {; B' ]2 M. Z6 C</FONT>
& }% M0 k+ A, F</P>+ E- Y& S. _! p5 N/ j, _
< ><FONT color=#ff0000>函数名: outport </FONT>
7 }+ k/ i! e) K8 m$ C+ U O功 能: 输出整数到硬件端口中
6 D: c: |# H# O& \- l用 法: void outport(int port, int value);
4 z7 Y, ^7 Z k9 g程序例: </P>
4 h1 ^( z0 F! j8 s< ><FONT color=#0000ff>#include <STDIO.H>4 w) F! d5 c' m. p% V
#include <DOS.H>$ R. Q3 t, ^, G
</FONT><FONT color=#0000ff>int main(void)
1 V9 c) ]7 j. O: M) M, @! u{ % {! j4 x) `/ B. M7 J
int value = 64; 2 v# s* o% a) i) M9 u
int port = 0; </FONT></P>
; c" S E5 |# B# Q' k# B" ]< ><FONT color=#0000ff>outportb(port, value); 2 Q$ ?% M4 N2 T6 b& p) a2 e
printf("Value %d sent to port number %d\n", value, port);
+ L l1 O* o* T: n# Treturn 0; 5 t9 ^, D) o- t9 x w5 d3 K2 f
} 5 ~9 A' R z7 s3 N+ Q
</FONT>
6 F8 r/ c2 L6 ]# [) S$ i</P>
/ f: u' w4 P9 G# [9 B< ><FONT color=#ff0000>函数名: outportb </FONT>* W( G+ d* \* p4 c' f0 r6 a: j5 L
功 能: 输出字节到硬件端口中 ! O9 [- L( ~4 f/ |1 q- t; s
用 法: void outportb(int port, char byte);
" d5 g) z Z8 W* U. c* c8 j8 K程序例: </P>" B& z% h0 {! ?. i9 |2 n
< ><FONT color=#0000ff>#include <STDIO.H>8 b- R" }3 Z# F
#include <DOS.H></FONT></P>6 E4 v: L; P# Q) q
< ><FONT color=#0000ff>int main(void) : T! H% |7 F) f1 H' C
{ # N4 @* I. J! j& b6 u) p
int value = 64; ; b! \0 n8 C5 y/ S% E2 I* j4 J, T% I
int port = 0; </FONT></P>
# Q2 Y! j+ a9 S< ><FONT color=#0000ff>outportb(port, value); / C2 N* k6 E/ V& ?
printf("Value %d sent to port number %d\n", value, port);
R/ S" s8 \; d# @* `3 Treturn 0; ; X( D: K1 l" K
}
2 ?7 ^7 @! x5 @& h5 j</FONT>; ^4 y v8 U/ v& P: I
</P>: Z2 a9 l# @2 _7 V' x& Y+ f
< ><FONT color=#ff0000>函数名: outtext </FONT>; j8 k7 m# G3 Z9 \& p
功 能: 在视区显示一个字符串
* i' v, }9 z% ~' a用 法: void far outtext(char far *textstring); 3 s2 L2 }5 V3 {4 {% d
程序例: </P>5 c: @4 p0 Q5 S2 \( ~
< ><FONT color=#0000ff>#include <GRAPHICS.H>) p$ m9 n% r0 A
#include <STDLIB.H>
# w2 Z$ M: F Q# Q#include <STDIO.H>
$ o& t% X% _5 ^#include <CONIO.H></FONT></P>
! B; s7 l# d8 x4 @! o, i/ d: Y< ><FONT color=#0000ff>int main(void) ; ^* V$ \1 G# D; w* [& n. o
{
1 G# }3 D9 S1 |. _/* request auto detection */ 2 N' `! ]3 b4 Y% D+ b3 w8 s0 a
int gdriver = DETECT, gmode, errorcode; & d. g, `( Q. B' W d
int midx, midy; </FONT></P>1 R8 Q8 }! D" [: L3 ~
< ><FONT color=#0000ff>/* initialize graphics and local variables */
' {6 x, n3 N- o0 winitgraph(&gdriver, &gmode, ""); </FONT></P>) T6 O; w; ^. o
< ><FONT color=#0000ff>/* read result of initialization */ , g! l; h+ G! U6 q
errorcode = graphresult(); 5 I4 y. k* ]/ ~* A0 C2 N3 v8 L
if (errorcode != grOk) /* an error occurred */ " t% _5 ^0 j5 r
{ , w4 v- m e, `5 ]0 `) f) l
printf("Graphics error: %s\n", grapherrormsg(errorcode)); a7 @4 _& @5 H. C. ?
printf(" ress any key to halt:");
- {+ {0 d6 Q" V9 p, _" Mgetch();
' p* {& [3 C1 D5 m! u6 fexit(1); /* terminate with an error code */ 5 D6 m# ]0 O0 I% m& ~) S; D
} </FONT></P>8 s( k8 U" w" Q% x3 H5 k
< ><FONT color=#0000ff>midx = getmaxx() / 2; 7 N$ y- {- R: z# n
midy = getmaxy() / 2; </FONT></P> F: |, {! }5 q2 C+ l i( m
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */ * r7 u1 s* y0 d9 H
moveto(midx, midy); </FONT></P>8 d+ e2 [8 O5 Y
< ><FONT color=#0000ff>/* output text starting at the C.P. */ & A5 t; V5 \! Y+ Q! e
outtext("This "); N3 J% M. t$ _0 v& }
outtext("is "); 1 ~5 v [. k5 j, m6 c
outtext("a ");
$ X* R: {+ \" } Nouttext("test."); </FONT></P>
# s% t! y+ C+ V$ |% w; n. U< ><FONT color=#0000ff>/* clean up */
A: P- u, U8 z8 L# Wgetch();
~, W3 d: f6 u2 u4 ~closegraph();
8 v- m; ^- o4 k' i3 C; R# |& creturn 0; 4 _: X. Q4 m, t I7 e7 ~
} </FONT>
, D- K# X& [6 W3 c8 j6 v5 Q: s8 e0 U- t3 t( s* y
</P>
e2 E y6 M u& u: ~1 u l< ><FONT color=#ff0000>函数名: outtextxy</FONT>
0 p- S* W$ l) D2 k功 能: 在指定位置显示一字符串 / [2 R+ |& d0 J8 A% C+ {
用 法: void far outtextxy(int x, int y, char *textstring); : j& q. @3 d0 P+ P" L7 K
程序例: </P>
5 d! O- s0 |; S4 M1 o% M< ><FONT color=#0000ff>#include <GRAPHICS.H>
5 N& S1 g2 v( B& n0 W#include <STDLIB.H># N+ \2 T' f% X/ ?+ `$ X) G
#include <STDIO.H>/ V& v6 A/ }$ o1 z
#include <CONIO.H></FONT></P>
' _) j/ S$ [1 M< ><FONT color=#0000ff>int main(void)
' n) V) W6 A, S" ^ `{
8 V9 F. K; f! `5 @/* request auto detection */
4 y' h" v7 l: A* uint gdriver = DETECT, gmode, errorcode; . b s5 G8 J1 S. I
int midx, midy; </FONT></P>* M2 h% M( L# G- d- D7 M+ d3 k5 C
< ><FONT color=#0000ff>/* initialize graphics and local variables */ 2 L0 i6 G( J" ~
initgraph( &gdriver, &gmode, ""); </FONT></P>) g% `& V; _' F9 P" i1 ~% k
< ><FONT color=#0000ff>/* read result of initialization */ # e' K' E/ i1 q! a% F' X" L \
errorcode = graphresult(); 7 W% O- P* _. A/ X4 G2 N' J% Y
if (errorcode != grOk) /* an error occurred */ ! U3 r G) i# ?& s+ W) @1 c4 E5 H
{ 2 ^6 V8 p+ V) |
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 6 I6 b; \7 b4 t( h/ t$ C5 L- D- B# ]
printf(" ress any key to halt:"); , ?: [* d! G) o* v# v- [ c' M3 V
getch();
9 I7 Z3 E$ o4 L/ j7 o2 Qexit(1); /* terminate with an error code */ + Q$ k K4 S/ K6 F" A4 ~
} </FONT></P>
' k$ v! m' n( s+ k7 M. A" h7 t6 P<P><FONT color=#0000ff>midx = getmaxx() / 2; 2 N Y; V3 ~/ @( R; j
midy = getmaxy() / 2; </FONT></P>2 S, Q! O3 c/ ]
<P><FONT color=#0000ff>/* output text at the center of the screen*/ 5 {2 u2 N" Y. m
/* Note: the C.P. doesn't get changed.*/
: L. X% w; P/ _& z% j7 |; Uouttextxy(midx, midy, "This is a test."); </FONT></P>7 B) Z3 V+ f" X6 u) J
<P><FONT color=#0000ff>/* clean up */
# T7 r& T$ M1 n' l4 Agetch(); . {1 v+ ]% J8 u
closegraph();
# ^) r4 d( N0 J0 P6 Q. H; {! I0 U0 ]return 0; ) u: b# F& d6 M+ i4 a! ^/ M# F
} </FONT></P> |
zan
|