QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1706|回复: 0
打印 上一主题 下一主题

函数大全(n ,o开头)

[复制链接]
字体大小: 正常 放大
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

跳转到指定楼层
1#
发表于 2004-10-4 02:56 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(n ,o开头)</FONT></B></FONT></P>0 P# C5 k7 ?  G! B4 |4 p
<><FONT color=#ff0000>void normvideo(void );! E2 R1 o, a% c
</FONT>选择正常亮度字符。6 [% [8 |1 F8 A
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>9 E6 ^% F* e4 {& e6 B

1 W; Z) B! f' z( {3 g# r6 ]8 v) G
- f, O* O0 ?7 {) T4 v+ L# O+ H0 B<><FONT color=#ff0000>void nosound(void );
& i1 i) `+ h( r& r' g</FONT>关闭由调用 sound而发声的扬声器。9 O$ K% t( y" n! m5 r! A8 u7 ~
</P>' n6 e3 H- ^) f  {. Z7 v* s" W' i% H
<><FONT color=#ff0000>函数名: open </FONT>+ Z) C# L, l! ~9 ^
功 能: 打开一个文件用于读或写 6 Q* N0 U3 Y! f9 P! A
用 法: int open(char *pathname, int access[, int permiss]);
4 e3 {" o; G7 [$ P9 a5 \# w& ~程序例: </P>$ n' p6 D/ x8 h
<><FONT color=#0000ff>#include <STRING.H>
: n+ S' Z0 p. O! \6 @# N8 A8 ^#include <STDIO.H>3 \+ K3 q/ g3 ~
#include <FCNTL.H>
3 v/ D8 \0 I- ?" M#include <IO.H></FONT></P>3 d* P, |  p( f2 S; o
<><FONT color=#0000ff>int main(void) + d$ s$ a! v) b0 u
{
9 A: E6 v% K( f3 Zint handle; ; b8 B% T8 e0 k6 C/ Y% L( z5 ]
char msg[] = "Hello world"; </FONT></P>
! o* v3 u5 f# f# o2 n2 v1 q<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) 9 k$ @, ^/ x! [! Y: g
{ ! K' P& x; J, }7 S) D
perror("Error:"); ( ~1 \& V3 N. {
return 1;
/ r$ i+ B" ?" t4 M  z} " [* G4 ?1 W; f/ C) b! z
write(handle, msg, strlen(msg));
& \7 v( \5 l8 f9 @+ a1 gclose(handle);
- z5 F0 @" M: p# y5 `# areturn 0;
+ T+ X0 N, ^, c, F& t' Q# B- d! A}
! {/ W, W* g6 V5 ], p</FONT>( G; a1 C9 |( s6 M4 J) D
</P>4 r( u3 A9 I8 `2 @, J
<><FONT color=#ff0000>函数名: outport </FONT>
$ X" E0 I7 B4 o' v功 能: 输出整数到硬件端口中
' m; F- _) U$ k! G! m' S9 h用 法: void outport(int port, int value);
) ], j- z4 U* E' @* ^4 w( A程序例: </P>
7 K. y" Z9 \% U, V<><FONT color=#0000ff>#include <STDIO.H>; X. ]' i6 h/ D  Y5 n/ q
#include <DOS.H>
  \% @; \; x! R* i) A/ F$ @- o</FONT><FONT color=#0000ff>int main(void)
& J  ~8 y; }% n! M1 _: ^0 {2 R" T' X; ]{ 2 }% F& D9 v6 a: S! s
int value = 64; 7 Q+ Z, l: _8 @) _; ]- x) [8 B
int port = 0; </FONT></P>6 q7 f9 x3 q# T7 v
<><FONT color=#0000ff>outportb(port, value); 4 ?5 g6 S3 w& Q9 B$ o1 n8 x) a
printf("Value %d sent to port number %d\n", value, port);   {/ C: R) f+ i& ?0 B
return 0; 8 c( r. V. o, i+ S! Z
}
  S& R& J7 P2 t' ~</FONT>
/ L& p! H  O: @7 U. w0 V</P>
2 h& A3 ~3 g; S! a/ d, B5 G/ P<><FONT color=#ff0000>函数名: outportb </FONT>  \4 t8 E/ [% ~
功 能: 输出字节到硬件端口中 1 Z5 k& ]! A& X8 x- X! i
用 法: void outportb(int port, char byte);
& c- m8 c- |" u0 E5 @程序例: </P>) Z! d- P$ q$ [2 J- F: J: k( n. G
<><FONT color=#0000ff>#include <STDIO.H>
! A: K$ [& ^* G% J# Z#include <DOS.H></FONT></P># ^  A9 N& p. l+ J
<><FONT color=#0000ff>int main(void)
( @) _) h: W9 k{
, W% ~1 l5 P8 y& |: \# |int value = 64;
  q; P; a; K- t3 Y+ iint port = 0; </FONT></P>
) @  U4 ]4 e, n9 |<><FONT color=#0000ff>outportb(port, value);
* q# [5 v, k' r: j' aprintf("Value %d sent to port number %d\n", value, port);
0 B; Y, b, ?5 j. x; u6 X9 D8 ]return 0; 1 U" T! w- d1 H
} ! b- R; @4 E5 K- o
</FONT>
7 w0 R7 C2 y; u* z; U9 S</P>. S+ t: D% I: P. a, e! Y
<><FONT color=#ff0000>函数名: outtext </FONT>
6 T3 c9 x! f5 j/ V! O8 G0 \功 能: 在视区显示一个字符串
2 h( r- |' Z. `: {8 Q* S用 法: void far outtext(char far *textstring);
0 n  y+ Z. X9 g8 }! L4 a. g程序例: </P>
; o0 J8 _4 k5 R) e<><FONT color=#0000ff>#include <GRAPHICS.H>+ L1 v1 |" N, J0 B% y. p( Y
#include <STDLIB.H>
& R* [) l' x* a# |#include <STDIO.H>
7 o5 O8 u9 r, G6 i0 U#include <CONIO.H></FONT></P>
* W- c  K2 z- g<><FONT color=#0000ff>int main(void) ; k' G1 e/ [8 a" L) f
{ 6 P5 V' }4 S; A7 _# ^+ X- ~! g
/* request auto detection */
; d- P6 J/ d& \6 Z. _int gdriver = DETECT, gmode, errorcode; # }9 w$ X. I! d* ?. o7 s! E6 F
int midx, midy; </FONT></P>
* G# S1 ~) V+ M1 j* ^& a" _2 A8 P# I<><FONT color=#0000ff>/* initialize graphics and local variables */
1 x9 A$ P3 {0 W7 minitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
# _. b7 {2 r1 z<><FONT color=#0000ff>/* read result of initialization */ 8 s& l7 p% s- }/ Q1 `$ e: n  [9 D
errorcode = graphresult();
; [) q+ G7 {; d" ]( p' {! N) aif (errorcode != grOk) /* an error occurred */ 8 b/ p' {& G& x# `
{
3 [4 O8 e+ c* Xprintf("Graphics error: %s\n", grapherrormsg(errorcode));
. i) I. i6 _6 k3 @printf("ress any key to halt:");
& T0 N# S- ^( d3 Rgetch(); , L) _7 r1 w: v5 i$ ?6 F; [( ^8 S
exit(1); /* terminate with an error code */ * H2 b! S& I  H  b$ a# `
} </FONT></P>
* I: {. [; {5 o4 d; D' R. W<><FONT color=#0000ff>midx = getmaxx() / 2;
: E5 U, c+ X, G& A+ L( Y, i' Vmidy = getmaxy() / 2; </FONT></P>
7 }/ B1 Y  x- L# @  r) b<><FONT color=#0000ff>/* move the C.P. to the center of the screen */ ; z' }, Y% y% O; g
moveto(midx, midy); </FONT></P>
: v( L% J( D# O0 }0 g<><FONT color=#0000ff>/* output text starting at the C.P. */
9 z( S9 r4 ]) D0 F! Youttext("This ");
* j7 {* w: H" Souttext("is "); 4 ]' f* W. J4 z- L4 V
outtext("a "); . k" M" V% R) S% k. J
outtext("test."); </FONT></P>
) n2 c; A  y8 c1 z<><FONT color=#0000ff>/* clean up */ , s' Q# [2 O! p: J2 a; u) B* D9 s
getch(); ! E. g4 T, b$ Z0 j( E4 x$ G
closegraph(); 8 D) u% z2 M! p+ ^3 z5 y: {
return 0; 8 R) p) I, y! m. m% o
} </FONT>1 E% h( @* w3 v- p6 G5 k
, [8 N( x! t0 I# p! x* G6 ]
</P>
) q& C5 J3 G: H  E<><FONT color=#ff0000>函数名: outtextxy</FONT>
# d# m9 s) D3 S+ w4 l1 T: c功 能: 在指定位置显示一字符串
% A! q& ?5 V7 o用 法: void far outtextxy(int x, int y, char *textstring);
) l/ L3 G6 i! \. m程序例: </P>' b0 H: o& c; I/ p  ?; b
<><FONT color=#0000ff>#include <GRAPHICS.H>- p6 X: @: Q. y  S
#include <STDLIB.H>
1 ]* ?9 R8 h+ M#include <STDIO.H>. ~# z! b% \9 y) M) C" g( `
#include <CONIO.H></FONT></P>, j4 D: b* Z, a
<><FONT color=#0000ff>int main(void)
% @0 j1 l6 L6 v) [8 }  V3 B8 R{ 6 g' [3 j# {3 g3 i
/* request auto detection */
, m5 x5 ]: ?# d1 D9 C' I+ w& x" _int gdriver = DETECT, gmode, errorcode; 4 v0 g- K+ ~  J$ Q
int midx, midy; </FONT></P>. ]5 [+ H/ S8 d+ g, l; B3 E
<><FONT color=#0000ff>/* initialize graphics and local variables */
" R/ O3 @7 Z/ {1 ^1 B. g3 Minitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
4 N  _4 b0 |/ G( P<><FONT color=#0000ff>/* read result of initialization */ 8 I5 d. p, I* p3 C# ?" c
errorcode = graphresult(); ( D/ W, N+ m. M9 @9 E; k
if (errorcode != grOk) /* an error occurred */ 8 Q' |2 R2 y! j" o9 C
{
8 ?9 T2 O1 S0 jprintf("Graphics error: %s\n", grapherrormsg(errorcode));
7 {- x% \+ ^* z- \1 ^* iprintf("ress any key to halt:"); 3 R. G, d; G. h: P4 X0 G
getch(); " u" Q8 S+ U8 ]7 A+ i
exit(1); /* terminate with an error code */
* H+ @( z  `& s3 ?" m} </FONT></P>
( B$ h- c4 L; Q9 V: d3 b<P><FONT color=#0000ff>midx = getmaxx() / 2; 3 l$ e, G. C4 C4 A2 A) Q. n
midy = getmaxy() / 2; </FONT></P>9 {: l, N+ T- Z& j6 ~& \8 F7 j6 @
<P><FONT color=#0000ff>/* output text at the center of the screen*/
0 x; _2 m! g# d! g/* Note: the C.P. doesn't get changed.*/ 5 c0 a) k( C5 v1 x  y7 h& ^5 {
outtextxy(midx, midy, "This is a test."); </FONT></P>
- J. G( q3 ~' I0 A<P><FONT color=#0000ff>/* clean up */ - r% ~3 X9 B7 d" S3 g$ U) d$ L
getch(); ) y, O$ H( V7 n+ k$ T; i
closegraph();
9 |8 g5 S/ ]! D( r! Ireturn 0;
  B. K5 o/ m( f  G} </FONT></P>
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
您需要登录后才可以回帖 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085
fastpost

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2026-4-20 08:11 , Processed in 0.802962 second(s), 52 queries .

回顶部