- 在线时间
- 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>
8 b' `4 W( o r4 @+ k( ?: ?< ><FONT color=#ff0000>void normvideo(void );
! T, P5 B y6 ^% d# Q0 K% M</FONT>选择正常亮度字符。* g7 i: P. C! B- Y8 ]- E0 ]
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>3 O% l) W# `" h* O& s$ ?2 P7 j
) [8 g4 D2 _( F3 A% D( k
) G% V2 X4 z6 l
< ><FONT color=#ff0000>void nosound(void );
6 F, A6 Q! u% f+ U+ }</FONT>关闭由调用 sound而发声的扬声器。
! f2 v1 C# J( k/ [2 N4 k</P>, Q' e ]* {8 r7 d% y1 r* Z ^
< ><FONT color=#ff0000>函数名: open </FONT>8 u+ z( r* |" s
功 能: 打开一个文件用于读或写
# T( i5 p: G- ]用 法: int open(char *pathname, int access[, int permiss]);
, A2 o; s2 A: q: Y, M程序例: </P>
, m% m- A! U& D% K: J( D< ><FONT color=#0000ff>#include <STRING.H>
, {7 \( }3 w2 @#include <STDIO.H>. J' n+ w# C" H* x" A
#include <FCNTL.H>
" u- X( b+ ?! L5 f: I) d5 [#include <IO.H></FONT></P>; M, U7 _& @( R; u
< ><FONT color=#0000ff>int main(void)
1 _3 T# `; C5 g: F; b{ ) A3 Z# B4 M* z4 X7 y1 v
int handle; 6 q, ?/ _, M J1 J! H( @
char msg[] = "Hello world"; </FONT></P>
. `- Y6 j6 Y) H& G' l7 X/ N2 h3 Q< ><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) 4 C% B! w( l- a' U
{
( w S% |; J' n0 l$ Rperror("Error:");
; i$ k; \% ]8 V& M3 Dreturn 1; 3 W+ g3 _+ _% q7 T1 [+ m4 N
} * g+ U8 O% g+ F( m. u
write(handle, msg, strlen(msg));
- W0 a1 ?" x( \# W8 Sclose(handle); 2 a( d9 C, s+ e7 c/ Q' t) w6 R
return 0; % r4 s0 H, K9 a& ^
}
+ s! g+ b. [3 E& X- f% y7 g</FONT>- `2 u: j! ?* B# x7 f
</P>) B' B, h+ M9 G, a
< ><FONT color=#ff0000>函数名: outport </FONT>( |: E* {( k$ X A8 {
功 能: 输出整数到硬件端口中
* n& t( A1 o/ c* B) A" W2 x+ r; U9 H用 法: void outport(int port, int value);
4 ~; g' i$ V) {程序例: </P>5 B+ A6 c; S5 N: s$ }+ e( Z
< ><FONT color=#0000ff>#include <STDIO.H>
8 p$ q# n7 s" e& U/ f#include <DOS.H>
0 r$ U( ~7 W) x$ ?; P: X</FONT><FONT color=#0000ff>int main(void)
/ v, E9 a* k- [{
1 ~9 r/ ^, m* G7 ]( ^; `int value = 64;
9 C v. O+ r% A+ B% \int port = 0; </FONT></P>
8 X, Y8 f1 t. ^: y* o1 \& ^% C& Z< ><FONT color=#0000ff>outportb(port, value); : A- ?0 d% x. F; ]8 B
printf("Value %d sent to port number %d\n", value, port);
) l2 N- I8 k1 B% a( t/ E* }return 0; # ^2 {. ~: x! f& Q$ @
} . B2 i, W! U8 |7 N9 M) U
</FONT>
% K( w( h3 C$ z0 R</P>
' X) a9 S ^- d: \. \< ><FONT color=#ff0000>函数名: outportb </FONT># ^/ N! Q5 I" I5 h
功 能: 输出字节到硬件端口中 ! `# l( x% U A) y1 c. ?
用 法: void outportb(int port, char byte); ' L7 i3 _" C+ a1 Y1 z
程序例: </P>
a; c& |1 M' O# ^7 g+ l; n2 A' Z< ><FONT color=#0000ff>#include <STDIO.H>! ~. T$ u' E: ]6 [
#include <DOS.H></FONT></P>
+ T8 g$ w' T1 D( N< ><FONT color=#0000ff>int main(void)
( M9 T% u: g5 Y2 Q{
3 x8 O# X8 h: N! gint value = 64;
: H2 l' y/ F1 \) [$ F2 Rint port = 0; </FONT></P>
( M9 D- |' k' G( U8 t9 b< ><FONT color=#0000ff>outportb(port, value); + h* W5 V. H. f# d7 m
printf("Value %d sent to port number %d\n", value, port); $ S8 V& o, x! `! f* e
return 0; 4 W4 b+ W" X" U* L, @
}
5 _- D' |9 r+ X( ?. \$ Q3 B</FONT>' E. S1 x4 ~: {1 J+ ?8 ^* j
</P>
6 l" X3 O$ w3 l7 R< ><FONT color=#ff0000>函数名: outtext </FONT>
5 v: y7 M1 z2 R; P- Z功 能: 在视区显示一个字符串 7 `/ f. [3 s0 R
用 法: void far outtext(char far *textstring);
" j5 ?4 a9 Q- H4 M& ~' G5 m程序例: </P>7 W7 y- X9 z& V4 \" |9 a# _5 S
< ><FONT color=#0000ff>#include <GRAPHICS.H>
6 C" G8 Z1 K9 k1 m1 K#include <STDLIB.H>
" k$ W9 Y4 h9 l- r. U#include <STDIO.H>
7 y1 {8 l7 I5 M, x3 K& e#include <CONIO.H></FONT></P>
, N: O5 X" {) A* Q< ><FONT color=#0000ff>int main(void)
6 H9 k9 [) \3 `( W{
" g! j0 D+ |' E, P/* request auto detection */
7 q9 }" P& \3 B" `2 G6 r$ V% g6 h; Wint gdriver = DETECT, gmode, errorcode; + X4 L( U9 K; \# o" g3 g
int midx, midy; </FONT></P>
a! s( d0 K) Z< ><FONT color=#0000ff>/* initialize graphics and local variables */ + s1 A- s, N2 a6 P" S* ]
initgraph(&gdriver, &gmode, ""); </FONT></P>( @1 B* M/ t0 W9 K" U+ X. { D8 y
< ><FONT color=#0000ff>/* read result of initialization */ : a' n) ^ R0 R5 E* X- {9 v! f1 {
errorcode = graphresult();
, u! G8 G* H2 K, {2 V) }8 |6 wif (errorcode != grOk) /* an error occurred */
" X& w. Q' O5 l0 h8 O4 ^6 x{ , G% _ }* M0 B" O& l9 a, ?
printf("Graphics error: %s\n", grapherrormsg(errorcode));
& X, e; A2 M8 J* q, R rprintf(" ress any key to halt:"); 9 c# s! ?8 c& o& q, N# j" W
getch(); * b5 N, W& h. G2 I5 }" A
exit(1); /* terminate with an error code */ . f- z1 S4 {, a- q9 Y% x# `
} </FONT></P>6 X- x. ]5 k+ [6 D6 l/ L
< ><FONT color=#0000ff>midx = getmaxx() / 2; 6 ]/ k d# |2 ^+ W6 S- l( f) Z
midy = getmaxy() / 2; </FONT></P>
& e; S! J+ j: P. j# f< ><FONT color=#0000ff>/* move the C.P. to the center of the screen */
4 z( h! {, q- R' E- g. bmoveto(midx, midy); </FONT></P>4 R- W4 n2 R& ?: W/ J {
< ><FONT color=#0000ff>/* output text starting at the C.P. */
. v5 `) R. f6 F6 G% youttext("This "); 5 W% ]+ V. _/ o$ a$ A* r. Y5 J1 f" y
outtext("is "); 4 j# o" W" N1 W, u& u
outtext("a "); * `/ W4 a$ @' c
outtext("test."); </FONT></P>+ t z1 @! X7 U6 `2 S, ~0 p
< ><FONT color=#0000ff>/* clean up */
0 U! z- z" J% T- k8 f- w+ f igetch(); ! A9 r6 H5 n# I, P, C/ Q
closegraph(); & W# y7 O+ T) X3 H4 n9 c
return 0; f& b' \( w& [' B1 c( w
} </FONT>" _, ]5 C, ?8 B4 ]8 L' `2 o
6 o9 F3 I$ ?* Z1 r, V5 F1 n+ s</P>
. k1 r' L3 c* J1 d% n& {) C- s* [< ><FONT color=#ff0000>函数名: outtextxy</FONT> - x; {( C7 d' l1 J7 X% y
功 能: 在指定位置显示一字符串 - f: t1 U H( H. T6 y
用 法: void far outtextxy(int x, int y, char *textstring); ; k' v6 M: f3 H
程序例: </P>
6 j8 ~7 R% w: u& F* t, b< ><FONT color=#0000ff>#include <GRAPHICS.H>1 H1 g+ U+ X, g1 P, X* [4 c
#include <STDLIB.H>3 d! m6 z5 ?0 D |; t" `
#include <STDIO.H>
/ L: P0 Y) V3 O2 @; L! ?7 p! Y. t#include <CONIO.H></FONT></P>! }9 @1 \: [. ?9 r" C4 X
< ><FONT color=#0000ff>int main(void) 4 ]2 `* F+ X) ~+ K
{ 0 c9 W& b) X, I& k7 G' g5 `; c1 [
/* request auto detection */ & Z& l% z9 ~7 Y- G8 \" n7 M: g
int gdriver = DETECT, gmode, errorcode; / a4 Y. v* }& B) B8 x/ `8 j
int midx, midy; </FONT></P>" [7 W7 n8 N. }, G5 o
< ><FONT color=#0000ff>/* initialize graphics and local variables */
) ` @/ h& }6 Ginitgraph( &gdriver, &gmode, ""); </FONT></P>
6 s) C2 A% x2 }2 ]6 d1 W< ><FONT color=#0000ff>/* read result of initialization */
0 h6 f; G2 c! J- derrorcode = graphresult();
. S, `( G$ C# U {& X9 eif (errorcode != grOk) /* an error occurred */ , F3 L4 N: d- x6 w( j1 H
{ ; k" i& f1 e5 r1 ?
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 3 _# W# q! v, A7 \
printf(" ress any key to halt:"); ' d' I' j& d. U! ~ y
getch(); 2 S0 e; D( V& m8 M- H& t
exit(1); /* terminate with an error code */ 6 @! N/ R( [" G/ u$ B* Z6 m
} </FONT></P>! \1 A2 e9 g: L: n7 d
<P><FONT color=#0000ff>midx = getmaxx() / 2; & @2 d, B3 V. b. y
midy = getmaxy() / 2; </FONT></P>9 x! f& H) T) l2 `$ U
<P><FONT color=#0000ff>/* output text at the center of the screen*/
0 Z+ c2 n+ Y, {# L+ r/* Note: the C.P. doesn't get changed.*/
' L% t) a) ?2 }outtextxy(midx, midy, "This is a test."); </FONT></P># U r0 e+ Z0 p. d8 f
<P><FONT color=#0000ff>/* clean up */
4 G0 j! k6 V3 ggetch();
& s8 {) \! s! A# P8 @closegraph(); 3 P# h7 r8 _0 A' i+ D$ z; H) q0 w
return 0;
. R' H- o) ~* R& ^6 f5 Y} </FONT></P> |
zan
|