- 在线时间
- 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>
; G9 O8 m' b. t< ><FONT color=#ff0000>void normvideo(void );
" p5 J/ m0 s& d' H$ ]- w- }$ M</FONT>选择正常亮度字符。5 m, ]- Q0 O+ l/ [3 Z2 K
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
+ U4 U" j5 Z+ f+ |, `. ]/ Z7 w; D9 N1 v3 m1 r; f" H3 X5 \- q
4 a" p9 I* U( ^2 C" C
< ><FONT color=#ff0000>void nosound(void );
- G7 y) F4 ^6 ?9 l) E6 W0 O8 ^</FONT>关闭由调用 sound而发声的扬声器。
/ N3 Q8 B$ f) X1 a5 E. @</P>
' m! {5 d" {; d. |) q< ><FONT color=#ff0000>函数名: open </FONT>5 D6 L" P' t$ \0 {, Z* B
功 能: 打开一个文件用于读或写
: L$ u' S: P: N/ K7 V6 a用 法: int open(char *pathname, int access[, int permiss]); 5 W" K4 J/ K' s+ g
程序例: </P>* b' B$ m2 j' W( k3 `9 k: p$ t7 x
< ><FONT color=#0000ff>#include <STRING.H>( ]- K2 M$ G9 t$ n& `
#include <STDIO.H>" _# ~, B. @ l; P3 ~, L
#include <FCNTL.H>
) C$ s; k, r, e( C# {: X; g: {#include <IO.H></FONT></P>
: @3 }4 l- C& b+ y. Z< ><FONT color=#0000ff>int main(void)
' p+ y, F4 U1 r x4 e, L{
/ [0 M4 S. C# ~4 N8 x. m) kint handle;
x: w. B( U& `5 j, a) L: t1 e5 Gchar msg[] = "Hello world"; </FONT></P>4 s/ j5 I7 \1 U! R% n/ Z o9 ^
< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
' z$ \( o& g! v* a1 U/ d; q: C{ ) j/ y( q* S. t+ x& `
perror("Error:");
7 W: F* P& ~+ q! I0 n. Lreturn 1;
8 w) Q# S8 ]: A3 z+ v}
9 K+ D! r, I/ ewrite(handle, msg, strlen(msg));
% L, {4 q- |5 l4 t Uclose(handle); : y9 u) A5 }! i3 X3 Z5 z
return 0;
6 r0 Q% o/ S5 j! t}
+ G& i0 U3 n: e$ N4 Q: Q3 N* }</FONT>0 Z {5 T5 Z. B! G" W
</P>
5 O0 k5 V3 `( U& Z0 o% U, E< ><FONT color=#ff0000>函数名: outport </FONT>2 F* j) |0 n+ a9 v
功 能: 输出整数到硬件端口中
/ {3 @8 D6 L3 W用 法: void outport(int port, int value); . V$ b6 [$ X5 d d
程序例: </P>
- F" N$ Y. i7 U8 C% o5 N# y& {< ><FONT color=#0000ff>#include <STDIO.H>. w$ Y4 R3 `! N4 n6 j
#include <DOS.H>7 s8 @# U- l2 g/ `- X
</FONT><FONT color=#0000ff>int main(void) 4 `0 t: m" P# Q( R4 C" }
{ j0 h6 C6 z$ n& u n4 H* t
int value = 64;
* Q8 {" m% s4 h& e# ?/ c% }0 Rint port = 0; </FONT></P>" [3 w" A4 e8 r8 x
< ><FONT color=#0000ff>outportb(port, value);
! ~0 ]! x9 U/ F! D yprintf("Value %d sent to port number %d\n", value, port); 5 H! \: v, o E- b3 F' `
return 0;
& K$ K7 a; i) f- P7 W, }}
# ^* q' E3 F; u) c% x) L; F, L</FONT>
0 o* l4 B/ J+ G- U( q: i8 ~</P>
1 D3 I E4 \' d1 e$ W+ q: j/ `) [" `< ><FONT color=#ff0000>函数名: outportb </FONT>7 F# |# n& G9 C7 O! h
功 能: 输出字节到硬件端口中
3 g0 D7 l4 S. c" f" L用 法: void outportb(int port, char byte); 3 c4 m$ i: M5 ]) X5 u
程序例: </P>2 }2 p5 i0 b- R+ b/ c a
< ><FONT color=#0000ff>#include <STDIO.H>
. Y% D* m& ]- \& [) G$ A* P4 _#include <DOS.H></FONT></P>; o% g( j$ c S, ~4 t4 J) S+ L# G
< ><FONT color=#0000ff>int main(void)
& T" \; y" r8 h2 K: ?{
; S; C3 R9 {; z# u' m* Zint value = 64; 5 N1 O/ k" b; y& q/ @4 ]! n
int port = 0; </FONT></P>
6 [5 a6 f' X' r0 M5 k, E! G8 s0 _< ><FONT color=#0000ff>outportb(port, value);
1 M& y. Z& N f5 |printf("Value %d sent to port number %d\n", value, port); ) o% M6 Y& O. V: e
return 0; ' D3 b$ f' R1 `. a- q3 @) \6 a
} & K2 v: S* V0 j: d# ~5 q
</FONT>9 E( A7 k% J0 v0 B" j; p% a+ ]8 H
</P>
6 L. f5 ~" d7 e4 P< ><FONT color=#ff0000>函数名: outtext </FONT>
r; o3 M/ g @! X) N' n功 能: 在视区显示一个字符串 . h- b% N% S$ i1 G4 K
用 法: void far outtext(char far *textstring); " B- g; c/ q% j) E, J: H1 D
程序例: </P>; J+ f5 P) n; }2 ^" |( f
< ><FONT color=#0000ff>#include <GRAPHICS.H>
( w$ l G+ Q2 Z( ^#include <STDLIB.H>1 v( i& ^" ]8 K3 R' x& w
#include <STDIO.H>
m6 ?4 ~; {* l" }1 M#include <CONIO.H></FONT></P>6 a6 F1 `- F% `9 e7 B$ k
< ><FONT color=#0000ff>int main(void)
" W: ?" {4 w: \3 Z8 ]& }{
' M: f% N a, Q! R/* request auto detection */ ! c# V% ]6 ?: M% r
int gdriver = DETECT, gmode, errorcode; 9 w* j* v4 G% D4 r
int midx, midy; </FONT></P>" `% [$ A) R0 o, B6 h
< ><FONT color=#0000ff>/* initialize graphics and local variables */
" O& [! y+ n- y' ^ P* R# ninitgraph(&gdriver, &gmode, ""); </FONT></P>
' ?6 L# ]+ Y* D) f. `< ><FONT color=#0000ff>/* read result of initialization */
. C' d9 i4 X) o0 R; perrorcode = graphresult();
p( h# X. K! a/ J/ J" j, Jif (errorcode != grOk) /* an error occurred */
& s2 G5 P2 h; D{ 6 \# M+ [0 [4 ^. M3 t) ~
printf("Graphics error: %s\n", grapherrormsg(errorcode));
2 L. E1 x$ f) \6 n, d. C. [printf(" ress any key to halt:");
5 O0 \0 t9 x! igetch();
; z6 y* K A- e- Y3 Wexit(1); /* terminate with an error code */
! G- z5 @" D7 r; F! }5 P} </FONT></P>- W0 O. p7 h" E* S
< ><FONT color=#0000ff>midx = getmaxx() / 2;
3 F+ R& C* `1 ?8 i' j: [midy = getmaxy() / 2; </FONT></P>4 V& |& ]$ ?. C. b4 d
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */
3 Q/ S1 o2 V2 A, `& `; lmoveto(midx, midy); </FONT></P>' r3 @! y, L) d0 j* L% E* \$ `6 f
< ><FONT color=#0000ff>/* output text starting at the C.P. */ ' L: w+ O- r5 p" V H/ s8 U2 V
outtext("This "); 2 v5 T( n V, J0 {/ E2 O! `
outtext("is ");
# }+ z, R+ H2 S) [5 g* j$ [outtext("a ");
" I: y' x9 T( A8 U8 d5 h1 h* @outtext("test."); </FONT></P>' n$ a) i; k0 Y: @2 g7 D, m
< ><FONT color=#0000ff>/* clean up */ 4 ?* g) x% m. F6 n9 K+ A
getch(); ! s0 v/ R! w' P. O; h: ]+ j% R
closegraph();
1 W, |, _0 D3 Zreturn 0; 7 ~/ |' W/ ?, }5 \
} </FONT>- N) s+ E: q# Y/ y; J. ?% l- U3 Z
! ?) r7 P! w5 j0 i& X
</P>$ W9 ~7 v7 G g3 ]9 c/ e% _
< ><FONT color=#ff0000>函数名: outtextxy</FONT>
: b* o l7 a' {# L' b, t1 s, T功 能: 在指定位置显示一字符串
; b" ]) T4 X5 i2 k/ S' ~用 法: void far outtextxy(int x, int y, char *textstring);
2 I7 k: o' ]- R: } R程序例: </P>8 y1 t$ t+ X U8 [' _$ [
< ><FONT color=#0000ff>#include <GRAPHICS.H>5 e$ }- A% n- b: }
#include <STDLIB.H>
' ~4 t: M& S8 ]. E e7 F#include <STDIO.H>1 V+ N; a2 h& e4 m) B8 `8 n( K
#include <CONIO.H></FONT></P>
+ e) q( [3 q" M< ><FONT color=#0000ff>int main(void) 1 C; e* M7 g3 F( y
{
. v5 S6 _8 d/ S% ?' i/* request auto detection */ 0 [0 R, y8 M; W: z' k. P: _
int gdriver = DETECT, gmode, errorcode;
& P( V9 s4 r$ K7 n( [' J0 Fint midx, midy; </FONT></P>
6 A# W7 L* z1 {$ d) J! j# Y; n! ]< ><FONT color=#0000ff>/* initialize graphics and local variables */
' ~9 ^5 i U5 q( B# Rinitgraph( &gdriver, &gmode, ""); </FONT></P>+ d7 U0 h. x3 ?7 h3 s: c- [
< ><FONT color=#0000ff>/* read result of initialization */
5 @' I& n- U7 }3 O7 T% {8 k$ Derrorcode = graphresult();
* {+ ~: t# t2 j& lif (errorcode != grOk) /* an error occurred */ + x4 P4 m O' W* K2 z
{ 3 z! m6 u0 j9 R0 Q
printf("Graphics error: %s\n", grapherrormsg(errorcode));
) u9 w# U* w* s. X6 ?printf(" ress any key to halt:"); % {( ]1 G$ y& i% ]/ T
getch(); / P/ T( P% C) n$ _# |7 `2 @4 \
exit(1); /* terminate with an error code */ ; f2 q% Y6 T" x( e3 y* ~7 `1 g
} </FONT></P>
. f* V9 E2 K& b8 D<P><FONT color=#0000ff>midx = getmaxx() / 2; ! u- I" k+ [! Q7 s$ v
midy = getmaxy() / 2; </FONT></P>" @4 b0 n- {' u. J% W
<P><FONT color=#0000ff>/* output text at the center of the screen*/ 9 A; u- V0 Y2 e! V
/* Note: the C.P. doesn't get changed.*/ n3 B! b* l: L+ c, c
outtextxy(midx, midy, "This is a test."); </FONT></P>% a7 i2 W, o1 t+ O& q0 f
<P><FONT color=#0000ff>/* clean up */
" k% Q o, I# i; ^. M' ^getch();
( q/ u3 I. ^, }' U+ L. h% T# ?: ]closegraph();
4 c. T; P! y9 ?$ U0 Freturn 0;
: x. E, c* G7 U4 j- j; [7 p( A} </FONT></P> |
zan
|