- 在线时间
- 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>
X8 Y; z3 ?" n- Y8 S< ><FONT color=#ff0000>void normvideo(void );
# ~6 [8 C5 _, Y+ w6 |" _</FONT>选择正常亮度字符。
' f' S5 N ?% l将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>9 j F2 F6 X! l
1 I* C6 x. l3 {, I: f/ J x1 q, X5 u8 k1 W' t
< ><FONT color=#ff0000>void nosound(void );+ z9 k6 Y- n2 I4 @& p* V
</FONT>关闭由调用 sound而发声的扬声器。
! [6 x0 E; V* u& o z</P>: a9 S1 Z; n6 t. x
< ><FONT color=#ff0000>函数名: open </FONT>) l( Y i6 x4 G! u" J; w
功 能: 打开一个文件用于读或写
. Q6 F: L. R. \5 e用 法: int open(char *pathname, int access[, int permiss]);
6 }2 W2 O* L" {8 Y& u& v程序例: </P>
- t) ~* \% v* }2 y P< ><FONT color=#0000ff>#include <STRING.H>
* F6 p0 k# f. T/ r2 }. ~( M& ~; D#include <STDIO.H>1 _% V# U, Y* Y. g+ Q
#include <FCNTL.H>, [/ t) A | ?. P0 H
#include <IO.H></FONT></P>5 |: u! P8 K% W# I3 l3 [' r5 |
< ><FONT color=#0000ff>int main(void)
7 ~5 u: ]( d: {8 w9 ^/ p0 w{ 0 `* }* r$ i" }* e) V3 E1 ~- A6 k
int handle;
t1 N9 J$ J/ W' ]- D" L1 Y: cchar msg[] = "Hello world"; </FONT></P>
! k2 q- g1 i2 q# ?. n% n+ l3 f< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) - L8 j/ P9 ?0 {; S# v3 n& V
{ $ O2 C: K& l0 H3 g% D. }; B7 r! M
perror("Error:");
- `& S6 d% ^$ Z! l5 J2 rreturn 1; 5 I! h. Z* `2 r" @4 b5 G. G
}
1 P) Z% K' u, L6 S* w% owrite(handle, msg, strlen(msg)); 6 D) {/ L4 V8 a$ T
close(handle); 3 J& c) U k+ V+ z
return 0; g6 |, B0 N# |/ _
} " ?6 u" B. N- B- @) k; f9 [
</FONT>3 [1 ^( i* T: T9 b" ?
</P>- V+ @# m$ U' [; T
< ><FONT color=#ff0000>函数名: outport </FONT>7 {' ^% r- e$ M, G: T
功 能: 输出整数到硬件端口中 % b# E+ j$ [- f/ l% |! h' E% U
用 法: void outport(int port, int value);
. w+ ^9 h8 h- R; q/ `) d程序例: </P>
: P! W, ]6 u2 x/ \1 n8 n< ><FONT color=#0000ff>#include <STDIO.H>
; ?' p+ U u! z x) \#include <DOS.H>% y% q: N8 A6 D* M) e# R( L/ R
</FONT><FONT color=#0000ff>int main(void)
5 |6 e+ ]" M7 I5 h0 D, u{
1 w0 \- P$ z7 W- I7 R1 R6 Z# fint value = 64; 3 L$ Q( j1 |0 p1 [. P
int port = 0; </FONT></P>. V- }! U9 w1 l3 ~3 n: m# q
< ><FONT color=#0000ff>outportb(port, value); 8 C9 W. G; V8 O5 G
printf("Value %d sent to port number %d\n", value, port); N9 F& Q ]0 Z( a, t
return 0; + N7 W( m6 \7 _; D, G& m+ b
}
" f! [" j& A o) h g4 ~</FONT>
' P- G) P- R- O: O. |/ N' V</P>! `5 @. ]) C# r: U, u/ y$ t' f
< ><FONT color=#ff0000>函数名: outportb </FONT>
; d1 ^5 j; U4 e1 \" }1 f. v功 能: 输出字节到硬件端口中 & u8 A' U8 ~/ A Z) f5 N
用 法: void outportb(int port, char byte);
# l8 p9 r+ a5 j% J程序例: </P>
+ u: o4 k; s$ Y9 R9 r+ Z% w5 h% X< ><FONT color=#0000ff>#include <STDIO.H>
( A4 q5 l; \; o* z# Z$ f5 p" e# ^#include <DOS.H></FONT></P>
" I+ m. }( X: a, w% X* R( W< ><FONT color=#0000ff>int main(void)
# O+ d. ]# D u% z/ c7 D{
+ B+ H' E4 F& A' a) d) e" ~+ p5 v' mint value = 64; r( V3 _& ]& W* E \
int port = 0; </FONT></P>
& Y! N( b0 A' f- G* U [< ><FONT color=#0000ff>outportb(port, value);
" k" Z8 f c5 ^2 Jprintf("Value %d sent to port number %d\n", value, port);
+ e# X9 e2 o( u1 ^- h0 H2 g1 `- qreturn 0;
$ Q/ ~" L6 i! X [4 R' }' p3 M} 3 d, q& w/ W& W& E8 G3 | V3 c" w
</FONT>/ g8 ?8 H, ~; t! c
</P>) ?: S% @1 W/ P. a) X
< ><FONT color=#ff0000>函数名: outtext </FONT>2 V- p$ Z0 J5 ^/ G f0 S
功 能: 在视区显示一个字符串 $ p z B4 C: [+ D( O+ Y8 }
用 法: void far outtext(char far *textstring); + ]: q1 z z" P: Q1 X
程序例: </P>
- v6 ^6 Z. o$ v/ D h< ><FONT color=#0000ff>#include <GRAPHICS.H>5 D/ A% ]: [- B
#include <STDLIB.H>. ]2 [- c0 p, A" @- e! L
#include <STDIO.H>
( u2 ^& x" }8 \3 O1 r#include <CONIO.H></FONT></P>* e, m: L2 Z# i$ R4 A" D
< ><FONT color=#0000ff>int main(void) 6 B1 \7 k: y% N4 B- |
{ 8 i; F4 h- ?2 X6 O4 R
/* request auto detection */
* f8 s; l2 ^- n7 {int gdriver = DETECT, gmode, errorcode;
1 i" e2 G+ w3 n" _# m( d) ]2 Z8 oint midx, midy; </FONT></P>
( Z0 y+ w! m1 B- O< ><FONT color=#0000ff>/* initialize graphics and local variables */
! j2 V; t. O% Y. e \initgraph(&gdriver, &gmode, ""); </FONT></P>
! Q% P' p1 E, y9 M) t9 N( g< ><FONT color=#0000ff>/* read result of initialization */
n+ l+ k' f9 E- {errorcode = graphresult(); * [( F5 a# h$ {
if (errorcode != grOk) /* an error occurred */
& E; c. @2 W4 F6 D, Q _ p{
K& f' h9 `3 Z5 O% K7 H4 G- j3 N; Gprintf("Graphics error: %s\n", grapherrormsg(errorcode));
4 [$ d# v d' P" ]( G/ Wprintf(" ress any key to halt:");
! f. W# n. k/ I3 Kgetch(); 9 |" W, Z6 x- i* X
exit(1); /* terminate with an error code */ 2 ]: q8 y8 h( y2 J* B+ U* r
} </FONT></P>
! h/ W" y" L1 e; J2 k4 `0 k6 ?" _< ><FONT color=#0000ff>midx = getmaxx() / 2; v) ?2 l$ ` J
midy = getmaxy() / 2; </FONT></P>: R4 G1 y2 x- Z2 _& y3 N/ m% Y+ P
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */
5 U t( l3 u) a6 @8 j% T! Q- A; Pmoveto(midx, midy); </FONT></P>
9 \4 j2 D' _3 R. w7 w< ><FONT color=#0000ff>/* output text starting at the C.P. */
' p, x }, B/ I% D, J0 douttext("This ");
9 E7 y: c1 m8 P3 a* H# routtext("is "); 5 Y m4 D7 r5 D$ O3 a
outtext("a ");
3 `% D I7 u j7 r, |5 \( ? m( Souttext("test."); </FONT></P>) B+ q1 w, j& z
< ><FONT color=#0000ff>/* clean up */
' @! K4 H. z q- U7 [* egetch(); - E0 l5 e; Z+ o( ^+ T) h
closegraph();
8 h$ L1 \7 m+ y7 N( e5 M) Oreturn 0; 5 z2 C! V( U; N# K% v) K5 w
} </FONT>
" b& s; p8 U7 W* d# C3 D
+ Z' I( P8 R9 s</P>
+ m8 W9 H6 X1 F2 _+ S0 Z< ><FONT color=#ff0000>函数名: outtextxy</FONT>
- c; q' @+ K! _3 d6 ^3 m9 k功 能: 在指定位置显示一字符串
2 T. Q- ^- t/ L0 A" w用 法: void far outtextxy(int x, int y, char *textstring);
$ R( r6 ]9 ^2 o' l程序例: </P>
# ^# A/ ^3 W) C< ><FONT color=#0000ff>#include <GRAPHICS.H>
( v) V/ D' a. T& r( z#include <STDLIB.H>
$ g5 ~. J7 A, J4 z6 \0 w$ ^#include <STDIO.H>
- X: D, U3 V* g#include <CONIO.H></FONT></P>
+ F! L$ H, P; [/ W( A2 N' J0 {< ><FONT color=#0000ff>int main(void)
0 d$ V% e& O2 U" Q9 L{ " ?8 U2 P2 \- I3 i. L8 L
/* request auto detection */
2 `* s- H$ M1 _int gdriver = DETECT, gmode, errorcode; & ^+ |/ r6 v* X [; n6 t& x* J
int midx, midy; </FONT></P>
) M( W) o G3 r4 o< ><FONT color=#0000ff>/* initialize graphics and local variables */
+ K& V, Q Z% D+ winitgraph( &gdriver, &gmode, ""); </FONT></P>- y8 Q6 |: I$ ^& @
< ><FONT color=#0000ff>/* read result of initialization */
8 x/ p! N# X2 t: X rerrorcode = graphresult();
5 @ d& e3 i+ B8 \7 E5 lif (errorcode != grOk) /* an error occurred */ 5 t3 c) t G: ^: j* U# p/ d
{
$ _9 P: R9 u1 c9 K+ n" E" I( b/ Xprintf("Graphics error: %s\n", grapherrormsg(errorcode)); $ O! S- k' O6 K, M a
printf(" ress any key to halt:"); - U J; b- G/ g+ ?. h+ ~% `
getch(); ) Q5 a9 O7 Q& P3 T) a" f! v/ N
exit(1); /* terminate with an error code */
; J4 M4 r6 O- h6 S1 N' I5 m9 \* }} </FONT></P>5 ^+ s- l1 o/ F0 C7 J) E
<P><FONT color=#0000ff>midx = getmaxx() / 2;
2 O& K1 H" G) v8 ^/ t) Zmidy = getmaxy() / 2; </FONT></P>
. Q1 y1 P3 L- K2 p1 ?( S<P><FONT color=#0000ff>/* output text at the center of the screen*/
, W6 S/ O# b+ H% Y/* Note: the C.P. doesn't get changed.*/ - U3 V8 f/ h ?3 I4 p$ P" b
outtextxy(midx, midy, "This is a test."); </FONT></P>, l9 U& Z! J! R" F O9 D
<P><FONT color=#0000ff>/* clean up */ 5 @9 L5 o. G! ]1 L2 I- x
getch();
" Q1 [3 ^7 m( U" @2 f# {$ S* Oclosegraph(); ! A$ \2 R! i4 o7 g0 Q! V2 A0 S
return 0; 0 \# s8 p& M( P
} </FONT></P> |
zan
|