QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1809|回复: 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>
! Q* H' n3 Q7 Z- U( ~2 z5 u; p<><FONT color=#ff0000>void normvideo(void );7 g7 L" y- ^. j* S
</FONT>选择正常亮度字符。
2 _# }8 `; @+ b4 Z" Y, M将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
! I+ z$ N. t! t% R) {/ P8 [# R
; Y) C* ^4 Y, _: Q/ B8 r7 _8 w: S
<><FONT color=#ff0000>void nosound(void );0 e! O5 F% u5 N1 a9 W
</FONT>关闭由调用 sound而发声的扬声器。, u3 v# g' z5 ]9 t
</P>$ V9 t" h* }- k( c
<><FONT color=#ff0000>函数名: open </FONT>
9 f: _$ ~$ T( n/ q" }# m7 d功 能: 打开一个文件用于读或写
$ j. _' J% ~1 X5 W( @用 法: int open(char *pathname, int access[, int permiss]); 8 Y$ `6 `4 ?% r$ V: d
程序例: </P>, k+ m2 i, V, @( Z0 l
<><FONT color=#0000ff>#include <STRING.H>! [% W  |( I* e
#include <STDIO.H>
  ~9 J8 G8 |+ |* z! r) I' M, u0 ]#include <FCNTL.H>
" C# M/ r& L" S: n$ \#include <IO.H></FONT></P>0 P' p6 _- P& m0 H" e' Y% T
<><FONT color=#0000ff>int main(void) . H/ {, I3 U$ s, f3 W2 e5 D
{ 6 \' [! j5 ?! Q6 W
int handle; # `+ j! T5 v0 F( ]9 a  B9 R& C' Q
char msg[] = "Hello world"; </FONT></P>0 E$ C' L' T: Q' E2 v
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
# q. G& a, W0 x, O; K7 d, U{ % M, K$ g" Y7 {2 U8 E  V: k- l
perror("Error:"); / N8 h! Q9 N2 z( r6 @8 u, {9 ^
return 1;
! h4 g: j% e5 D- ~; }' J  f} $ s2 v. t( ~  k8 L
write(handle, msg, strlen(msg)); & C4 }5 V2 ^) k2 u$ n! a# ]: o/ r
close(handle); / ]6 R8 m! _; b3 b' S$ ]3 }  b) `! w: J
return 0;
  B' a/ d8 h& N! B1 _6 j} " }/ d) X! `  C* b& x# s+ q- C) y
</FONT>, V- z  V3 R& n0 H' W% o' x0 q
</P>, {+ a7 n$ ]$ }
<><FONT color=#ff0000>函数名: outport </FONT>
# c* M9 o* P: j. ~6 F功 能: 输出整数到硬件端口中
! a) E0 d( h6 I: H/ m. r% i用 法: void outport(int port, int value);
- M. B  o( _2 J# Q( c. l4 Q程序例: </P>/ G+ a, @3 O& M- l. D
<><FONT color=#0000ff>#include <STDIO.H>% J. ~; ?3 H! |. J( A) Z. u5 N  X, c( _, O
#include <DOS.H>
1 v( c5 E1 ?6 U2 Q  @1 e2 G- V</FONT><FONT color=#0000ff>int main(void) 8 w% o2 s: }' |4 L
{
& ]" [8 S* V- u& s8 Tint value = 64; $ U" B# K* T* f+ s4 f! T5 A7 l  ?
int port = 0; </FONT></P>
+ E7 a! V; v" P+ {9 @  o<><FONT color=#0000ff>outportb(port, value);
, S8 g& r5 l; \( x. zprintf("Value %d sent to port number %d\n", value, port);
: j8 B3 w  e& _* Ireturn 0; " j* k* M( ~' ~  a' n9 S3 l
}
+ H& o( J0 L. a4 u</FONT>
- A# O  T, n8 Y" P$ x</P># f5 z4 h7 C! }0 c7 I) p
<><FONT color=#ff0000>函数名: outportb </FONT>5 i5 P3 f7 g$ v2 ?% X
功 能: 输出字节到硬件端口中 & w( H! ~$ G3 d( W( b9 ^, k/ h
用 法: void outportb(int port, char byte);
) o: ^1 k/ ]0 W& D) f" D% x程序例: </P>
$ D$ \8 a/ s$ {& Q- U" j" E, W, i<><FONT color=#0000ff>#include <STDIO.H>
2 ]9 ?4 \$ q1 A3 K- H. \- J#include <DOS.H></FONT></P>
+ A3 ?7 y6 q+ P$ N) J$ b! ?9 a& J1 u<><FONT color=#0000ff>int main(void)
) d! N0 u/ p" ]; E0 Y( S2 J{ ( u" M4 L8 ^. T- I" B/ ^1 D
int value = 64;
% C# i! }$ ~" ?; h; hint port = 0; </FONT></P>
& ]: u! \+ P2 U0 W<><FONT color=#0000ff>outportb(port, value); ( h9 {: m& W4 A0 e, T2 v# }4 B1 q
printf("Value %d sent to port number %d\n", value, port); ; [* `, n% m4 W
return 0;
) K5 d, H: T5 ]: U} 9 \3 }/ f5 N' C8 K
</FONT>% ~  m+ Y6 G6 j. Q! F) k+ x
</P>
# G2 D3 t6 ]  _* P5 E% a% K# n  @<><FONT color=#ff0000>函数名: outtext </FONT>: l  w7 t: m& W4 U6 [0 |2 q( i
功 能: 在视区显示一个字符串
4 a+ R0 R' B' p, e* b; V用 法: void far outtext(char far *textstring); 3 [' q5 v' d( T$ _; g/ L5 L# y: ~
程序例: </P>( Q+ j; V& m5 k- Q, f2 c
<><FONT color=#0000ff>#include <GRAPHICS.H>! ~) C* S) k! v
#include <STDLIB.H>  `- V6 i5 I4 d* ?
#include <STDIO.H>
( f5 g) r$ t! M#include <CONIO.H></FONT></P>
/ e. k# ~, \6 _9 T) ]<><FONT color=#0000ff>int main(void) ! L# a+ h- p) j2 E1 G, T
{ 0 u" b/ v* w1 A5 V0 j4 S! h. |
/* request auto detection */
  x: A7 E# x* Wint gdriver = DETECT, gmode, errorcode;
+ ~; b; p' `+ Y4 H' e6 N4 c/ ^# {int midx, midy; </FONT></P>
5 H" T/ x: t: `. g  K- H' Z" f, r<><FONT color=#0000ff>/* initialize graphics and local variables */ - ?! `7 N! c) P1 B1 K
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>. \1 M7 u6 v+ P3 _% R
<><FONT color=#0000ff>/* read result of initialization */ ) |0 L/ O* U* C+ k& _8 f5 ?
errorcode = graphresult();
6 E8 c: v, j! N& A- x+ ~$ ]! yif (errorcode != grOk) /* an error occurred */ ) t  _0 i" m8 A7 z* B4 @) e) i$ n
{ ' I4 J9 D3 }8 U: J. p; _+ J. t
printf("Graphics error: %s\n", grapherrormsg(errorcode)); : f0 d7 D# G# C7 T0 [
printf("ress any key to halt:"); % q0 v9 k% H' u4 M4 Y# v6 S
getch(); " x4 X1 l3 l9 Q
exit(1); /* terminate with an error code */
. M# ~# f+ l( M8 S* G} </FONT></P>
/ i% u6 X3 O' J4 t) T<><FONT color=#0000ff>midx = getmaxx() / 2;
) n0 o; D( |. S+ \' V; d9 Tmidy = getmaxy() / 2; </FONT></P>
) o( t2 d. n/ V: ~; b0 D; I<><FONT color=#0000ff>/* move the C.P. to the center of the screen */ ' l, t" R6 s( P  i: }
moveto(midx, midy); </FONT></P>
' U( Y. M  D3 J; J<><FONT color=#0000ff>/* output text starting at the C.P. */ ' L' T2 L2 R9 l& p
outtext("This "); ! G; u$ {% L7 e% T
outtext("is "); * h7 F( i3 X% {
outtext("a ");
: }! J5 M. f- {8 v7 U) F) @; fouttext("test."); </FONT></P>- W$ u1 U. H1 T- X9 B' ~! j8 d& R
<><FONT color=#0000ff>/* clean up */
) p" c  s/ f. g9 D1 @getch(); - X0 ]# |5 `6 v4 o9 l
closegraph();
: s: J2 F. P3 p7 zreturn 0; ( u" r  _1 L8 m) o3 S
} </FONT>' T6 p# z9 w! B( G+ x8 Z# {. @
$ l6 W, ?! v8 o7 v* W4 D+ \
</P>
7 S, Z3 T% z' k. d<><FONT color=#ff0000>函数名: outtextxy</FONT> & A/ F( }: P; T- h& w$ F, h9 K
功 能: 在指定位置显示一字符串
; c1 q- x, r# {! X7 f) ^用 法: void far outtextxy(int x, int y, char *textstring); % b5 s. F" n3 C: s- I" w
程序例: </P>
1 F5 r- V) z& h<><FONT color=#0000ff>#include <GRAPHICS.H>
. V- V1 n0 c$ V' F$ @) d) C. ?& W#include <STDLIB.H>
$ J* O  E% z  _+ |% ]" O#include <STDIO.H>
" H- z" F* |9 \0 ?8 i#include <CONIO.H></FONT></P>
" y8 y; P# N1 z* F<><FONT color=#0000ff>int main(void) , J3 Q# X& b+ p  |2 f! y& e+ q& _% |
{ 1 }( o1 |8 g+ ?: y7 Q! L
/* request auto detection */ ( c( c  O% L  B# A7 \
int gdriver = DETECT, gmode, errorcode;
3 _! ]! j: i- v/ B* Mint midx, midy; </FONT></P>* |) U  ^$ e+ K4 g* `: w
<><FONT color=#0000ff>/* initialize graphics and local variables */   B  f2 C8 a4 W4 S- f. Z
initgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>* n8 e* D4 R5 @5 f7 p5 k1 ]
<><FONT color=#0000ff>/* read result of initialization */ # L3 h4 z0 L- @3 C
errorcode = graphresult(); # f( `8 L2 ^  D% n( {/ |8 A" p
if (errorcode != grOk) /* an error occurred */ ( g8 j2 w  `" Z% w) x5 J! ~. {8 u
{ ( ~9 q" O1 [) ~4 d- P2 H
printf("Graphics error: %s\n", grapherrormsg(errorcode));
) w' i8 \( f# Z% g, N6 iprintf("ress any key to halt:");   s* f" L: U2 J: p4 M9 {) v
getch();
8 V0 b* P9 K9 U+ }  C% M' t% B7 Dexit(1); /* terminate with an error code */
% e" z# z: ~. b; P, K. m7 s} </FONT></P>
; Z! `! D. O2 [<P><FONT color=#0000ff>midx = getmaxx() / 2; " F7 A" b4 [1 N
midy = getmaxy() / 2; </FONT></P>0 D. W1 Q) u2 j- G# }* e" P
<P><FONT color=#0000ff>/* output text at the center of the screen*/
2 i( B. F8 |! Y' @. x- N, Q/* Note: the C.P. doesn't get changed.*/ ( [& E7 f* M5 j" ^' k* H! m
outtextxy(midx, midy, "This is a test."); </FONT></P>, g3 c" A0 G. U5 d
<P><FONT color=#0000ff>/* clean up */
8 @6 k: s" D% A& ygetch(); 5 w+ s. K6 Q; F% {. w
closegraph();
% c/ t/ n( C" t3 kreturn 0;
6 F+ c# A, v# Q8 A( Z  c} </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-10-25 09:49 , Processed in 0.536399 second(s), 52 queries .

回顶部