- 在线时间
- 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>3 g2 L/ `2 R9 x5 a; p3 [
< ><FONT color=#ff0000>void normvideo(void );
3 W3 V1 x) S8 i' V! W7 p" X</FONT>选择正常亮度字符。
- a( C+ W3 b% E/ t' U: H. Q7 O将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P># T7 a3 s8 D7 D' ]
& ]3 B% v1 r7 W/ {0 t. ^
+ ]3 Z9 _- Y5 r( a* X8 d4 h+ F< ><FONT color=#ff0000>void nosound(void );1 L5 X+ \, M4 m* |1 w; [
</FONT>关闭由调用 sound而发声的扬声器。! `/ x$ b" O3 ]% w8 ?7 K" I2 n
</P> v4 V% M4 ?/ y( B# j& S
< ><FONT color=#ff0000>函数名: open </FONT>7 s6 n8 P3 E1 ~9 P7 ?
功 能: 打开一个文件用于读或写
, v: u6 L) e( N8 M2 {% N! m用 法: int open(char *pathname, int access[, int permiss]);
1 F" m; |# i- B9 j! G程序例: </P>' W4 ^' l8 G4 g1 h/ k8 V
< ><FONT color=#0000ff>#include <STRING.H>
4 b, e! y" o- f& S* b$ q#include <STDIO.H>
8 d& Q( u8 ]# U) x! A#include <FCNTL.H>- [, G1 _9 m' N' F1 R @7 {5 c
#include <IO.H></FONT></P>
p2 e" F6 Z5 p3 o' a) H$ B1 L< ><FONT color=#0000ff>int main(void)
7 L' [4 q; n. N{
" D& K( y: @: j# r) M2 uint handle;
8 ~! T9 ^% \& F& n8 Jchar msg[] = "Hello world"; </FONT></P>4 U. Y* K# O7 E4 k* E
< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) 7 A4 v+ ^+ S8 W. _( y
{ 5 A7 b, Z& @: ~. ]% \; p9 D
perror("Error:");
6 _& _) x6 G6 M/ m1 ^return 1;
|: H" c2 t/ w1 Q7 [& @5 L8 X! U}
" p0 r# r8 m4 I- ewrite(handle, msg, strlen(msg)); 9 j/ {0 x+ c3 Z3 Q C Y! E
close(handle); 6 V3 u& b& M% N
return 0;
; @/ L& n+ u, o6 C} $ ]! B2 y+ F0 M: l6 G# b7 ~
</FONT>9 G$ K5 i6 z; K# P
</P>
1 q$ k5 d! v9 [; W; Y2 z< ><FONT color=#ff0000>函数名: outport </FONT>, n* r4 ~- e }8 m
功 能: 输出整数到硬件端口中 " D- Y$ }4 S" a2 T2 F* R. |
用 法: void outport(int port, int value); " e0 F d, d" H' T6 |, W
程序例: </P>
! m4 L6 f) j9 A, }+ V8 V< ><FONT color=#0000ff>#include <STDIO.H>- d* F: B' ^# W* t0 `
#include <DOS.H>$ b" _3 y" y" A: _- S
</FONT><FONT color=#0000ff>int main(void)
9 v9 r5 z) A7 m3 h1 o1 Y4 g{
m% n% e/ ~2 i! y* j/ ]int value = 64; / k+ {' K; m5 ^2 L# s
int port = 0; </FONT></P>. [5 M. ~2 K4 T2 R% d. Z: R5 N
< ><FONT color=#0000ff>outportb(port, value); $ R2 H# b- j, I0 ~7 I3 m; G
printf("Value %d sent to port number %d\n", value, port);
% h. Q9 a6 s5 z7 f& [return 0; 3 U) a- W4 N0 C. n
} $ O- L$ ^* K& ?" c2 X7 H; h
</FONT>
( L7 e. n3 y! M2 e: _/ O: T0 K$ w</P>
- s$ u2 m+ g, H< ><FONT color=#ff0000>函数名: outportb </FONT>
) F3 u% G. V# t& Z+ `功 能: 输出字节到硬件端口中 ( D. u& ~$ ]8 o$ L# R* k, s
用 法: void outportb(int port, char byte); 9 e0 Y1 R ^5 t7 ]1 P4 z2 y( N
程序例: </P>0 X) @2 G0 f' i6 @, Z
< ><FONT color=#0000ff>#include <STDIO.H>4 t; m2 Y+ K" H
#include <DOS.H></FONT></P>. i3 j5 L9 J- q$ J/ x" t( v
< ><FONT color=#0000ff>int main(void)
0 Q' Q" D, N% h1 _; V6 m{
/ {, z; A* o+ ^% o* H0 x1 Rint value = 64; ' a6 u7 e- _, I# \' R( L K
int port = 0; </FONT></P>% |+ g- W' x) o- m( N6 \& f0 g0 ]
< ><FONT color=#0000ff>outportb(port, value);
: L7 K7 P% Q7 H, U, f0 Sprintf("Value %d sent to port number %d\n", value, port);
$ c5 `, k0 c, {. Yreturn 0;
! j, S( b) V! Z8 X* W. z/ D}
8 ^: b) {# t2 W1 D0 I+ _6 X9 N</FONT>" O# M' ~% Q' q8 Y# n
</P>. Q# ]/ \) ^. b! E' ?/ M
< ><FONT color=#ff0000>函数名: outtext </FONT>
8 E2 W: J% H8 Y7 c( o( D功 能: 在视区显示一个字符串
9 h h# n6 I/ u用 法: void far outtext(char far *textstring); 5 E' n/ x) q- I4 R+ F) ~+ D
程序例: </P># [9 B5 S# s, L# B/ m
< ><FONT color=#0000ff>#include <GRAPHICS.H>+ W; L/ k8 a+ W" X e
#include <STDLIB.H>! M. h4 D) |) S/ d
#include <STDIO.H>9 O. d% O3 r- x3 a) J! a
#include <CONIO.H></FONT></P>$ w8 i4 U/ k( {) `$ {. L: q7 C
< ><FONT color=#0000ff>int main(void)
" N/ C% m2 R8 l( `8 t{
, E$ j# [; a- _6 o9 w+ \/* request auto detection */ 2 ~0 L! ~* R& d3 J1 ^
int gdriver = DETECT, gmode, errorcode; 8 s& |! s; G: z; T# M e* }
int midx, midy; </FONT></P>- i* B9 g/ q' t+ m
< ><FONT color=#0000ff>/* initialize graphics and local variables */ & j' Z! B0 }0 d7 l1 N7 X* j: o- g
initgraph(&gdriver, &gmode, ""); </FONT></P>
- C( d1 Y2 X) F% C< ><FONT color=#0000ff>/* read result of initialization */
$ J) k, z: c& I1 i8 W+ ^errorcode = graphresult(); ' i* z$ H" Z- x S6 J' Z- z
if (errorcode != grOk) /* an error occurred */
% o& ~) N' f8 F/ c6 A C& t% N2 D{ ; b: ?# s' k1 N. D& U5 L
printf("Graphics error: %s\n", grapherrormsg(errorcode)); ' f/ d/ ~* F8 g
printf(" ress any key to halt:"); / X( H. K: |' ^
getch();
3 S. D1 M" M8 n: `' B1 }exit(1); /* terminate with an error code */
( y* Z2 |' Q4 k% E9 y} </FONT></P>' b. o1 ~2 |/ p2 n
< ><FONT color=#0000ff>midx = getmaxx() / 2;
2 K5 l6 ]- c2 a' Kmidy = getmaxy() / 2; </FONT></P>. E( l5 }9 Q# B @8 m1 A) b: ^) {. i
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */
& M2 d7 y2 b# Tmoveto(midx, midy); </FONT></P>, w3 u) c/ e! Z" r- g
< ><FONT color=#0000ff>/* output text starting at the C.P. */ ( E) A i2 w) ]0 H, h/ \
outtext("This ");
1 W1 ~ A9 h# p) z0 ^outtext("is ");
3 c1 ^: b2 C8 e6 K& T; h1 L1 q1 \outtext("a ");
9 l- Y) m5 Q! S" |% f0 d# _outtext("test."); </FONT></P>, b5 f/ {5 }" m0 M2 g; k
< ><FONT color=#0000ff>/* clean up */ + E& Y* S2 U# V- o7 U& F7 }! ~
getch();
; b/ z9 W/ z( B$ I( nclosegraph(); 3 x! l2 w1 z1 e( R7 K
return 0; 9 _6 J4 G4 D/ l* D. c3 ]
} </FONT>" ^4 G3 @/ z% w& D6 X6 g$ b4 Z
: @- U- m. n3 u; u; C! a</P>
' q" } ~$ B; a' A6 |$ Z* j+ q9 d< ><FONT color=#ff0000>函数名: outtextxy</FONT> & T! w' ]+ ]( r1 A# [' ~- d
功 能: 在指定位置显示一字符串 . q" r% [/ E: w s
用 法: void far outtextxy(int x, int y, char *textstring);
; s4 Z( V# z) [3 s/ l6 h, o- n/ K程序例: </P>
& W3 e* R% c3 O, n< ><FONT color=#0000ff>#include <GRAPHICS.H>
, W' P. \" d2 o. W! J#include <STDLIB.H>8 E6 _+ ^3 d6 y, w7 @ G
#include <STDIO.H>
5 t2 s8 T ?/ R! s" F# _" D% w#include <CONIO.H></FONT></P>
; h o; ]) t0 p+ C X9 A1 j< ><FONT color=#0000ff>int main(void)
% W* o# b) V2 k' ^0 x0 s{ $ @7 y8 E/ z& P) W0 Y4 T" R, q
/* request auto detection */
8 V; U, l" C& n* Aint gdriver = DETECT, gmode, errorcode; " \9 |* k, d# l2 f
int midx, midy; </FONT></P>5 |3 M. R ~+ H4 o- d( Z
< ><FONT color=#0000ff>/* initialize graphics and local variables */ 5 ?; [9 V+ e3 i
initgraph( &gdriver, &gmode, ""); </FONT></P>! h; ^4 A+ q9 s* ~2 S5 F
< ><FONT color=#0000ff>/* read result of initialization */
2 _* X4 Y' w1 S" N berrorcode = graphresult();
% k7 L6 B" K! m2 u3 o% V% f0 Lif (errorcode != grOk) /* an error occurred */ : I8 c% e7 i9 d/ S# i6 `4 E& f
{
( k! @9 n: z) s2 `2 Zprintf("Graphics error: %s\n", grapherrormsg(errorcode)); ( O" [' `$ Q/ b; n1 M B
printf(" ress any key to halt:");
8 H; w2 s! h# c: _; G6 V/ i# Kgetch(); ; ]; E/ V5 O; }6 U; V$ U7 h
exit(1); /* terminate with an error code */
5 p% ~/ J( f& t4 A} </FONT></P>% }5 P. Y1 q6 h, r2 z
<P><FONT color=#0000ff>midx = getmaxx() / 2; : `2 H5 G9 E: d2 |! V$ o# H( I
midy = getmaxy() / 2; </FONT></P>
4 G) T5 r9 k9 @* Z( H0 j<P><FONT color=#0000ff>/* output text at the center of the screen*/
5 x7 _; z& T+ v6 l/* Note: the C.P. doesn't get changed.*/
: m3 U8 k4 G: q+ G9 Xouttextxy(midx, midy, "This is a test."); </FONT></P>
2 {+ g& ]% }! B- l% Z<P><FONT color=#0000ff>/* clean up */
' e) l5 ~: G$ Pgetch(); / I K2 S5 e- J E5 }. w& Y$ Q$ ~
closegraph();
5 J! ?7 B+ G0 Z5 z8 I( G) Treturn 0; + b( Y, Y" t" c& W+ O! y
} </FONT></P> |
zan
|