- 在线时间
- 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>! t# r5 y7 Z+ a1 _2 i
< ><FONT color=#ff0000>void normvideo(void );/ X3 l% }9 p& w# D( |
</FONT>选择正常亮度字符。
/ E5 b4 H& ^, o将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>; K' F6 n1 {; ?4 E
: ~6 \5 b3 V7 q: q7 q
- \5 U$ @5 Q, i( R
< ><FONT color=#ff0000>void nosound(void );
; u4 ^6 v. c0 j- m2 v' ]</FONT>关闭由调用 sound而发声的扬声器。3 h' A8 z4 z+ ~& V9 S( s+ p6 d/ \$ I
</P>
) `, U& m L# u+ \< ><FONT color=#ff0000>函数名: open </FONT>
3 t0 C# w: K' }1 `- u2 V: A) G功 能: 打开一个文件用于读或写 ) `" S) G. r7 I, Y: S! z+ ?' ~
用 法: int open(char *pathname, int access[, int permiss]); ; W( @$ ?3 N) Q' E; I9 O
程序例: </P>
3 [- p& `/ m0 J! X% T< ><FONT color=#0000ff>#include <STRING.H>
4 S; ~9 J9 S& a#include <STDIO.H>- n! [! V) P$ I$ K' m* f+ f8 V
#include <FCNTL.H>
# g! A; g4 ~9 c#include <IO.H></FONT></P>0 I$ D X" r. b1 c5 ^% c
< ><FONT color=#0000ff>int main(void)
$ L4 [: `3 i; A- f/ }{
3 z6 s5 V/ w0 k7 Y: A5 K! {! tint handle; ; x$ F8 r: g t" ^( r7 d
char msg[] = "Hello world"; </FONT></P>
1 [. M8 F% B# v! J' k4 H7 ~2 ?- f< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) # {+ ?* A9 \, ~2 J9 R$ g8 I- v+ v
{ 8 U' t# X+ e9 d8 ~
perror("Error:");
2 o; i; U& V6 _0 q. ?2 w. Freturn 1; 2 i& u% G. d6 ~0 u1 t* r7 j
}
6 q7 z: m# V' [9 D: Jwrite(handle, msg, strlen(msg)); , V3 O! z# d- N2 r" d2 e8 Q
close(handle); 0 `. y! `/ w% _# S# Z: U
return 0;
5 T7 G, X" l' O3 u6 B} ( m2 n3 X5 w! c, }0 O5 a+ `8 N
</FONT>
/ e- U p3 ^! f9 L# w3 U' t</P>2 t6 m1 W4 R0 n, \# ]: W! j
< ><FONT color=#ff0000>函数名: outport </FONT>
7 P! U t4 F t4 P ^ o( n/ m' c功 能: 输出整数到硬件端口中 ; [1 L9 b) D% I( j
用 法: void outport(int port, int value); ; j' M$ Z: b2 J( h
程序例: </P>) i3 g; V6 z. _ E2 t) H& b: u
< ><FONT color=#0000ff>#include <STDIO.H>
+ c, B' r! D3 }* N; c- d#include <DOS.H>2 t% y5 `, H1 o- e+ Y
</FONT><FONT color=#0000ff>int main(void)
6 p. P0 p0 S9 C$ F' M7 |# r{
. V$ m# e+ e6 Pint value = 64;
4 s2 `: t$ n& Z6 ~* hint port = 0; </FONT></P>
: l8 u1 I! o: J- x& z& J< ><FONT color=#0000ff>outportb(port, value); + P$ I& I) X- E% p5 g8 p
printf("Value %d sent to port number %d\n", value, port);
( t( B, G: R9 A. I& M8 sreturn 0;
* A1 i0 g3 v S' N& G2 g- g}
3 w& d5 w- Q! L* h: c2 X+ R</FONT>
; z/ B! n' A0 r" r( b</P>
5 t8 z& _' b# i' o1 \) H! I< ><FONT color=#ff0000>函数名: outportb </FONT>! c. k+ B' e2 m. N' ?2 i
功 能: 输出字节到硬件端口中 * ?) d- M1 V1 h$ X1 m4 R
用 法: void outportb(int port, char byte); ! {+ o2 V& @% q9 q+ i# }1 n
程序例: </P>; u& s* w. D& |4 k
< ><FONT color=#0000ff>#include <STDIO.H>/ \2 Q9 C, [2 g: }+ F: ~% p1 c
#include <DOS.H></FONT></P>, f1 G. q, Y* E% f9 t
< ><FONT color=#0000ff>int main(void)
% P- r k4 J% E. U7 k, c/ |, S{
4 X! _5 z! t& M9 C- V% xint value = 64; : n5 V$ N+ R$ V3 T. F+ A' L
int port = 0; </FONT></P>
8 P3 e5 p. x, O< ><FONT color=#0000ff>outportb(port, value); 2 i! L. a, ^- d4 t5 ~1 e! U
printf("Value %d sent to port number %d\n", value, port);
& f/ @ ^2 G7 d8 m( }return 0; 7 S3 E: b$ p+ @- U6 u# V
}
1 T" l$ L* ]5 O" ]4 s* o</FONT>
0 G( o" w& m. y1 i4 K: O! U: H</P>( i& t. W7 Y z
< ><FONT color=#ff0000>函数名: outtext </FONT>; b% e2 h" x/ c6 \8 \
功 能: 在视区显示一个字符串 - u" v$ b& N5 |+ }. ]
用 法: void far outtext(char far *textstring); 8 N% u, G! Z9 B, j
程序例: </P>' g$ s$ x, U' P7 P3 `
< ><FONT color=#0000ff>#include <GRAPHICS.H>
& i- f4 C+ b e9 B6 \+ m5 P#include <STDLIB.H>
7 l- K" w: _% [, M5 M#include <STDIO.H>
) [+ Q V' |; w* [8 P3 ?: ? ^& B( \. o#include <CONIO.H></FONT></P>: m% v# q0 ^$ T! M6 V, h" u
< ><FONT color=#0000ff>int main(void)
' }4 w0 I* a2 B/ x8 L0 u, X! @{
7 Z) Y; @: b' x) c \, h2 r/* request auto detection */
; N% c n# M5 _/ H! yint gdriver = DETECT, gmode, errorcode; 8 r7 Z2 H3 x" P# h
int midx, midy; </FONT></P>
8 E. E5 ^5 ^6 V% p8 c. b5 D< ><FONT color=#0000ff>/* initialize graphics and local variables */ 2 @) i0 U9 v, t& {$ n
initgraph(&gdriver, &gmode, ""); </FONT></P>0 |& i$ l2 p8 @: |1 Y+ H+ s
< ><FONT color=#0000ff>/* read result of initialization */ # t6 Y* G% w+ _) o; B) d+ E
errorcode = graphresult(); + X! J: a0 ]# ?5 v/ F u
if (errorcode != grOk) /* an error occurred */ ' v; a- A" d& p" {, M H J- o1 q7 W
{
. D/ c: {; F, r# m5 v3 s8 iprintf("Graphics error: %s\n", grapherrormsg(errorcode)); ~/ o" O9 |; a" v
printf(" ress any key to halt:");
9 h) j8 a( Z2 J- j' I& Tgetch(); 3 v/ H0 w' R7 N$ b- M; V
exit(1); /* terminate with an error code */ ( M; @5 q2 }0 a% s4 b
} </FONT></P>
2 A0 q3 u% ^4 s! P2 c< ><FONT color=#0000ff>midx = getmaxx() / 2; 6 `% V; t" l9 H% K0 h$ d0 q- J. L
midy = getmaxy() / 2; </FONT></P>, K1 U$ f& O4 W" `1 h- m
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */ / u3 s1 \! C& y* d0 m) Z( N
moveto(midx, midy); </FONT></P>
" T6 z9 O! w: h1 z2 ]8 O6 p< ><FONT color=#0000ff>/* output text starting at the C.P. */
9 U: @, Q9 l6 E* M6 uouttext("This "); R: J& Q# ~# X
outtext("is "); ( E ^. e. o$ a
outtext("a "); ( V+ z: Q' Q% S6 Q
outtext("test."); </FONT></P>
' i4 I" B4 ?6 I5 f9 H< ><FONT color=#0000ff>/* clean up */ " l9 c) ?8 P4 M
getch(); * E% `8 i7 W% ]. I
closegraph();
9 Q, n9 f, h3 W; ireturn 0; & u- h2 {4 x" i
} </FONT>! z) ~2 ~: j* r/ P
" t! _0 [8 N0 B+ x! R l</P>
T4 T" c+ I' H' Q( s# o8 V3 X1 u< ><FONT color=#ff0000>函数名: outtextxy</FONT> ! p+ H+ G: r% x3 n0 i/ V( N0 v% T1 j
功 能: 在指定位置显示一字符串 + G5 O0 O |+ f [8 d2 \/ T& g
用 法: void far outtextxy(int x, int y, char *textstring);
1 @8 I" l9 |4 K* k# [ Z9 {程序例: </P>( P4 s% Z2 {& q% u6 i& O
< ><FONT color=#0000ff>#include <GRAPHICS.H>
" p. ]5 D& q+ a3 K2 N' e! K#include <STDLIB.H>1 }/ ?: N' h3 Y" j, @
#include <STDIO.H>- ?5 n+ C: f6 u X! D
#include <CONIO.H></FONT></P>. H! r B" P. \- ~+ a
< ><FONT color=#0000ff>int main(void) ) l/ g; A# T, N4 l+ j
{ ( e4 s# u- S X& }" c9 F
/* request auto detection */ * \$ Y' D! Z7 F
int gdriver = DETECT, gmode, errorcode; ) B0 C" f, B1 p3 o9 {
int midx, midy; </FONT></P>
9 Q) n. F, Z+ e& R0 `$ ~$ S6 u G5 K< ><FONT color=#0000ff>/* initialize graphics and local variables */
5 Z$ q4 y0 ?( u* H d0 c j3 kinitgraph( &gdriver, &gmode, ""); </FONT></P>3 z& `/ S6 z& L! D' i- H2 \
< ><FONT color=#0000ff>/* read result of initialization */
7 F5 s" {5 f( F8 d Derrorcode = graphresult(); ) d- ~. f: @, a" I P- H
if (errorcode != grOk) /* an error occurred */
5 ^$ M/ _7 x6 H5 z{ 1 l6 _* O# z! E
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 8 u# l& l( x' z6 f1 h, N* _' R
printf(" ress any key to halt:"); - M' a2 u) _4 o' t" G9 y& t! s7 u3 o
getch();
# E' q4 Z- k$ N' L2 Aexit(1); /* terminate with an error code */
: R* z% H3 v- x: ]" U} </FONT></P>
: h: [6 ?1 @; b& ~7 y3 o3 \<P><FONT color=#0000ff>midx = getmaxx() / 2; G ^6 ]1 T+ O+ p1 Q
midy = getmaxy() / 2; </FONT></P>1 `! c- o" s7 [0 H' n9 p. p
<P><FONT color=#0000ff>/* output text at the center of the screen*/
: Q1 ?; E/ g, |6 B! i0 b U6 A/* Note: the C.P. doesn't get changed.*/ 9 O& a1 U. J' }3 }) ?
outtextxy(midx, midy, "This is a test."); </FONT></P># \4 p( `. G: b9 g
<P><FONT color=#0000ff>/* clean up */
7 `8 O. K j1 O# t E$ ]getch(); / m/ M* v8 U* X1 m3 V* `! O) m
closegraph();
- f% a& A/ T; ^' w+ J3 e, H2 Breturn 0;
6 l# A' h: t8 n/ u} </FONT></P> |
zan
|