QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1744|回复: 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>5 |- q2 d( P* R
<><FONT color=#ff0000>void normvideo(void );
' j5 ?( |( B: D: W, r! S5 b</FONT>选择正常亮度字符。
  a1 v% I1 `( u' l' Y" n将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
# B: r& Y9 M, }/ i+ {3 }" I, |! ^8 G! g

/ i) c. Q/ E& v) f9 _6 V<><FONT color=#ff0000>void nosound(void );
8 T9 z/ p% i. W; A. ^1 e</FONT>关闭由调用 sound而发声的扬声器。
- ?9 E8 r( `2 l  m" x</P>4 b# M2 i) @/ N  [* C5 e( t
<><FONT color=#ff0000>函数名: open </FONT>* g2 j. n: i  ?; n% V
功 能: 打开一个文件用于读或写 . B' d! w# m1 V
用 法: int open(char *pathname, int access[, int permiss]); 4 A8 X8 T6 @, E
程序例: </P>; {5 M9 o) Y8 Q% o
<><FONT color=#0000ff>#include <STRING.H>
* k8 k3 c7 z! d2 |, k* [  w$ ^#include <STDIO.H>
5 H: j. v1 a% V+ L! q  f  I; x#include <FCNTL.H>
$ J+ p( A7 c0 O- F( r2 f% |#include <IO.H></FONT></P>
" w% M9 [- F% {( A, ]; d) p<><FONT color=#0000ff>int main(void)   t* n/ G) L5 K- a3 e
{ 2 ~( o% g2 h& x- d
int handle;
6 |: v8 c/ b5 H4 n% i- L- [7 ^char msg[] = "Hello world"; </FONT></P>% M7 E0 w% J6 A- p
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
& m8 K; c' g$ L5 t5 r; T4 a3 i{
0 _  q$ ~; V" N1 K  \6 B% T! Lperror("Error:");
; V* Q( f5 m3 L- C# @% N" zreturn 1; 2 \7 t% x2 w! L7 g6 l; O* `! S
}
5 x5 T1 h' r8 I) }write(handle, msg, strlen(msg));
, A1 I0 t. f$ wclose(handle);
- `! p6 R5 m5 C) k' z  m/ Ereturn 0;
3 i: k# r- w, a; q} + Z$ _1 W/ M! i8 |/ a' r
</FONT>5 }: x  ~4 r0 x/ q
</P>/ M- ?7 X- G. S9 f
<><FONT color=#ff0000>函数名: outport </FONT>% K! a, E3 Y. c7 ~. ]3 o
功 能: 输出整数到硬件端口中
/ V4 t. ~! x/ W3 z用 法: void outport(int port, int value);
1 }# S1 V0 S- `4 A$ j程序例: </P>
: c$ Q: V. y5 n- h/ `<><FONT color=#0000ff>#include <STDIO.H>
9 u0 j" }( M( b! ]  }6 S' h#include <DOS.H>' V3 k/ _9 m2 r4 q: w& U
</FONT><FONT color=#0000ff>int main(void)
1 P+ H9 _/ b, ?0 _{ ) F& L! L6 Z0 F3 ^- i( M2 a) {
int value = 64;
$ w$ \1 f& R3 ^( r( Uint port = 0; </FONT></P>. ~+ n3 t* |9 h9 z1 k
<><FONT color=#0000ff>outportb(port, value);
8 e9 O- `" Y5 w8 ?# f$ tprintf("Value %d sent to port number %d\n", value, port); ! }* B# m: G6 R
return 0;
5 j3 p3 M& ~% t2 j4 r} 7 I  u* w, j9 A2 \# ?( }2 E) @
</FONT>
, t; a0 O. g: {8 K0 ]) K$ ~</P>/ A6 C7 [6 n1 z  _& n& `
<><FONT color=#ff0000>函数名: outportb </FONT>
5 M1 W2 p& ~- u功 能: 输出字节到硬件端口中
5 C1 x4 L- R# V9 L- l4 h$ h5 ^用 法: void outportb(int port, char byte); # G& K- j  Y" a) L4 O8 c4 ^
程序例: </P>: k, I# \/ ], |# Y7 R% q0 z+ B7 p
<><FONT color=#0000ff>#include <STDIO.H>
- h. H1 A- k. y: n. t#include <DOS.H></FONT></P>; F2 @$ F3 c# M# [4 h( O
<><FONT color=#0000ff>int main(void) ( |. j1 A) m9 L+ }6 L
{
# z, w" U" r  A3 I$ lint value = 64;
" E3 P( v$ R& s" @# Xint port = 0; </FONT></P>  x! \/ R7 @1 N6 o0 Q7 r
<><FONT color=#0000ff>outportb(port, value); 4 r4 A" \# Z; A1 J+ E' `
printf("Value %d sent to port number %d\n", value, port);
) R9 j% N! s- F6 {* h% freturn 0;
0 i1 h# ]# h1 E1 Q) Z# _" ~} % f3 X! [: g. A. q6 A/ d  K
</FONT>
3 K, v# b" Z9 t& ?* p0 w</P>: u1 K4 u8 b$ y
<><FONT color=#ff0000>函数名: outtext </FONT>
5 _( a( T6 N9 M" C$ _, u+ G3 p功 能: 在视区显示一个字符串 0 F+ B" a1 G6 A8 }* H! ?
用 法: void far outtext(char far *textstring); ) `, F1 U) X; b$ _. Q
程序例: </P># {  v4 l% C+ A$ Q/ x9 e
<><FONT color=#0000ff>#include <GRAPHICS.H>0 {6 {+ Z6 I( D  ~# |+ T6 l: m
#include <STDLIB.H>2 r* f& r9 Y/ p; {, @
#include <STDIO.H>& `& n5 q. Y% |/ p6 k: z
#include <CONIO.H></FONT></P>
& J, p' \7 b. F" x* c9 ]<><FONT color=#0000ff>int main(void)
9 w$ E, B  ?+ I{
: o5 G5 V' ^- _9 S, Z2 f. h! d/* request auto detection */
6 N6 T+ e$ {. c" b, M" aint gdriver = DETECT, gmode, errorcode; ' k: K" [; H& j: S  w) I+ Q3 B
int midx, midy; </FONT></P>  d8 z4 R+ F0 U# z) d8 _5 W7 ?
<><FONT color=#0000ff>/* initialize graphics and local variables */ " O4 L3 Q* ^& k9 E* c
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
9 D* t9 i% l4 b( a1 v, I. _/ n<><FONT color=#0000ff>/* read result of initialization */
% @$ p; `) g; S( c' werrorcode = graphresult(); ! N! u! m0 b% m% f- B' h
if (errorcode != grOk) /* an error occurred */   A6 [7 I  z& i& W) E
{
& `. Q; g/ [+ X+ f7 ~# yprintf("Graphics error: %s\n", grapherrormsg(errorcode));
& M$ n1 K5 N- D9 o8 V& [$ @4 Gprintf("ress any key to halt:");
- U5 e. G; X3 E' _' pgetch(); * b& K: ~  u* ?4 n6 A- u" |2 p
exit(1); /* terminate with an error code */ # y0 D$ i/ M5 q: Y- S
} </FONT></P>
/ j0 Y# Z1 h3 s* \* A7 r# g<><FONT color=#0000ff>midx = getmaxx() / 2; - B! M' e6 A$ @( S4 _- B9 ?9 C
midy = getmaxy() / 2; </FONT></P>/ s/ M* D$ {. H7 i* b
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
2 u  f5 e* x% b4 _* |/ Cmoveto(midx, midy); </FONT></P>
3 }- R' d  S6 y. Z0 h2 ~. t! W<><FONT color=#0000ff>/* output text starting at the C.P. */
, Q2 ]% H0 z7 douttext("This "); 6 d/ _& X6 N2 g5 ]% l; s+ u# p/ ?
outtext("is ");
7 j2 L0 A7 U6 h' N1 O8 q# \outtext("a ");
8 C# r8 d9 ~. l- ^) P( K# Touttext("test."); </FONT></P>
+ H# p8 {8 T. ~- O<><FONT color=#0000ff>/* clean up */ 6 _+ n' y  f- w) b$ z
getch();
8 M4 Y2 Q) c) Z6 p% F) M$ Kclosegraph(); & ~; F8 w, ]8 Q$ W) }
return 0; 9 S, b2 [3 l' q; k& \
} </FONT>3 \6 {0 G/ V/ K( o+ h
; S  t- u: s; i1 v6 a
</P>
" j$ @& E! J' R: a! U/ l8 |( ]<><FONT color=#ff0000>函数名: outtextxy</FONT> 3 J( W! i; W' s
功 能: 在指定位置显示一字符串
  V$ L& A- D* ~用 法: void far outtextxy(int x, int y, char *textstring); ! F  t& }" p- B4 Z
程序例: </P>
! m+ t$ j/ x! ~7 C  ~& `<><FONT color=#0000ff>#include <GRAPHICS.H>5 G$ Q& X) K+ G3 j# e6 B
#include <STDLIB.H>' J0 M/ d, k) L3 {
#include <STDIO.H>
4 N# O9 {3 w4 o0 N: H#include <CONIO.H></FONT></P>
& e# ~, Y& h  R0 y0 c5 e<><FONT color=#0000ff>int main(void) ! a) j* X  k- G) @- ^+ s
{
4 i4 z1 G# ?. {/* request auto detection */
% {0 D% i" ]2 ~2 ~" S  {int gdriver = DETECT, gmode, errorcode; ! q# i8 C" f, V6 t
int midx, midy; </FONT></P>2 ^* o" ~9 j# R
<><FONT color=#0000ff>/* initialize graphics and local variables */ 8 S5 U3 I7 N+ G) h
initgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
2 n- \0 U& D' n2 _<><FONT color=#0000ff>/* read result of initialization */
: Y3 k' [% h, }: u4 S. R3 ?# ierrorcode = graphresult(); ! `. D: b- f. `
if (errorcode != grOk) /* an error occurred */
; [; F: C% ~5 q( u, D, b% F$ e/ W{ + K5 o9 u& N3 N( I; v3 H
printf("Graphics error: %s\n", grapherrormsg(errorcode)); * I) C7 c7 a4 `* x% H5 K
printf("ress any key to halt:");
' l) P! U& G* P/ t* mgetch();
  A* c0 i' X8 p5 i) texit(1); /* terminate with an error code */
4 m1 L4 u; B  o% H+ [" n) U$ f  c% C} </FONT></P>; _" ?3 D0 {* ^6 V0 t; m
<P><FONT color=#0000ff>midx = getmaxx() / 2;
. a; t# J2 {& j! c8 M4 @midy = getmaxy() / 2; </FONT></P>/ n$ o+ \( `, V: [
<P><FONT color=#0000ff>/* output text at the center of the screen*/ " r# a% ?6 Y* y( V. m9 J7 R: W2 j
/* Note: the C.P. doesn't get changed.*/
; C' V8 U" D  L0 touttextxy(midx, midy, "This is a test."); </FONT></P>
' n! b% i) E9 P$ i6 x2 U, k. B<P><FONT color=#0000ff>/* clean up */
  h5 V$ {4 [5 O4 |. B7 f; k2 B( Igetch();
8 g* T9 N! _' Lclosegraph(); / n, P$ O! `+ C# t% ?
return 0; * \" U8 s  Z* V; W, w, O1 ^/ A" b+ F
} </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-7-21 01:39 , Processed in 0.338089 second(s), 52 queries .

回顶部