QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1709|回复: 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>( E# }5 e; j0 W4 B7 L& j/ A! D
<><FONT color=#ff0000>void normvideo(void );
) f5 e/ f$ p: U) \</FONT>选择正常亮度字符。9 a% b( g/ C4 c, T& Q) y! [0 x& f
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>- v  T  ?0 d6 u1 ~8 S, ^4 x0 t

$ K& ]7 L: }% \) D
: O6 u) S# C5 N& ]  Y# h7 F" `$ n<><FONT color=#ff0000>void nosound(void );
1 @1 ]8 K" m. T1 `7 j. l1 K3 m! O. C</FONT>关闭由调用 sound而发声的扬声器。
2 o& d' i1 j" A" h4 O; w  e+ [! ]; A</P>0 x( q, w2 H" D5 S+ @5 _
<><FONT color=#ff0000>函数名: open </FONT>: e9 \, M* b% i9 D
功 能: 打开一个文件用于读或写 8 L7 o9 @5 `+ G
用 法: int open(char *pathname, int access[, int permiss]); . b- g. b4 |! e
程序例: </P>
# w; ?" R; W3 n0 N2 Z<><FONT color=#0000ff>#include <STRING.H>
, m2 @- f) t- N" o#include <STDIO.H>: {/ K7 x5 O2 {4 X: A- }2 H
#include <FCNTL.H>
* B* o1 b% P; \9 J$ ?! ?3 d#include <IO.H></FONT></P>
% q# E1 s% F* A# c0 I4 y<><FONT color=#0000ff>int main(void) # [+ Z6 \. v) N% i% G8 j0 ~% R" H: Q' o
{
) L5 r) b2 V. |5 o& sint handle; . S: p7 q; z# V+ e; o) S# @
char msg[] = "Hello world"; </FONT></P>6 h4 Z2 w" J9 s( s
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
+ C" V; H2 J* u7 s+ w$ o{
. d) ~0 X& H1 @) G6 `( {/ m; Yperror("Error:");
6 L; z' s  u1 w/ a1 ereturn 1;
1 D/ Z4 G, V0 T}
/ j5 L2 J7 S( k4 d0 q* h0 Ywrite(handle, msg, strlen(msg)); , W: L! |# T, @2 e8 r9 j% |
close(handle);
+ v" ^3 `$ V9 c, K: E7 v; L3 F/ yreturn 0;
8 {; D4 \9 {4 X; ?* h8 c" `) r} / y1 Q/ d( f, T& P
</FONT>
' h+ E9 C1 B$ t. C</P>% R/ [5 M' U4 U7 U  N* z. R. E
<><FONT color=#ff0000>函数名: outport </FONT>8 {4 `8 Y5 g' O
功 能: 输出整数到硬件端口中 ) ^- q; R7 |# z, C" [8 V6 M' t
用 法: void outport(int port, int value);
/ A3 d( Z1 h, F7 f" _. t程序例: </P>% B, f. s! S% J! @% ^  ?
<><FONT color=#0000ff>#include <STDIO.H>
: g; a/ u" N" n$ E9 B3 ^#include <DOS.H>
! W7 V/ _( T( h; M' s% ~</FONT><FONT color=#0000ff>int main(void) : G7 r& {0 ~: C1 v1 Q
{
. _6 H. m  [  a: L, yint value = 64; 9 T  J' S7 X9 ~- i
int port = 0; </FONT></P>7 F3 S5 U  C: W# `" p) q4 A7 w# m
<><FONT color=#0000ff>outportb(port, value); 3 E# p' t" A8 ~* L) X+ D
printf("Value %d sent to port number %d\n", value, port); + J6 v8 @. \3 H! q; J% ^
return 0;
  K5 M3 W. V" ?0 {} ( s  `2 D% R/ x) E4 r+ o
</FONT>
+ v1 F9 z  u5 x% R6 x$ V</P>
1 s; M. E3 N7 m9 P6 h<><FONT color=#ff0000>函数名: outportb </FONT>  S  R2 O5 A1 G$ h' D; D# b" ]
功 能: 输出字节到硬件端口中
* |: a) b. W$ g5 h3 n, Q4 `# t  Z用 法: void outportb(int port, char byte);
% `1 k! }% S0 Q6 \程序例: </P>
) r$ N1 \& |+ @  f. `2 M<><FONT color=#0000ff>#include <STDIO.H>
2 D/ [4 s; |- N/ y( h( Q) l#include <DOS.H></FONT></P>
: R( h9 }/ a8 x% B- b<><FONT color=#0000ff>int main(void) 1 C" o4 ^2 U' f$ Z4 D4 B* m
{
0 [3 x, i0 I& g" p7 d& Uint value = 64;
) P5 _4 t# i6 M: b" sint port = 0; </FONT></P>
1 B: u. d0 D( [. X- b<><FONT color=#0000ff>outportb(port, value);
$ h# j: Y) T3 @/ Eprintf("Value %d sent to port number %d\n", value, port);
2 z; S' J: U9 O, h  Q5 f4 yreturn 0;
  d* p' a. Q: S% D" X" b  x}
2 _, o- H: K+ N0 x- h</FONT>' T9 @" q5 B% a
</P>
' v) I7 g# \- s" M. J. J+ H( [: |# W<><FONT color=#ff0000>函数名: outtext </FONT>/ o+ m/ O! L# N& d0 y
功 能: 在视区显示一个字符串   E0 r. g2 b1 h- o, Q  b3 h
用 法: void far outtext(char far *textstring); + t- n: w1 m" A2 I. P3 d4 z
程序例: </P>' q: D4 f4 E) \" S+ X# k
<><FONT color=#0000ff>#include <GRAPHICS.H>. I7 Z2 W1 K- E' a" L
#include <STDLIB.H>5 p4 r) I* F! Y0 V
#include <STDIO.H>
% ?  I9 C' ^2 V9 O#include <CONIO.H></FONT></P>9 B3 P7 l6 v1 ]
<><FONT color=#0000ff>int main(void)
+ |! n) [8 v: K  C  v' ~{ 2 \) N5 R5 e, `/ x5 E
/* request auto detection */
4 _8 _) R; H+ Q' A% Rint gdriver = DETECT, gmode, errorcode; & `  E4 {  Z& M4 v1 k) P. v
int midx, midy; </FONT></P>- [' B6 \# R  v2 b( z* T! b
<><FONT color=#0000ff>/* initialize graphics and local variables */
, z4 K% d. T2 d# ~6 j# Uinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>8 g3 ~5 _' }8 C" N! L# h2 t; y
<><FONT color=#0000ff>/* read result of initialization */ 8 T* A  `8 L! z3 o. v
errorcode = graphresult();
, P  g' v% y: C0 K. N. gif (errorcode != grOk) /* an error occurred */
  \. N1 c1 u: f; W" [{ . j" P( g$ q+ Z& i; E7 c4 N; r6 a6 c$ w
printf("Graphics error: %s\n", grapherrormsg(errorcode));
" M/ N' ]: |7 K' l- D) d5 U& |printf("ress any key to halt:"); - |: J0 v) E" D% |4 }
getch();
/ E6 H5 ?& h/ G/ ^; Fexit(1); /* terminate with an error code */ . o8 J8 R. e, x( R4 j7 Q' ~( ]: f5 l% i
} </FONT></P>
; d& j1 z5 ?" Q<><FONT color=#0000ff>midx = getmaxx() / 2;
; b+ N! ]" B) ?% z9 A' @midy = getmaxy() / 2; </FONT></P>$ y0 M( Z" ]* J6 \! y6 T6 U0 p2 q
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */ # P$ g2 k3 V$ }" Y7 C
moveto(midx, midy); </FONT></P>8 A$ k# T5 `4 Z$ y6 O0 W! x; a& H
<><FONT color=#0000ff>/* output text starting at the C.P. */
' ?7 ?) m! y- h' zouttext("This "); , R3 X: H$ x9 a: ]2 g
outtext("is ");
2 c1 N+ Y4 _( h$ Gouttext("a ");
& r# ?7 L4 n; V5 E( k3 l5 ~outtext("test."); </FONT></P>
+ ?5 K9 Z2 w1 |<><FONT color=#0000ff>/* clean up */
; D# {- c8 g7 y+ j  d8 I9 M8 |6 M" Egetch(); : F) N6 M# P4 N. b* m8 _9 K* {+ I& H. c
closegraph();
& }- T/ H* _8 K1 F1 ureturn 0; * W1 k# q/ U* |8 n; F) A7 c9 I
} </FONT>
" o6 j7 X! j( B! e8 j5 {, j$ E
9 k( c9 F# i) X! t5 k</P>
8 ~; o7 W* q" O' ?+ t3 ^$ c: i% E0 @<><FONT color=#ff0000>函数名: outtextxy</FONT>
" Q  d6 y+ o4 j$ _  U功 能: 在指定位置显示一字符串
/ h' u; Z5 Z0 D5 Y用 法: void far outtextxy(int x, int y, char *textstring);
% e/ |: X8 R& S  v6 ?, s/ v2 ]程序例: </P>7 x4 X' y# J( P9 B) i* {9 G
<><FONT color=#0000ff>#include <GRAPHICS.H>2 d! ^% a+ k, Q% `' N
#include <STDLIB.H>
: ~3 q$ G. [5 j, `7 z; l#include <STDIO.H>, ^/ F* k* V9 O5 I% G* L# k5 j; f
#include <CONIO.H></FONT></P>
# z3 ~: C5 p3 T% ~; }# Y& p<><FONT color=#0000ff>int main(void) 5 X4 c" D$ p: [0 \* }
{ $ i; F9 D: V3 x7 P% P& Q4 A
/* request auto detection */ 9 \7 \7 a; C: _
int gdriver = DETECT, gmode, errorcode; " O" q% ?  ]! }* n
int midx, midy; </FONT></P>" i1 U% V* V7 o* E$ F6 V& l
<><FONT color=#0000ff>/* initialize graphics and local variables */
& i( Y, _; r" minitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>: r% A5 A* t9 S) G# K
<><FONT color=#0000ff>/* read result of initialization */
: r9 w' p+ ]5 W4 r( B9 w8 ]5 E5 perrorcode = graphresult();
" r" e$ I* m0 @# J$ L4 J4 j! j0 n; V/ J) wif (errorcode != grOk) /* an error occurred */ : y, e. G, _' c
{
( z+ Q( T' X% U. S4 G, Q3 \7 lprintf("Graphics error: %s\n", grapherrormsg(errorcode));
, E5 r, j2 x9 dprintf("ress any key to halt:"); 4 h" d' k) G6 e: E
getch();
1 `1 q& i3 m* P- E1 n1 O, Cexit(1); /* terminate with an error code */ + b+ L7 k% l* ]. H
} </FONT></P>
! Q; ^( T% i5 A- k. Y<P><FONT color=#0000ff>midx = getmaxx() / 2;
  y% K! a( A# |. p: f# O3 Bmidy = getmaxy() / 2; </FONT></P>
( U. j) L& U; Q. C9 h, \( b2 _! l<P><FONT color=#0000ff>/* output text at the center of the screen*/
% m( ?7 C, o0 p2 C/* Note: the C.P. doesn't get changed.*/ * F8 N3 K: }9 }9 W, u7 G
outtextxy(midx, midy, "This is a test."); </FONT></P>/ ?; V+ k' b1 a: f
<P><FONT color=#0000ff>/* clean up */ $ A, o% {8 X% y% k; g( n
getch(); 4 R. O) o1 l4 S* S$ b, j
closegraph();
' {3 O9 U1 E' M: B4 G5 k$ rreturn 0; 5 m% D' h7 @# d" b/ k% y& m
} </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 17:04 , Processed in 0.418789 second(s), 53 queries .

回顶部