- 在线时间
- 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 O3 |$ R0 b" W$ t< ><FONT color=#ff0000>void normvideo(void );$ d- P+ ]9 x; W6 \( S. \
</FONT>选择正常亮度字符。0 v7 S; D- y' ~/ g* a- Y7 S0 c+ Z! k
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>6 X# L. U2 x" `, Z+ r
6 A2 S& L' t9 N
% @; x! M& [6 T; i. `9 y2 V< ><FONT color=#ff0000>void nosound(void );& g2 p# P/ _0 Q1 G; U
</FONT>关闭由调用 sound而发声的扬声器。5 W% x! A0 @# n$ q
</P>1 ]( N2 k4 t# N% P- j) ]' N; [
< ><FONT color=#ff0000>函数名: open </FONT>
/ R6 L/ E6 b' l+ I& t3 a5 [# ]功 能: 打开一个文件用于读或写 : H, \" g- }. v8 S
用 法: int open(char *pathname, int access[, int permiss]);
- _* i( [# U+ G' B2 {. F [$ I4 ^5 a程序例: </P>
4 j, q/ D: ~! v) u) G( m% _6 h$ T< ><FONT color=#0000ff>#include <STRING.H>
@1 l1 z/ b# R#include <STDIO.H>3 o6 `+ h& m6 z3 i; j
#include <FCNTL.H>
2 v' k. t. g* W: k5 X) X$ A3 _, V) a#include <IO.H></FONT></P># ~ T* r; X% N3 ]5 M$ w
< ><FONT color=#0000ff>int main(void)
" A0 `) i1 z5 h{
9 s8 h: j; [3 r" D2 p- Zint handle; ' k3 V# @8 {* L8 g; g1 @
char msg[] = "Hello world"; </FONT></P>
" k/ C- J$ @' e: l2 q) ^9 {0 Z' l< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
5 M; d9 ?$ |0 _% g* |! ~5 H" {& s{
* i# q- I# Q" G) I$ m# p) Nperror("Error:"); $ D* A) C; }+ O/ _! R/ e2 Z
return 1; 1 N& q. C: t" L3 ^9 _4 u$ M
}
7 ~6 K8 B# ]. E3 U7 b8 x, b: ]write(handle, msg, strlen(msg)); 0 c6 ` P2 n4 Z
close(handle); ' I9 p, i( p5 l6 r Y
return 0;
0 z% c5 F6 D8 @& I} / r6 A( P8 ~0 u; D1 n r0 l) v
</FONT>
# R4 s2 l; L+ _4 W</P>
2 c, k7 k K0 U< ><FONT color=#ff0000>函数名: outport </FONT>) N( J: u8 U$ V8 a) |, F
功 能: 输出整数到硬件端口中 $ T4 o4 A0 y& |& O5 [
用 法: void outport(int port, int value); O( C, j9 M+ |3 ~% Y4 D0 T
程序例: </P>, b) \+ P- a l% \/ y
< ><FONT color=#0000ff>#include <STDIO.H>
2 f, B- {: r* |7 _) _ X" h#include <DOS.H>
% I0 X8 g2 w$ U# c9 d' y</FONT><FONT color=#0000ff>int main(void)
/ M& P8 H$ N' P6 r+ a" r{ ! d% d; ?/ ^. i: U3 h `/ f1 e( P$ c
int value = 64; * D) t# R& m) ?1 r) X
int port = 0; </FONT></P>; Z) o! ~6 n8 }& p2 X9 f o
< ><FONT color=#0000ff>outportb(port, value); / C1 t' p C& T0 S: @# c* Z! r
printf("Value %d sent to port number %d\n", value, port);
6 r6 }5 ]3 f2 K" zreturn 0;
' q' \* p8 X8 l} : S9 O$ b) o6 c2 l. a
</FONT>$ H. t! P! \- w% s+ t
</P>! ^: k( E& r4 q+ @, t4 X
< ><FONT color=#ff0000>函数名: outportb </FONT>
( S# P% x% N" h) x' V0 @! {功 能: 输出字节到硬件端口中
% S7 ~& f2 ~1 R2 h( @/ e% u! [; i用 法: void outportb(int port, char byte); ( H: K: ~. d2 v: c% f
程序例: </P>
" S4 V& n$ h6 G+ c' g$ x, D< ><FONT color=#0000ff>#include <STDIO.H>* u0 b+ t7 Q& e _
#include <DOS.H></FONT></P>
# Q3 g9 _; F3 V8 J; k/ A< ><FONT color=#0000ff>int main(void) - m6 q0 [; w* [) s0 G0 D: U+ m$ A: l
{ + a- a" O4 S6 d% V: ~2 I7 S% R
int value = 64; ; u- U! J* j( n3 U
int port = 0; </FONT></P>' s, I2 f# g, |2 V
< ><FONT color=#0000ff>outportb(port, value); 8 V8 a- y/ j8 Y. b* D( ~# H! Q
printf("Value %d sent to port number %d\n", value, port); % v! B, x, ` c. t6 Q1 D
return 0; ; u. r/ i/ B# s) }% [
} + V, g& A, `- y) X
</FONT>
" W. f$ D5 }5 p) `8 N6 L</P>5 i, ^. q, x" K% _' H8 l
< ><FONT color=#ff0000>函数名: outtext </FONT>( B" ^2 ~1 h0 S9 ~/ A" n9 p; l, X A
功 能: 在视区显示一个字符串
7 D" Y5 Q! M& `6 `0 G3 n用 法: void far outtext(char far *textstring); ( q o- x g( N( {
程序例: </P>
( ]- N- Z/ L9 q6 o< ><FONT color=#0000ff>#include <GRAPHICS.H>
& s. r! O: G/ } q#include <STDLIB.H>6 t2 e* b( r: i& L2 m; f: d6 `3 T; u
#include <STDIO.H>
3 A7 T, l0 l8 g& a X& Q, V#include <CONIO.H></FONT></P>
8 J9 E8 S. i4 |* T" i. i< ><FONT color=#0000ff>int main(void)
& E* y9 W4 q/ p3 [& g3 R{
8 J* {! ~0 J# d- _! l, C5 j/* request auto detection */
# y7 n( G& J# N5 c: y; }int gdriver = DETECT, gmode, errorcode; 6 z9 _6 E" U2 o3 X+ X
int midx, midy; </FONT></P>
( K% W" }) V& W8 U- A- \< ><FONT color=#0000ff>/* initialize graphics and local variables */
" y, z b1 N) J+ U& _3 yinitgraph(&gdriver, &gmode, ""); </FONT></P>; L0 B3 v2 K. j- G+ ?2 [
< ><FONT color=#0000ff>/* read result of initialization */
8 ]+ [6 e7 }, Xerrorcode = graphresult(); 0 j! p, ~; v( B/ }" c8 M) C
if (errorcode != grOk) /* an error occurred */
" G$ B! g' h- B7 m7 u{
2 i& r! U4 n6 v }0 E* K2 Zprintf("Graphics error: %s\n", grapherrormsg(errorcode));
$ w4 e/ w C/ j9 v# n2 h& j/ Iprintf(" ress any key to halt:"); 8 X1 Q. V* n) R" q/ {
getch(); 7 v& A: Q/ M( ?" a+ p7 M, _
exit(1); /* terminate with an error code */
/ [* t1 L- |9 M, L7 ]" d" L( O} </FONT></P>
% M5 Q& |$ t- x: j% C< ><FONT color=#0000ff>midx = getmaxx() / 2; 2 t; c: I1 j9 ~
midy = getmaxy() / 2; </FONT></P>" B$ d6 P$ t: h) I/ F& `7 M% ]2 _+ L
< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */ 9 F* |/ l$ h# E% R" h# A
moveto(midx, midy); </FONT></P>
8 E8 g) ?# c9 O) A1 L< ><FONT color=#0000ff>/* output text starting at the C.P. */ 7 D4 [7 e% w0 [4 k* b( T
outtext("This ");
4 F. \0 v7 `" d' Q3 Eouttext("is "); 7 ^; ^' v8 g. `2 d
outtext("a ");
. O4 e; |- `1 e* ]1 V2 Vouttext("test."); </FONT></P>+ c: g- f% q/ [) @7 T1 Q$ ^
< ><FONT color=#0000ff>/* clean up */
' p) q6 h" a3 q" l$ Igetch();
/ j9 ~3 d: W% T4 h7 ?closegraph();
( A7 E* q3 |( Lreturn 0;
" Y* n5 a2 y0 {/ o4 n9 E/ V4 C/ L} </FONT>
$ E0 S) v1 H' ~# y) X; P" V3 B! Q3 D; Z4 r% B/ w7 q& l
</P>
5 t- u5 c5 n% B% k- V< ><FONT color=#ff0000>函数名: outtextxy</FONT> ( X+ Q% @+ b% d9 K4 N5 D
功 能: 在指定位置显示一字符串
h0 X- r/ D) R1 m& m- l: g用 法: void far outtextxy(int x, int y, char *textstring);
7 ]( q! W4 U9 w' ]' h程序例: </P>
4 n z; {9 V. l) f" G) g9 Z< ><FONT color=#0000ff>#include <GRAPHICS.H>/ r) j V" d s
#include <STDLIB.H>
5 V& S; Y! H D# W3 q#include <STDIO.H>
( e! Q5 b7 |7 o& F7 p. q; }#include <CONIO.H></FONT></P>8 [9 ~3 [* T, {
< ><FONT color=#0000ff>int main(void) 8 C& w8 Y6 L8 g* m% z& z
{ / W! S3 |0 m, L' c- \
/* request auto detection */ 9 p# _6 n+ I8 h' O# ~
int gdriver = DETECT, gmode, errorcode;
2 K) v. `, o& m, yint midx, midy; </FONT></P>
- m- F" B3 A, ~1 g% ~! |: [( l< ><FONT color=#0000ff>/* initialize graphics and local variables */ % |$ [" G4 n: K) U0 b: Z+ s
initgraph( &gdriver, &gmode, ""); </FONT></P>6 j7 V. k" O1 x" }2 M) {
< ><FONT color=#0000ff>/* read result of initialization */ ! h. O) u) T* Z J3 R3 Y
errorcode = graphresult();
0 a" I: y5 u# v0 z+ t+ Dif (errorcode != grOk) /* an error occurred */
( b: L0 h, s2 M8 k; C{
% t5 G/ @+ u7 e. N1 `. r+ Z2 u7 Mprintf("Graphics error: %s\n", grapherrormsg(errorcode));
" f, W4 d5 l1 pprintf(" ress any key to halt:");
/ }! K1 D. f3 y; A& i. n! a0 igetch(); + I7 J$ F7 ?2 j, b$ q+ N( Y1 e
exit(1); /* terminate with an error code */
% K; {+ \& |7 N& A) N0 H1 @} </FONT></P>
$ }" V8 W, u0 e6 R/ M1 Y<P><FONT color=#0000ff>midx = getmaxx() / 2; % Z7 v" Q' _5 _, i8 M. u
midy = getmaxy() / 2; </FONT></P>
7 K$ r m9 S8 }% u<P><FONT color=#0000ff>/* output text at the center of the screen*/
( |' ^, l( x( T/* Note: the C.P. doesn't get changed.*/ 8 X. e A1 t! G! w. d
outtextxy(midx, midy, "This is a test."); </FONT></P>
, {: Y9 g5 }' x! i) O ~/ ]1 z<P><FONT color=#0000ff>/* clean up */
; Y. k; F& J8 \9 N, q- F; `getch();
7 R. }+ \& `9 x% {9 tclosegraph(); ) M3 `, C- \3 [& @
return 0; 1 Q! P+ {6 G% a7 L, q/ U# x
} </FONT></P> |
zan
|