QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1724|回复: 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 U! }: z' N! p: @3 g<><FONT color=#ff0000>void normvideo(void );
$ m/ Z  p/ O# \# S</FONT>选择正常亮度字符。
% ~/ y' `& D. v将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
6 J9 J; D7 O& ^1 z, z" N2 C  Y+ i1 r/ G! I) l  x8 P( G

/ Y$ W$ ^( t1 P2 t<><FONT color=#ff0000>void nosound(void );3 [% i: J  n+ \0 f
</FONT>关闭由调用 sound而发声的扬声器。! j6 H2 i" x+ e9 B& C6 q7 f
</P>
" j9 j& ^2 N2 h8 b: r4 `. Z<><FONT color=#ff0000>函数名: open </FONT>
3 T) N! b- `: ?功 能: 打开一个文件用于读或写 . P, n9 w/ O3 \4 Q( N' G
用 法: int open(char *pathname, int access[, int permiss]); ' t! ], @( e) N6 I0 |
程序例: </P>
% i9 |! J) h6 ~$ d<><FONT color=#0000ff>#include <STRING.H>
. V; k9 [+ }$ o3 U+ F% {1 T, b#include <STDIO.H>( O! |- W# ^) t7 J2 \# E/ {2 ^- G
#include <FCNTL.H>' ?5 m+ ?! `% M4 |/ E, |
#include <IO.H></FONT></P>
2 [, M0 M( b- T: U8 e; K5 T7 J$ a<><FONT color=#0000ff>int main(void)
3 w0 D4 ]- m) X; p; F{ * ?- _5 P7 K+ \) {
int handle;
! w: R- A0 ^* ^! S  p0 Mchar msg[] = "Hello world"; </FONT></P>
+ G3 V8 F3 m  ?# c: O- y<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
; ?' x5 b3 O2 ]" U  r{
: `5 i' g" J% ^; |: ?. Eperror("Error:"); 7 _' f8 H$ P/ x1 F8 e( s
return 1;
- W7 T( T% D) k1 p; ~# P' S} 3 P3 Q. S8 f9 @$ m, c( V
write(handle, msg, strlen(msg)); ; t% T2 t1 j. o
close(handle); 9 X' }: j% @( a/ o$ M
return 0;
8 L3 O3 F' s* u7 ]} + X3 C3 V3 L: \# e
</FONT>
% v, |9 ]# L, l+ Z# \</P>
% P; W" y$ h$ |  Q<><FONT color=#ff0000>函数名: outport </FONT>  _4 f3 I9 s2 ?8 w, ]& B
功 能: 输出整数到硬件端口中
" r4 W" c& t1 M4 K! r! D% ^. h用 法: void outport(int port, int value);
5 s3 }; _9 u9 ~  e" M2 j5 j程序例: </P>
* n3 [+ @0 K& h7 O<><FONT color=#0000ff>#include <STDIO.H>
! L) v. k, a' ^" c7 h( K#include <DOS.H>
. }. }6 v: @! C</FONT><FONT color=#0000ff>int main(void) 8 u7 q- F" W. G2 I* H- z
{ 3 `: y% f: d3 D9 R8 B) j
int value = 64; & e7 j& d5 y' l! K# \
int port = 0; </FONT></P>9 N( ]! k% F# _
<><FONT color=#0000ff>outportb(port, value);
& t, w$ ?) \$ u- E  [2 Fprintf("Value %d sent to port number %d\n", value, port); 5 D4 [; n/ X8 f) L0 i2 x$ N' j
return 0;
% t1 Q  r  n- i( U/ ]8 E; z} 2 j  F7 _! N) f
</FONT>7 z* f- f( g6 w# j8 ]6 z
</P>- Q) g2 f4 g2 c* ?- ~! m1 l& v
<><FONT color=#ff0000>函数名: outportb </FONT>4 V) B' }" Y% o2 p  G2 R% L8 C5 P
功 能: 输出字节到硬件端口中 " e: R0 v' S& s* N( S
用 法: void outportb(int port, char byte); 2 f* D7 ]) [/ U
程序例: </P>: \8 Q9 ?# q, m4 G* Q
<><FONT color=#0000ff>#include <STDIO.H>
2 H1 ?% v0 Y2 y! _. s) z#include <DOS.H></FONT></P>4 o9 m* Z9 W, M! I$ h
<><FONT color=#0000ff>int main(void) & v3 H* n5 }0 I% H; a" z  y7 j4 C
{ % H' w5 k2 K$ K4 t
int value = 64; 5 |* I. d& ^0 ]0 N) m9 l$ g
int port = 0; </FONT></P>
" g  j# [/ T) `1 e/ x1 Y<><FONT color=#0000ff>outportb(port, value); 4 G4 O& B; M- z6 o8 S
printf("Value %d sent to port number %d\n", value, port);
; o; k" \6 i! |. Xreturn 0; " z- K$ Q' F  P4 i& i
} 8 g# X2 V5 N4 F* ]0 G6 s
</FONT>, \- ~) G# Z3 W2 w, y
</P>
4 ^  n( D8 W, M& l<><FONT color=#ff0000>函数名: outtext </FONT>  L! B5 @& J* ~! {" u: p0 |
功 能: 在视区显示一个字符串 1 K0 x: V0 \5 T( {! d1 }
用 法: void far outtext(char far *textstring); + e$ C+ ]! s, |- S2 C, m
程序例: </P>
* [9 H5 `- n6 {: B4 |<><FONT color=#0000ff>#include <GRAPHICS.H>8 J( V) @6 C$ b9 S
#include <STDLIB.H>
* M% E0 d  u3 [! Z7 X1 S9 @; B#include <STDIO.H>" p1 d$ W6 F0 {; ]+ \
#include <CONIO.H></FONT></P>
1 N: ?; H2 ^; t+ w<><FONT color=#0000ff>int main(void)
5 s6 T! C% ~- }  s' K9 ]; }{ 0 K% P' h; T8 z- ]9 O2 z
/* request auto detection */   j% J  ^0 S& r5 _; Q
int gdriver = DETECT, gmode, errorcode;
9 ?( j% C9 `) ^4 Aint midx, midy; </FONT></P>
5 P- z; W$ p0 I! D% {<><FONT color=#0000ff>/* initialize graphics and local variables */
/ y# {/ L0 I; b8 ~2 ~1 R. u# rinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
+ `' Q! R. s$ G8 ^* l. j<><FONT color=#0000ff>/* read result of initialization */
  y+ y+ M6 h$ o9 W, oerrorcode = graphresult(); : \4 D8 w6 Q* n- w: K$ [
if (errorcode != grOk) /* an error occurred */
7 u- i& S1 J# `) g3 z  S{
6 N7 T' Y3 L1 x0 C% X- hprintf("Graphics error: %s\n", grapherrormsg(errorcode)); & D" ]/ D- F- x8 L: m; {9 d
printf("ress any key to halt:"); 4 R: ~2 d( B8 C) w# ?
getch(); ) }' w" j6 @9 ?
exit(1); /* terminate with an error code */ - x' _5 y' h5 Z$ {4 I/ G- m
} </FONT></P>4 \4 o0 G4 Z, y/ m7 I2 d: h; ^
<><FONT color=#0000ff>midx = getmaxx() / 2;
# d% b8 w) p: w2 f4 V# Wmidy = getmaxy() / 2; </FONT></P>
( I% `' d, q7 Q/ m0 m8 m( b. Z<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
: b  j0 z2 X- ^5 U* H/ w1 k6 F* cmoveto(midx, midy); </FONT></P>4 B2 d) G$ f: M8 \: J$ d* q
<><FONT color=#0000ff>/* output text starting at the C.P. */
6 W- E" R, W. E2 \0 Fouttext("This ");
9 l* |- I$ _& E3 g2 }% zouttext("is "); - ]' Q+ {1 K7 o7 w: Z$ C
outtext("a ");
) I4 K. [  V0 A( e& ?( U2 P1 Douttext("test."); </FONT></P>0 t: P4 j2 `/ h9 ?2 M) f7 S0 C) C
<><FONT color=#0000ff>/* clean up */ ) a2 ]# _4 \; z: w
getch();
* c$ W7 N0 t& S9 i/ D7 N$ G7 pclosegraph();
4 O- V( B2 e; X: P3 w' M8 S  c* Zreturn 0;
3 e+ w( Y( H: j7 e/ ?} </FONT>8 i. N2 X9 n3 W/ |* n1 L8 G

' a4 [' O* b" G5 G! r</P>
; o6 Y- b% T5 o" C! U* h<><FONT color=#ff0000>函数名: outtextxy</FONT> 8 b" c$ c- [( L, v9 k! I
功 能: 在指定位置显示一字符串 5 D0 i4 F$ D* S% J
用 法: void far outtextxy(int x, int y, char *textstring);
  l, M% {! s! U3 U程序例: </P>
6 O7 J3 h4 x+ F' {6 s' P! Q<><FONT color=#0000ff>#include <GRAPHICS.H>
  j. M  S" J6 N5 Y0 s#include <STDLIB.H>
2 j% B" y+ Y5 _' n9 ^#include <STDIO.H>
+ m; t# X9 M9 J5 E" k#include <CONIO.H></FONT></P>
* J/ j: r' {1 r  h* M<><FONT color=#0000ff>int main(void) $ t+ E* t0 ]. |# [& J8 Y8 `4 u
{
8 k4 Z# U" W* m/ x$ f6 ]- ]/ \' ~/* request auto detection */ 1 p: @6 m1 D8 S8 r* E
int gdriver = DETECT, gmode, errorcode;
: @4 v6 x  Z( W& X  |9 {1 `int midx, midy; </FONT></P>& m  ?$ L' s2 t! F& x( B; e$ t- C
<><FONT color=#0000ff>/* initialize graphics and local variables */ ) W5 O2 [9 T+ a3 O$ @, ^4 r- H% y
initgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
) [& @* |; H" n: r<><FONT color=#0000ff>/* read result of initialization */
" T$ l" |( [/ |& o0 C1 perrorcode = graphresult();
! z: i) ^9 M0 zif (errorcode != grOk) /* an error occurred */
+ ~5 O1 Z: z& W' r; [{
' S1 a# y2 j0 cprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 4 @+ z" l: A5 O9 C
printf("ress any key to halt:"); + `" _, {% E3 Y8 Q  n8 e1 J
getch(); 2 p2 \  P8 W7 F" H" Z; g
exit(1); /* terminate with an error code */
3 g  B# A- k6 i4 F; z2 V" t4 e4 n} </FONT></P>
7 |1 \; M& x3 U  w. p4 }* m" W<P><FONT color=#0000ff>midx = getmaxx() / 2;
# Y, P6 e* Z7 f! v0 C0 {1 ]midy = getmaxy() / 2; </FONT></P>
9 `; \+ w. W" r<P><FONT color=#0000ff>/* output text at the center of the screen*/ ( I: P2 p0 ]% j9 b
/* Note: the C.P. doesn't get changed.*/
. V& {* X  L( P) Souttextxy(midx, midy, "This is a test."); </FONT></P>
$ f: U, g0 v0 `# i<P><FONT color=#0000ff>/* clean up */
) _+ a$ Y0 Y8 I& W* N" [/ [+ z7 Bgetch();
2 S  k. {; i5 b: k$ u! F- ^3 Yclosegraph(); 2 N1 s* ?' u7 g7 i  [" \
return 0; 1 t  o$ I/ }. o9 Z
} </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-11 07:26 , Processed in 0.402904 second(s), 52 queries .

回顶部