QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1729|回复: 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>
6 H: R+ @( e+ @& ]* y<><FONT color=#ff0000>void normvideo(void );- D& k- C, j. o
</FONT>选择正常亮度字符。
8 F# ^: Z* a. m; z  z将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
" w- c- D" W5 f% f% _7 E- K, r; m: p; S& I/ _& f0 W4 B! y# D1 A2 i

& ?6 L3 b8 T( J( x/ C<><FONT color=#ff0000>void nosound(void );' d' ?* b! O4 _1 N5 U
</FONT>关闭由调用 sound而发声的扬声器。2 C/ \: e( m+ z" I, k2 z+ e
</P>
# K! R4 a* w3 V0 ~3 {7 i% Y<><FONT color=#ff0000>函数名: open </FONT>
" U4 d& R$ H& t4 Z5 j6 H- y功 能: 打开一个文件用于读或写 : U. X2 s: Q$ }2 y1 P
用 法: int open(char *pathname, int access[, int permiss]);
+ C2 ?. S, i6 Z' ~) Z程序例: </P>8 C) C% C2 K1 \+ `6 J" N6 ?
<><FONT color=#0000ff>#include <STRING.H>  \/ G7 ~: a" A( z' @; `  \- w
#include <STDIO.H>) {, b6 N4 D) E* f: E: _* s! ~
#include <FCNTL.H># ~8 p4 \* t" h; M, g* b6 u" U
#include <IO.H></FONT></P>$ u5 g. c+ s, m8 C
<><FONT color=#0000ff>int main(void) 4 w. y1 a& w+ ]0 ^. x( K
{ ( W) z( d+ Z2 t7 @, b. n
int handle; . g: a% q! G; `# W3 K
char msg[] = "Hello world"; </FONT></P>! p$ S: q) Y0 u$ O! ~: I
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
- A2 D9 R7 [$ v1 D% B5 l, }& U{ 8 o: b4 e% x( b6 W. v' y3 ]0 R) b
perror("Error:"); - x  ]6 y/ ^. ?. _6 |# l
return 1; 9 f' E, `: b0 z
}   h$ a: A7 N8 W. A5 ^
write(handle, msg, strlen(msg)); ' _+ F( S& u3 }; [3 t! G; O
close(handle); " `# e# D3 ~- S- E; v; ?# F5 t# D6 e( Z
return 0;
' t9 t  x$ M$ }$ a} ! F% m6 F  g4 w2 l% a& A+ a
</FONT>5 M8 h5 {0 a% v. T$ H2 t
</P>
. R! M5 F  ]1 G3 u' U+ X- d<><FONT color=#ff0000>函数名: outport </FONT>3 V4 t. @) y0 E) n; d+ w
功 能: 输出整数到硬件端口中 ( U. b, K  r" j) ~8 u8 H$ W1 _; B
用 法: void outport(int port, int value);
  _+ q: _: z: u9 G8 {0 {6 Q程序例: </P>
/ s! ^# X" X( L8 V& J<><FONT color=#0000ff>#include <STDIO.H>+ [/ r$ F- y, S. O( ]
#include <DOS.H>, u: e& g9 B) `, J5 u% p" ^$ M4 c
</FONT><FONT color=#0000ff>int main(void)
1 E  `& @, |6 A& S9 \{
( A$ |: k- I4 xint value = 64;
$ o" l5 q  }# }: J* lint port = 0; </FONT></P>
% x, {4 l' ~% `! [<><FONT color=#0000ff>outportb(port, value); " l# h' U* {: O7 ^9 @
printf("Value %d sent to port number %d\n", value, port);
" S& j# u# C& X# `: v( w1 p& J6 B6 dreturn 0;
2 Y" [. L9 k- x3 W} 4 X+ |! M  L# p/ X- {% h, O
</FONT>
3 l& ^" q' s' h$ [+ z</P>% r; b; Y2 D. k7 A- q3 e- B
<><FONT color=#ff0000>函数名: outportb </FONT>
+ _0 k7 F1 A1 Y+ m6 D% _& i功 能: 输出字节到硬件端口中
1 s6 F7 R" P/ W" ?' O9 l; n# q用 法: void outportb(int port, char byte);
( H& v* p  S4 P7 R3 @; j程序例: </P>
' H4 P' i+ V) c1 n* h5 a6 g7 T<><FONT color=#0000ff>#include <STDIO.H>6 w  ^3 m, o2 ?! j* ]% I# ?
#include <DOS.H></FONT></P>
3 }! b9 H& E# k. j8 A<><FONT color=#0000ff>int main(void)
2 ^1 Y7 n: z( N* b$ V" m{ ( r9 d0 ^2 o4 ]# J0 w+ q
int value = 64; % M1 u( l+ n7 j6 D6 n4 L' N* f# n
int port = 0; </FONT></P>" p; s- H) F' H
<><FONT color=#0000ff>outportb(port, value); # P& c1 a. ?$ d- Y3 i; m3 G6 L
printf("Value %d sent to port number %d\n", value, port); : ~/ S9 I6 f1 w. n/ y
return 0;
1 s4 _8 C5 I) s3 T+ f}
" y. A+ f' V% ~</FONT># M$ o- Z5 _( n) d1 L
</P>; t+ X0 I+ q- @& N  F) |
<><FONT color=#ff0000>函数名: outtext </FONT>5 e; s* g" |' a  a9 p9 s/ r
功 能: 在视区显示一个字符串
) V& T3 o- ?+ j0 k  {# M7 b用 法: void far outtext(char far *textstring); 9 w, t+ f/ I; N
程序例: </P>. Y( g# ^+ O9 h( t
<><FONT color=#0000ff>#include <GRAPHICS.H># I6 ]7 x8 S% U& E& l# E5 {
#include <STDLIB.H>
6 K! D  E* n! E  K! Q- J1 p' Q' i#include <STDIO.H>
0 ?2 t/ K, ^; N/ g#include <CONIO.H></FONT></P>" A0 }- [9 a1 h4 g; V. F' D2 e( G: f
<><FONT color=#0000ff>int main(void)
( ~) ~1 ^  h9 t6 j# f; a+ y{ ' e/ U3 \4 p9 g) J& P  w6 N
/* request auto detection */ 9 P2 j" ^$ O  X8 @! A: \! x& p
int gdriver = DETECT, gmode, errorcode; 1 a2 }, E5 D( R2 q( @# P/ `
int midx, midy; </FONT></P>
1 b% d2 m1 f4 _) g7 M+ }, g) [8 b<><FONT color=#0000ff>/* initialize graphics and local variables */
, R4 R. g7 O1 Z# W3 X6 Vinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
, F  g8 b6 x- C4 X8 l6 ~4 C2 p% P2 v<><FONT color=#0000ff>/* read result of initialization */
5 A% P5 q( _4 y$ D9 [, E. serrorcode = graphresult(); % A# z4 W# f/ T! v6 O3 ?0 m1 n
if (errorcode != grOk) /* an error occurred */
9 p8 [7 Y* y# Q! b5 _{ ( l6 e* t5 Y3 f: Y5 R; q
printf("Graphics error: %s\n", grapherrormsg(errorcode));
  R; f* M; g- N/ M$ O* Sprintf("ress any key to halt:"); 6 `2 M6 m" G+ F/ }8 L/ c# @+ ~
getch(); & f: F) n9 m& R7 @/ v
exit(1); /* terminate with an error code */
- I5 v3 @/ u" n! @1 {) t} </FONT></P>
* ]' }% v1 M1 s% r2 f3 x8 E: d<><FONT color=#0000ff>midx = getmaxx() / 2; # V: E  n3 K4 w7 N5 S: d
midy = getmaxy() / 2; </FONT></P>& `2 B2 Q( M! M
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */ - E# k" u, {8 R0 w5 B  V8 G
moveto(midx, midy); </FONT></P>$ T8 n9 {" T, c7 D) P; y
<><FONT color=#0000ff>/* output text starting at the C.P. */ 5 o- f# V! s5 `6 x7 U3 u
outtext("This ");
4 e  L  r. z7 q( v" N6 pouttext("is "); $ L( d" p& P* {8 O7 g- P! n
outtext("a ");
# y3 X9 L+ h6 `9 J& o+ a8 @outtext("test."); </FONT></P>4 k! a  r' s7 V) L
<><FONT color=#0000ff>/* clean up */ . h4 |- |2 q2 i) F, V2 ~2 _
getch();
% N0 B0 x! n2 h+ ?2 `4 G. S1 qclosegraph();
* b8 N2 U! Y1 C& y+ Nreturn 0; ( Y' Z, M) I$ W( d+ y$ N2 ^
} </FONT>
0 @: K3 R; _7 [  Q
0 H; p1 J* q' Y+ \) T, k4 S</P>" l0 m2 A6 j) y. [
<><FONT color=#ff0000>函数名: outtextxy</FONT> & V* \- [+ x8 ^7 d4 {$ V
功 能: 在指定位置显示一字符串
& G. o9 q+ U8 \. l3 o; R) q用 法: void far outtextxy(int x, int y, char *textstring);
2 s: L! w2 F* D  y2 @, c程序例: </P>
* ^2 [% T: J' G8 [<><FONT color=#0000ff>#include <GRAPHICS.H>
2 b8 v  [' n( K, D( d6 R#include <STDLIB.H>2 B% x3 _1 Z# E$ ]" |/ L& `; B
#include <STDIO.H>0 s4 V$ J# m, O2 t% C
#include <CONIO.H></FONT></P>7 B/ ]/ Q9 r0 r7 ]. Y! r5 U+ N
<><FONT color=#0000ff>int main(void)
" V; W0 K9 P+ ?7 t% y# B{ ! r1 L* K( r% J9 T5 B5 M/ {$ j& k
/* request auto detection */
3 }1 ~$ }  u# H8 A0 ?: F1 N, oint gdriver = DETECT, gmode, errorcode;
) L# E! z& V+ Dint midx, midy; </FONT></P>
  W' l8 o+ B1 X1 U<><FONT color=#0000ff>/* initialize graphics and local variables */
1 f1 U6 g" ~" }& G; u8 sinitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
. ^" r( [# k2 c/ [+ a( z# R8 x<><FONT color=#0000ff>/* read result of initialization */
6 {! y' @( v6 T' Serrorcode = graphresult();
0 F1 v$ o, V$ r3 |$ Zif (errorcode != grOk) /* an error occurred */   o) h' J- A6 c* E' P$ a( H8 a
{ " y) }7 S% Q3 [% b9 M
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 4 S4 \: C, C5 E6 t% G" N! H0 x! ?
printf("ress any key to halt:"); % y$ E+ n  g- a* K5 h
getch(); 1 y( H9 R5 o( c* s
exit(1); /* terminate with an error code */
+ n: s  W3 X: _6 u% f5 \0 _} </FONT></P>
3 F2 {- x: y0 t( ^% `<P><FONT color=#0000ff>midx = getmaxx() / 2; 3 w$ M1 N9 x% i0 U" C# k
midy = getmaxy() / 2; </FONT></P>
+ \' W$ `. s+ O- Z& ?<P><FONT color=#0000ff>/* output text at the center of the screen*/
3 \; {% S# G- f/* Note: the C.P. doesn't get changed.*/ : T9 ]% }/ r# M1 E( J, D. h& K2 C
outtextxy(midx, midy, "This is a test."); </FONT></P>
# w4 W: C3 O9 J$ H/ ~<P><FONT color=#0000ff>/* clean up */ 6 S4 e! z! j, n% S4 W
getch();
0 }# k3 ]6 n( F: p8 l! n' s2 V# Xclosegraph(); " Q1 p# e5 c$ ?5 l
return 0; 2 o2 P% ?) W- P8 l$ g. _% D
} </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-14 10:24 , Processed in 0.401904 second(s), 52 queries .

回顶部