QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 1726|回复: 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>7 f5 y2 U1 E) C( m2 A; O
<><FONT color=#ff0000>void normvideo(void );" t- m4 i/ X5 s6 v  E
</FONT>选择正常亮度字符。  w8 |/ f6 @  ?+ @
将文本属性(前景和背景)置为启动程序时它所具有的值,来选择标准字符。</P>2 n  V4 t4 Q+ [3 Q; N) P3 {; R$ S

; P0 A5 u* G) Y+ X' j. t$ C% I, u% t3 Q, S- f0 w+ a
<><FONT color=#ff0000>void nosound(void );5 K5 F2 U: G) g3 u  E2 H( s0 y
</FONT>关闭由调用 sound而发声的扬声器。
  t* I! ]' X$ D" ]1 b+ K  ?</P>0 e1 t. h2 v* M  @* U" h/ I
<><FONT color=#ff0000>函数名: open </FONT>
, Z3 C% c1 j( A7 D+ f+ {功 能: 打开一个文件用于读或写
/ ]7 D7 @) r# P. L" ]+ J用 法: int open(char *pathname, int access[, int permiss]);
# i: o% c0 F$ f0 B$ V( V  {程序例: </P>! [4 k' r8 a: ~$ z
<><FONT color=#0000ff>#include <STRING.H>4 @7 h- W7 d2 Y$ K
#include <STDIO.H>
5 u" @: @, S2 C$ |% u; m#include <FCNTL.H>
" K: l8 h! |/ h7 F- o, w. s#include <IO.H></FONT></P>0 K; p5 w/ ^4 A$ H4 y# X6 W9 r
<><FONT color=#0000ff>int main(void)
& V" k. q! w7 ]{ - S, M! a; J5 v7 j6 ~
int handle; 5 T" W5 c9 D9 g" F
char msg[] = "Hello world"; </FONT></P>7 R" X# C% F; G1 B
<><FONT color=#0000ff>if ((handle = open("TEST.$$$", O_CREAT | O_TEXT)) == -1) * h4 F: ~8 Z7 B% N* U# y/ N* O
{
6 m- V* A9 g( l+ R$ m6 v+ j# vperror("Error:"); ! A. X+ o- B4 q! L6 g& p$ O/ v2 s
return 1; + O: O: J6 b$ \
} " i& C5 j; C# |  _; a
write(handle, msg, strlen(msg)); 9 b: V) e7 }0 K% K# _8 i, p9 W' X
close(handle); 9 M. e1 x  y9 z: }* w, M
return 0; 4 ?5 @8 |% g( c. T! o, X. D
} 7 h) L0 Z" F5 W  @% T0 u
</FONT>
# l4 k+ _) b2 A$ _9 b) O9 y" d8 L</P>  {+ T! E& _; u4 d9 v
<><FONT color=#ff0000>函数名: outport </FONT>
& b2 k$ r7 c# X4 u9 o功 能: 输出整数到硬件端口中
/ O- v/ a1 B1 D" }1 s用 法: void outport(int port, int value);
1 F4 B% ^, k4 R程序例: </P>
% c( _# @, Z+ n+ O" Q: _% X<><FONT color=#0000ff>#include <STDIO.H>
& F6 g8 G" c3 P" `8 ?# w$ ?#include <DOS.H>4 u3 P) }; E- W: _0 |( H
</FONT><FONT color=#0000ff>int main(void)
' A1 P* K: `; t9 B{
3 E3 q2 L! s8 K9 }1 rint value = 64; 8 V% h: K5 n$ D. v
int port = 0; </FONT></P>
' E9 p. e6 o0 C" Q5 f<><FONT color=#0000ff>outportb(port, value); ( z: [+ F( Y. x9 H8 y9 `& J# M
printf("Value %d sent to port number %d\n", value, port);
0 P2 D" b, K" D8 r, P1 creturn 0;
) x0 ?$ T( n3 `& E2 P$ V4 h} , z: h- r& s6 `" c7 ~
</FONT>
0 X8 i: W; B* X5 L</P>( `" l* K) a6 p. ?/ I/ m
<><FONT color=#ff0000>函数名: outportb </FONT>8 d0 y# S) X9 _8 ^7 ]- r# Z
功 能: 输出字节到硬件端口中
8 N+ U9 e; d+ X/ z1 M. ]用 法: void outportb(int port, char byte);
4 y% m. _2 P! }- x9 `% r程序例: </P>
$ @  a% ?' A, F" d7 q8 @2 \, N<><FONT color=#0000ff>#include <STDIO.H>2 i1 N) u$ b& C+ h0 d7 R
#include <DOS.H></FONT></P>
/ G8 X5 D7 |3 X# t- Y6 R<><FONT color=#0000ff>int main(void)
$ F& W3 Z9 }) D6 }{ & E6 z0 w: F) h7 E7 r+ R
int value = 64;
% a/ E. K/ j' k# bint port = 0; </FONT></P>
' ~! E1 v# X. W7 ]7 H4 ]! |<><FONT color=#0000ff>outportb(port, value); 3 x$ G4 |6 E& A& W
printf("Value %d sent to port number %d\n", value, port);
! W1 m, \/ n4 B* {return 0; % S: r% o/ T9 x- j7 ?. m
}
5 D; N# E2 p" s8 N" P0 u- A' Z</FONT>0 J' j* C5 z7 w* x7 B: P7 t  Z
</P>6 P, T( ]$ m" I9 `; I
<><FONT color=#ff0000>函数名: outtext </FONT>
( |3 N4 V5 H  z功 能: 在视区显示一个字符串 8 J8 x  A2 R3 i5 x! g. z4 J9 h+ ]4 m+ h
用 法: void far outtext(char far *textstring);
2 L+ \3 I* k  {3 ^' M程序例: </P>
2 Y$ ~1 S2 i* ^! z6 \<><FONT color=#0000ff>#include <GRAPHICS.H>6 e5 A0 k' F; C9 f5 f4 b5 y
#include <STDLIB.H>* Z! I2 n& ^# Q8 A
#include <STDIO.H>
7 |& r3 M' Z7 B: `#include <CONIO.H></FONT></P>
! O8 p- q  [/ O5 ^$ a0 S+ X# z<><FONT color=#0000ff>int main(void)
! ^7 {$ D9 q3 ?* S, J$ S{ 5 g& S0 n$ w' D! x+ A7 T6 t
/* request auto detection */ , ?5 b" g% c5 y0 X5 }) O: G
int gdriver = DETECT, gmode, errorcode; $ D" {: b/ W% Y) |- W# g* B# l
int midx, midy; </FONT></P>
6 |" j( \; m5 V% P* D, d. m<><FONT color=#0000ff>/* initialize graphics and local variables */
9 z, q" H0 x3 _, b3 j1 K/ R: \initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
% h* J3 O9 L4 A# O: B$ @1 r<><FONT color=#0000ff>/* read result of initialization */ 6 p( n4 G2 `9 z- T* R1 W6 S( S6 @9 Z
errorcode = graphresult();
$ K' i3 L: z" l) |0 V3 l' h5 C) ^if (errorcode != grOk) /* an error occurred */ , H9 k9 f( \+ Q$ d1 C0 {. H& q
{ 1 z) A, A. i* ^% ^
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 7 n, g- c/ E9 n- k
printf("ress any key to halt:"); ; S$ ~' Z! s& [
getch(); - V# v; o, y# F( s# ]
exit(1); /* terminate with an error code */ 6 @. D3 L8 _) Z8 r
} </FONT></P>7 Y) a' @7 [2 I. s
<><FONT color=#0000ff>midx = getmaxx() / 2; & R, e+ ]9 @( Z$ _6 V
midy = getmaxy() / 2; </FONT></P>2 E& D* \+ i8 E" V
<><FONT color=#0000ff>/* move the C.P. to the center of the screen */
* C. a  l  {& W/ l  E' l! j. Amoveto(midx, midy); </FONT></P>
, d: b* g. c1 S. t" ~<><FONT color=#0000ff>/* output text starting at the C.P. */
9 x. g- H1 r/ ^2 Z" Bouttext("This ");   Q- O+ `- I2 \( ~% |
outtext("is ");
- [: D' Z/ p; ~$ {& Jouttext("a ");
7 @  P7 ?$ t/ O$ M3 ^' _outtext("test."); </FONT></P>: a, }: `5 w- }3 E' a$ Y% H
<><FONT color=#0000ff>/* clean up */
4 {% o& z9 c2 `. D- Hgetch(); ( o+ m; x7 R. O# S
closegraph();
4 b6 O1 s7 h) T7 T: Xreturn 0; 4 G/ B% q& s- h$ |& a) W4 z' U' a
} </FONT>2 O! ]1 I% z# L7 ~7 H

" N( s# A3 r4 R7 D# f</P>/ o0 E6 y. a- _1 n% d
<><FONT color=#ff0000>函数名: outtextxy</FONT> 9 s# B; w% [9 x. V6 G
功 能: 在指定位置显示一字符串 6 F% ?: B$ A; Z5 \' I
用 法: void far outtextxy(int x, int y, char *textstring); 9 f# Q8 [& y3 W% z) ~
程序例: </P>5 o; L1 x/ C* Y: h
<><FONT color=#0000ff>#include <GRAPHICS.H>* C1 g; c9 M+ c3 C* F8 c
#include <STDLIB.H>5 ~- Y4 O( w5 k- l$ W  L
#include <STDIO.H>
0 k0 Z% K7 h- C* ~#include <CONIO.H></FONT></P>
# {/ p# S0 f$ W$ r0 |<><FONT color=#0000ff>int main(void)
, f3 Y$ z* s# a( V2 N  @{
  X) G* ]% q( T: I9 o/* request auto detection */
/ [2 k4 ~5 Z. R: C; pint gdriver = DETECT, gmode, errorcode;
8 W  Q1 \: e) N& G; Q. Q% lint midx, midy; </FONT></P>
2 J2 K' r1 I4 ~+ a9 J6 x+ D<><FONT color=#0000ff>/* initialize graphics and local variables */ . R% D. U$ Q7 l9 H- f) M
initgraph( &amp;gdriver, &amp;gmode, ""); </FONT></P>6 S- x* Q6 H2 E: t5 K
<><FONT color=#0000ff>/* read result of initialization */
5 p7 U. C4 G% ?- c0 f0 Q# T$ C* merrorcode = graphresult();
& P" H, ~2 O5 D$ z( Uif (errorcode != grOk) /* an error occurred */ 1 E: R  _) x( }* B( V2 Q
{ . J  ^8 V$ k% n" s
printf("Graphics error: %s\n", grapherrormsg(errorcode)); * [. j2 w4 h8 O0 D: c! l
printf("ress any key to halt:"); ' c# ^# |  i, S7 U+ W# |; W. B- `
getch();
5 }7 R, F6 X$ u2 `; h  e7 yexit(1); /* terminate with an error code */ # c, e) a0 @/ N' l2 f
} </FONT></P>
  Q# |* f$ c% ]/ {$ r- b<P><FONT color=#0000ff>midx = getmaxx() / 2;
% q! K; b6 w4 }- I! Rmidy = getmaxy() / 2; </FONT></P>% C9 R& f$ |4 E1 Q. A& |9 I1 ~- N
<P><FONT color=#0000ff>/* output text at the center of the screen*/
9 E' b: l, i/ W/ d/* Note: the C.P. doesn't get changed.*/ 5 [3 a$ \) n9 H9 b0 q/ y! u" c
outtextxy(midx, midy, "This is a test."); </FONT></P>
  R" ^% W) P" U/ j6 |<P><FONT color=#0000ff>/* clean up */ + R" p% Y, K! p+ s% I6 T
getch(); 8 d/ Y' ^0 `5 w0 t  a) G; J
closegraph(); 7 W  t8 Q9 P: U$ F; h
return 0;
0 i- U/ ^+ l7 D' N" \+ J; w8 C' _} </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-12 23:09 , Processed in 0.612085 second(s), 51 queries .

回顶部