QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1805|回复: 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>
* M! P7 U: M) h; U4 |<><FONT color=#ff0000>void normvideo(void );
6 e: S0 b0 J5 W( e</FONT>选择正常亮度字符。
4 n! H, V1 _2 a3 q将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>
( v. B: G& r  l
+ n1 _4 h; O" j3 t( ^( Z' Y$ d- n" p' ?1 `3 E3 _
<><FONT color=#ff0000>void nosound(void );
/ V8 G, a( n/ h$ C, |  I</FONT>关闭由调用 sound而发声的扬声器。
5 H8 S: S* w% V</P>
8 z, k8 Z& X" l0 X( u$ P7 G$ a<><FONT color=#ff0000>函数名: open </FONT>* @: W3 O" n7 l  O/ U
功 能: 打开一个文件用于读或写
7 ?! ~& d" Y9 B6 D用 法: int open(char *pathname, int access[, int permiss]);
4 h  L( M+ n- x$ @1 |/ W程序例: </P>
5 R5 v/ f1 u( {<><FONT color=#0000ff>#include <STRING.H>
) a. h+ g) Q- r% \) D4 I#include <STDIO.H>
8 F1 N% w8 \0 _#include <FCNTL.H>
" X, |; e8 m4 _: f2 A0 S- ]#include <IO.H></FONT></P>
5 C, \3 O. v8 S3 p$ U- O<><FONT color=#0000ff>int main(void)
6 ^2 B5 B7 Y' ]4 V# n0 c{
* l" L2 u4 z9 Sint handle; 4 V' G* ~" ~+ S& y7 K5 v3 r# x) B
char msg[] = "Hello world"; </FONT></P>2 P! |6 k% B5 U5 V9 U9 Z
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1)
- M# a' E8 e: A1 D{ 2 t! b/ N0 }( T- w& U
perror("Error:"); % J1 Z: f9 ^; m: j; M
return 1;
6 N6 H% M0 @( {7 ]} . [& B. P+ z# I% s4 v/ E
write(handle, msg, strlen(msg)); 5 M5 G7 L3 L) D; {$ H6 K9 r* i
close(handle); ) c+ W, n! A5 M: W$ R5 C- z
return 0; 4 u9 c8 k3 ~6 b3 Y
} 1 h. a4 y  t' a) u+ \+ }( ^- \
</FONT>, e& G$ s2 r! Z3 v& ~" r2 j* \
</P>
$ z( ?& {6 G/ e6 ^) J, {7 R' w<><FONT color=#ff0000>函数名: outport </FONT>! {/ \  b% m; {+ o9 F
功 能: 输出整数到硬件端口中
5 l) F( @1 V3 ^" g; C: ?- l用 法: void outport(int port, int value);
4 [, c: y% ]. }! k! b程序例: </P>6 x% p# A4 Z( J; Y+ f: j
<><FONT color=#0000ff>#include <STDIO.H>
& ?/ ]) Q0 h2 n; d4 a#include <DOS.H>
  d3 p- O8 F- h8 @</FONT><FONT color=#0000ff>int main(void)
" w9 B0 W0 e: h7 ~& H( D; ^{
) W' I# V+ W5 X' I7 B% G( Uint value = 64; 9 V3 ?, v9 P9 r. m7 C
int port = 0; </FONT></P>
1 `2 U, S2 c6 F7 A2 {" d( y<><FONT color=#0000ff>outportb(port, value); 3 t* b6 n& E+ s0 j# c  O
printf("Value %d sent to port number %d\n", value, port);
; [: F- G; V0 W7 N9 ~/ ^; _return 0; , k8 @: @5 B# u. ~  j4 v
} / g4 q* E9 J+ C0 v4 Y- X
</FONT>
$ H% @4 i/ y& K9 K</P>
/ d: Y* c3 ?2 \& p<><FONT color=#ff0000>函数名: outportb </FONT>
4 c# H2 V4 W' V5 L, \0 ^功 能: 输出字节到硬件端口中
4 ]. B- N! v7 {# M6 D用 法: void outportb(int port, char byte);
1 S6 z6 i) w! M4 A7 Z4 x程序例: </P>
, I/ [' S* `( ?5 @' s+ C<><FONT color=#0000ff>#include <STDIO.H>
( g6 T% X4 W# X# p2 M9 }2 L#include <DOS.H></FONT></P>
6 ^1 l' C6 ]4 O; d4 P' s) T! o% j<><FONT color=#0000ff>int main(void)
$ q3 h# |7 A( V0 K$ T! P0 }{ & |& k4 z  T$ M) I3 g
int value = 64; - |9 X7 |% D% _9 Q/ ~# D4 P
int port = 0; </FONT></P>
/ j- S7 l9 t, n! r5 S<><FONT color=#0000ff>outportb(port, value); 7 r5 m+ m# r' e+ q( _5 X' F4 _2 l
printf("Value %d sent to port number %d\n", value, port); - O8 X& C1 \, I
return 0; ; D* }5 `# \# t: E+ W: ~
} $ P" Q- u1 n' T) y
</FONT>
' T2 G7 P2 B. ?6 j( E9 F</P>) a: O6 Z9 N8 N
<><FONT color=#ff0000>函数名: outtext </FONT>9 @6 x$ D& |1 J
功 能: 在视区显示一个字符串
. a9 n+ P5 T4 \' K$ P4 X8 `- [: z  p4 M用 法: void far outtext(char far *textstring);
! W2 w* ^8 @- f, Q6 a/ h4 j程序例: </P>7 w& ]6 J7 y! }, K7 F
<><FONT color=#0000ff>#include <GRAPHICS.H>
; K8 C9 d, X0 V0 `#include <STDLIB.H>1 y: L* I' X5 e& r9 s  k
#include <STDIO.H>
7 A3 a* @. q; V0 `#include <CONIO.H></FONT></P>
/ P2 U; H& p! c# j5 [<><FONT color=#0000ff>int main(void) : w0 x5 B: q1 E0 A
{ % }* a2 U+ W5 B2 x  i" n2 w4 t
/* request auto detection */ * s3 Y" c: |2 [9 `: n8 T3 ?& H8 F
int gdriver = DETECT, gmode, errorcode; % ~# E$ S- a. N6 w$ X( w8 w' r2 ~" Q
int midx, midy; </FONT></P>
, }7 E, P' S5 S3 Y<><FONT color=#0000ff>/* initialize graphics and local variables */
0 L4 f! a& M& d5 r: m- A+ Binitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>5 G' ^6 X1 S$ n3 q" N
<><FONT color=#0000ff>/* read result of initialization */
, E9 H+ l" `! U4 u8 Z8 Rerrorcode = graphresult(); # h% E' l2 p) h
if (errorcode != grOk) /* an error occurred */ 8 W3 e  a4 `+ S* Z' N# ]; H( V% K' b, ~
{
& ?. {& [* n1 X1 lprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 3 O) v- `2 E1 X7 F" L0 Q- j* R
printf("ress any key to halt:"); ; I3 O" G+ p. y
getch();
$ a$ C* X. E- k; `' Y5 Bexit(1); /* terminate with an error code */
# F: R/ K! h7 y+ {: u1 A0 _} </FONT></P>% A. H: V6 q/ Q4 w) z
<><FONT color=#0000ff>midx = getmaxx() / 2; ' O9 L3 y1 ^. k9 i
midy = getmaxy() / 2; </FONT></P>
5 G# L7 Q1 L& Q' ~, E5 v<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
  l3 k% K2 \* D$ o4 wmoveto(midx, midy); </FONT></P>! P* V/ M' o# t1 S+ B9 ]
<><FONT color=#0000ff>/* output text starting at the C.P. */ " q8 B6 n7 y  d
outtext("This ");
( A- |) ?$ c/ F0 Kouttext("is ");
  d8 d' F. k& v" e( P" Nouttext("a "); ! W7 f7 F3 a+ p4 u
outtext("test."); </FONT></P>
: A, v) P- Z$ s. k<><FONT color=#0000ff>/* clean up */ 9 X6 \; i' L" t0 l2 B
getch();
: ?- @* c- Y( t* z6 k2 L' g6 H' yclosegraph();
  j, Y- X7 c4 M' a- treturn 0;
. X6 ?6 X4 B, G4 q9 a- M} </FONT>
' F, F% I, Z7 o) [6 n- f4 a
8 j3 c8 o. [) l. S2 u0 n0 {) @# V</P>
" O' p1 [7 S; @<><FONT color=#ff0000>函数名: outtextxy</FONT> " h, p+ f3 w+ a. t
功 能: 在指定位置显示一字符串 ( _3 N- y, O3 q" Y
用 法: void far outtextxy(int x, int y, char *textstring);
" ~/ q& ^4 l1 M5 D程序例: </P>
( {5 t% H8 F1 K" o- u  V; a<><FONT color=#0000ff>#include <GRAPHICS.H>
- i" F- r/ P- l: R" s, s6 X0 _#include <STDLIB.H>
5 a% d" k$ D$ g  X#include <STDIO.H>2 G& f: x; B4 C+ b2 R! j7 Z) [
#include <CONIO.H></FONT></P>
1 Y& s! Z  t  e  c$ P8 L/ k<><FONT color=#0000ff>int main(void)   }" t& u8 m- e
{
2 r  s4 E$ r+ |( R. o& D/* request auto detection */
7 ?$ {; x/ H. V& P! B: w8 k* G; iint gdriver = DETECT, gmode, errorcode;
9 S2 n+ N4 ?) aint midx, midy; </FONT></P>  j+ b* j8 j; g6 O% k, y+ U' y
<><FONT color=#0000ff>/* initialize graphics and local variables */
7 o0 N( s0 V0 d5 r' dinitgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>
2 D, Q" r. a" |" U3 X' w/ U6 p) K<><FONT color=#0000ff>/* read result of initialization */   d' \/ A0 Z9 C; s" W: L& t7 i
errorcode = graphresult();
, u# ~6 v; h- P7 d% a' w/ tif (errorcode != grOk) /* an error occurred */
0 b6 D7 Z, V" B1 M& F7 f3 A- D{
: t0 I( E$ R( |& W" N, i2 g7 A2 n' Kprintf("Graphics error: %s\n", grapherrormsg(errorcode));
0 E' q! v+ K9 A9 c2 @printf("ress any key to halt:"); ( e- }% H1 Q7 T. y# C
getch(); ; X% O( R5 |8 J+ o
exit(1); /* terminate with an error code */
+ f% j8 X; o3 l2 H( f} </FONT></P>1 o+ }$ B: e5 ?2 F
<P><FONT color=#0000ff>midx = getmaxx() / 2;
4 g& c7 H: A- U" S* |/ ?" }/ F; _midy = getmaxy() / 2; </FONT></P>% Y2 b" w) J. Q  I
<P><FONT color=#0000ff>/* output text at the center of the screen*/
% z2 E7 [% z! _" ^1 a/* Note: the C.P. doesn't get changed.*/ & M, ?, \" n: o9 ?
outtextxy(midx, midy, "This is a test."); </FONT></P>
0 Z  h! i6 @0 `<P><FONT color=#0000ff>/* clean up */
% |5 D) A$ K8 L& Kgetch();
$ e9 [0 D6 }/ A' O0 u! zclosegraph();
5 v. s6 L/ o: g( I% \7 @5 N# ^return 0; * D9 X& D, |* 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-10-24 16:10 , Processed in 0.318780 second(s), 52 queries .

回顶部