QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1727|回复: 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>! y- a* b/ N& U1 I. l
<><FONT color=#ff0000>void normvideo(void );
' L$ N$ e/ P2 L' K7 d8 h</FONT>选择正常亮度字符。( N: m1 }( Y' I
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
. K* z$ ?& @  k1 |" m8 R# O  M+ q+ h+ y( J. d3 O5 [) r' G8 ^

. u6 E3 b+ m5 `1 I<><FONT color=#ff0000>void nosound(void );' V" ^* s5 o% f  r5 B$ q2 V/ L
</FONT>关闭由调用 sound而发声的扬声器。2 K5 j+ |7 J7 u" k& n/ q6 u$ ^. Q
</P>& n5 @6 g% B1 f
<><FONT color=#ff0000>函数名: open </FONT>- |$ O/ Q3 y5 r* v8 V
功 能: 打开一个文件用于读或写
- w3 n: d; ~0 y: `, v0 O用 法: int open(char *pathname, int access[, int permiss]);
4 i3 [# @" H- C7 [6 P, m1 G程序例: </P>- J8 [; U5 b: m. o. ]6 l* f
<><FONT color=#0000ff>#include <STRING.H>' R9 n' Z! ?+ |. j
#include <STDIO.H>( ^. c& f& z) s. A" d/ f4 V4 N' a; T
#include <FCNTL.H>
! ]: O' L- k& {! P+ D4 j#include <IO.H></FONT></P>
# V! P: J( e6 J<><FONT color=#0000ff>int main(void)
# c- E6 a+ A7 b; h0 \{ 1 H- o' `# a& e, S+ T; H4 C
int handle; 8 a  k4 l' _8 t* i+ M7 y7 i; o
char msg[] = "Hello world"; </FONT></P>
3 v+ i: @, H, [. A6 J' n<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
8 h0 N/ E; \1 w' b1 t9 @( C{
% I  q" u# d0 Kperror("Error:");
7 ~) W; `" m. [5 Mreturn 1; $ @; q( D( I# t# Q1 C* T$ @" B8 U1 T6 G
}
9 H* {7 ~2 N1 g" dwrite(handle, msg, strlen(msg));
& Z/ ^8 v0 z) `# r) k* Zclose(handle);
% ~3 p# S, {8 ^/ Ireturn 0; " B- r" i# z0 d* k" c
} 9 N# w& x& B% Y( ^: [0 q
</FONT>: Y; {  A7 T% {4 @& V. F9 W
</P>
2 n9 q+ [7 }- u/ V4 o<><FONT color=#ff0000>函数名: outport </FONT>9 q9 {/ I5 Q) y% u: q& S+ |* U- _
功 能: 输出整数到硬件端口中
9 l; A6 v- A- ]$ f用 法: void outport(int port, int value); . B! L* B+ c) H. E7 E
程序例: </P>
& G- v4 r! Z, z  U<><FONT color=#0000ff>#include <STDIO.H>$ H6 w4 K1 K& x, _$ V
#include <DOS.H>/ x$ X. z: V1 Q6 F
</FONT><FONT color=#0000ff>int main(void)
0 G- W7 d* b4 W! s7 i{
/ D! r1 A- q' z" Y$ g/ k# K' d5 [int value = 64;
) Y/ F- q* S6 c% Fint port = 0; </FONT></P>  I. e6 B3 c  {& i2 G' O( J
<><FONT color=#0000ff>outportb(port, value); 7 H! Q' s& {- e2 S1 g& c; }
printf("Value %d sent to port number %d\n", value, port);
9 V( ]) u/ y* x/ J( N3 d: jreturn 0; * u; L! ?. k% c& Y2 n
}
$ M+ ^' K: t& y# w1 V</FONT># g$ C7 H. M9 d
</P>
" H, d( f8 t% D2 F) K<><FONT color=#ff0000>函数名: outportb </FONT>
, W  r1 {' p2 k) t功 能: 输出字节到硬件端口中
: B3 H) y* o$ I6 @  V( y  x) U" W用 法: void outportb(int port, char byte);
: ~8 f& f% \& H程序例: </P>
' k& G2 Q, W# F<><FONT color=#0000ff>#include <STDIO.H>
  D; @. }6 P# Y#include <DOS.H></FONT></P>2 S+ P& b3 \0 S4 h. ~; |6 a$ ^6 p1 ^
<><FONT color=#0000ff>int main(void)
% N, A. s6 w: ~! c6 X{ : ^' n5 i$ P8 A6 u' p9 v
int value = 64;
5 W/ {, D5 I+ j1 f. R0 Jint port = 0; </FONT></P>
. V7 \; T' C1 k) e1 U<><FONT color=#0000ff>outportb(port, value);
5 M, F- M% r+ \printf("Value %d sent to port number %d\n", value, port); 4 d* M! H6 t: x+ A3 Z' i
return 0; ( [; w: A3 T( t' X& T2 G) y
}
# ?, F. R- I9 t) [/ f" S/ l; s</FONT>
. Z1 C& q% Q% T$ m1 D' |. n) i</P>
- x1 s4 Z( }& T7 K3 Z<><FONT color=#ff0000>函数名: outtext </FONT>& @: V/ ?& k9 ^6 y7 M: O
功 能: 在视区显示一个字符串 ( ]) V9 j' R( w& D( g4 x2 ^
用 法: void far outtext(char far *textstring); & K& Y) o  H, q# V4 A+ |6 @
程序例: </P>
, ~& L. m+ ]1 F( C<><FONT color=#0000ff>#include <GRAPHICS.H>0 \/ ?3 A5 H+ a
#include <STDLIB.H>
  b$ Q3 V4 }  e) O4 L  k#include <STDIO.H>
1 N4 v0 K" a, `; u! T- n#include <CONIO.H></FONT></P>0 y7 Z* G* e+ @2 v1 X
<><FONT color=#0000ff>int main(void)
- w% o* F0 Y; y' o8 b" G7 p8 _{ ! X5 k" ~" H& N
/* request auto detection */
1 z0 c+ J3 y' k: T, J2 hint gdriver = DETECT, gmode, errorcode;
# m3 l0 o3 J; o+ dint midx, midy; </FONT></P>2 t% b; O0 \2 J" w
<><FONT color=#0000ff>/* initialize graphics and local variables */
  H& \: g9 W: k. o# I: t# r8 {% yinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>% L, b, V3 {& G4 U
<><FONT color=#0000ff>/* read result of initialization */ - _' {2 c8 t& ?
errorcode = graphresult();
6 N* `- |/ T3 u' y( qif (errorcode != grOk) /* an error occurred */ * B( N$ [) I8 ]8 D
{
( X: K7 r8 q" Q' h3 t) dprintf("Graphics error: %s\n", grapherrormsg(errorcode)); ' q8 E8 L5 u' ?2 C- @: u7 |
printf("ress any key to halt:");   g' ?9 b/ P- S8 w: e" ~
getch();
* p# f" m9 m( ~; i' A5 B! @5 Cexit(1); /* terminate with an error code */
1 w' s4 J' S3 s} </FONT></P>
8 D2 S" O. j/ x9 l) F" K% T<><FONT color=#0000ff>midx = getmaxx() / 2; . |3 ]4 n# s# _7 U
midy = getmaxy() / 2; </FONT></P>
& p7 v. }9 d: b& \% S<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
  U) a3 i5 M0 W2 ~  Q* @moveto(midx, midy); </FONT></P>8 T! C4 F' j# J" V) f  m  S
<><FONT color=#0000ff>/* output text starting at the C.P. */
$ i0 a* x) k8 u3 touttext("This "); . o1 G5 B8 ?/ }0 t+ o; J
outtext("is ");
8 `8 P$ J- U4 i+ i" a- T) V  nouttext("a "); 4 G# }& t* z1 P& X* _, ?
outtext("test."); </FONT></P>
7 E4 v: L* M7 m, J; x6 {<><FONT color=#0000ff>/* clean up */
, C) p2 X- h! |1 O8 U$ ~5 H) U2 jgetch();
% c0 o2 A$ T# g# Lclosegraph(); 6 k  I) T6 B1 `: U# m/ M: S
return 0;
/ g, J7 n. Z2 M} </FONT>
" W4 N/ E6 C  L$ |- |2 Y& _" i) ^6 p6 q2 D. R/ D: }% w% t7 Q
</P>
; `2 u3 b9 D9 U- S$ d<><FONT color=#ff0000>函数名: outtextxy</FONT>
& @2 I' R: e1 ?5 I' x# m6 c* O/ q功 能: 在指定位置显示一字符串 & Q! S# D9 S6 N  `9 @, P
用 法: void far outtextxy(int x, int y, char *textstring);
0 O/ o: i$ u" P* d程序例: </P>% w1 F/ d) [* R# S' p4 M3 `& N
<><FONT color=#0000ff>#include <GRAPHICS.H>' J4 v! E8 j) d+ J
#include <STDLIB.H>
& [' q% l! Z, q" K! y3 T#include <STDIO.H>. h' j6 W% ^) h/ X5 q* i3 z
#include <CONIO.H></FONT></P>9 ?, q. {8 E1 D: n1 B# }$ y
<><FONT color=#0000ff>int main(void)
# M/ D  Y. z9 n/ ^{   U2 o2 N& Z3 N+ I& V; v3 }
/* request auto detection */ ! n" y" o  |: w) h& m
int gdriver = DETECT, gmode, errorcode;
, P9 g9 _8 t2 T1 A2 n6 Vint midx, midy; </FONT></P>7 u) [- q( e- d, g
<><FONT color=#0000ff>/* initialize graphics and local variables */ ; d. S3 r4 [1 e. m
initgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
- s% o/ x* \% U& }# {0 T1 w<><FONT color=#0000ff>/* read result of initialization */ ! `/ ?6 |4 X5 q" ^
errorcode = graphresult(); 3 {4 I  f/ g6 n& `. p# R! b; T2 z; d
if (errorcode != grOk) /* an error occurred */ 0 m9 A) j- `( B% T9 V. L0 [* ]
{
0 e( P' ?. i& b: S- N8 i; sprintf("Graphics error: %s\n", grapherrormsg(errorcode));
5 D( U  K" w* V# H- Vprintf("ress any key to halt:");
: |+ s6 G4 ?# F% g3 l) X1 ]getch(); $ t* s% p, U. o  f: [" D1 G
exit(1); /* terminate with an error code */ 4 n; {0 L4 Q5 |" @3 g& H
} </FONT></P>
& V$ u8 J$ f; E  `<P><FONT color=#0000ff>midx = getmaxx() / 2; 9 k4 p, }( g, s2 B6 V
midy = getmaxy() / 2; </FONT></P>
0 E9 X5 D0 C9 a  u& M<P><FONT color=#0000ff>/* output text at the center of the screen*/ & q% d! A9 {' W, q
/* Note: the C.P. doesn't get changed.*/
+ Z- F# s3 n; U8 W( T  G6 }+ fouttextxy(midx, midy, "This is a test."); </FONT></P>, U( y$ L( ^9 q; ~8 F4 {& h' ~+ Z
<P><FONT color=#0000ff>/* clean up */ . M  y" P7 j) @. D. y
getch();
8 E1 B5 y! i, Tclosegraph(); ( Z3 l- B& d/ d- }6 D, j  u
return 0;
" T# R( m1 O1 m# I) l. J9 a} </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-6-13 04:35 , Processed in 0.635874 second(s), 52 queries .

回顶部