QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2422|回复: 0
打印 上一主题 下一主题

函数大全(i开头)

[复制链接]
字体大小: 正常 放大
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

跳转到指定楼层
1#
发表于 2004-10-4 02:59 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(i开头)</FONT></B></FONT></P>
' p$ v0 s! M- `, E7 n8 R< align=left><FONT color=#ff0000>函数名: imagesize</FONT> ; U. C0 \' i+ u, I3 T' I
功 能: 返回保存位图像所需的字节数 , i( u+ o* O, a2 c$ C
用 法: unsigned far imagesize(int left, int top, int right, int bottom); 4 e$ S" s- [% }5 W, ^
程序例: </P>, r* f4 W# h" i' e7 q$ d3 f
<><FONT color=#0000ff>#include <GRAPHICS.H>7 b1 L+ S2 [. ^9 {" }) i
#include <STDLIB.H>
8 Y; H- x. k& F+ ~+ n* s#include <STDIO.H>
: j; S$ c% \6 ^% ?9 `' A#include <CONIO.H></FONT></P>
  e9 R4 [8 u, z8 ?/ t" P: z' x# f<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>" H; _$ X, F  W% b9 R
<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>* p/ Z' v4 W% I/ n
<><FONT color=#0000ff>int main(void)
% K$ z0 |* X$ K8 Z# |' U. K; w{
( _8 z( k2 u  ~9 a- G. Z1 J/* request autodetection */ / ]# h& Y" U9 l! a$ ^0 `
int gdriver = DETECT, gmode, errorcode;
3 }8 v- A1 ?& J4 g8 T( Bvoid *arrow;   l4 |5 c. V6 r0 l8 Z
int x, y, maxx;
, y6 a, }+ \- H. s$ ?( Eunsigned int size; </FONT></P>
( w! h+ Z. \4 N' {; A) [# ?<><FONT color=#0000ff>/* initialize graphics and local variables */ 3 b3 f0 c0 ^, [* ]
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>: R' C) d6 _8 G( @$ n# p$ K' z
<><FONT color=#0000ff>/* read result of initialization */
4 Z8 v8 |0 d" |# q: y4 ~errorcode = graphresult();
4 C' V8 `6 S: rif (errorcode != grOk) /* an error occurred */
! V4 d- M- C0 B, Q{
' D5 d3 p3 r! v- }# R% Q  ^. Sprintf("Graphics error: %s\n", grapherrormsg(errorcode));
& z% B9 S9 T; p+ l4 d" q3 wprintf("ress any key to halt:"); + E5 }) g* @6 Y$ \
getch(); 2 Q/ c! j1 O. S: v; T) z
exit(1); /* terminate with an error code */ ( `& E( ~7 Z2 H3 H% \
} </FONT></P>
% `' n0 f; y5 h( G5 Q<><FONT color=#0000ff>maxx = getmaxx(); : r4 R) P4 G- f- J; O3 M% M% z; X
x = 0;
% D2 R6 ~* e! M9 R4 Q* w5 L; Ry = getmaxy() / 2; </FONT></P>5 H3 Y6 Z  L6 d! ^
<><FONT color=#0000ff>/* draw the image to be grabbed */
2 k2 R; P3 F5 k! |  a# Tdraw_arrow(x, y); </FONT></P>. ?0 G( [7 X' u5 F
<><FONT color=#0000ff>/* calculate the size of the image */ 5 E  ^; Y* r6 R# m( j
size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>7 n) [  u7 P& D: a# a7 E
<><FONT color=#0000ff>/* allocate memory to hold the image */ 0 c" ~5 q0 b: k4 m, @2 _
arrow = malloc(size); </FONT></P>* Q# Q% V2 g& K3 K6 U
<><FONT color=#0000ff>/* grab the image */ . W: v7 m& _$ D0 o* l
getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>
! T; q7 m$ m9 i8 G<><FONT color=#0000ff>/* repeat until a key is pressed */
! \' R8 q( U9 F- N% Q  owhile (!kbhit()) * w5 N! [& b& I
{
1 r4 n' k. @% `7 n8 _6 q/* erase old image */ 9 z; z5 ?' h0 G2 F& J0 w
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>
2 D) z7 v7 a0 s6 E* K3 x<><FONT color=#0000ff>x += ARROW_SIZE; - [; j& X+ y# S
if (x &gt;= maxx)
7 }+ B: t  H2 N) T3 fx = 0; </FONT></P>/ ~/ y7 _- ~: d5 x% E  e
<><FONT color=#0000ff>/* plot new image */ 7 V2 s+ U& ], b9 D& j" i
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
+ |% }% v8 `# `/ O! K} </FONT></P>$ [2 j: T3 a( Q% o( w7 \& G
<><FONT color=#0000ff>/* clean up */
8 H4 `  Q- s! @6 H7 S( L3 v/ tfree(arrow); * b" L$ G: H/ s& f7 V+ Y, Z
closegraph();
& q  f/ a& [* `; C: m  greturn 0;
% [# k" w. h) N+ e9 H0 Q} </FONT></P>
( m! Z8 b8 p- o9 `3 a8 ^% X<><FONT color=#0000ff>void draw_arrow(int x, int y)
% R3 X' \! Q6 Y4 W6 Z{ , m/ W5 y2 O& D% z) C6 p
/* draw an arrow on the screen */ 5 Z! `1 b( r9 b9 s5 m
moveto(x, y);
3 N' Z9 l( R9 b( n5 Dlinerel(4*ARROW_SIZE, 0);
  W2 I: i9 N9 C% F' ?! |9 M3 Nlinerel(-2*ARROW_SIZE, -1*ARROW_SIZE); 0 t8 d$ ~, |$ u5 J% _
linerel(0, 2*ARROW_SIZE);
4 O5 E$ a5 J; ylinerel(2*ARROW_SIZE, -1*ARROW_SIZE);
* o/ X4 B1 m8 E9 {) p} - Y# K2 @. F4 [- h0 f

" }5 P& R1 x' ?: \
* A7 H' F: E% T& A</FONT></P>; {9 `; h+ K' c2 v
<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>$ Z/ u* h' q$ E: u$ l5 i
<FONT color=#000000>功 能: 初始化图形系统 * W9 m7 ^9 G: a" z7 Q: p& \
用 法: void far initgraph(int far *graphdriver, int far *graphmode, : Y/ d( I  A7 ^# K* e6 L/ {4 P1 U
char far *pathtodriver);
0 {$ o& E/ W* J  j4 ?4 Q! e程序例: </FONT></FONT></P>
- j9 {' t7 Z) V$ f<><FONT color=#0000ff>#include <GRAPHICS.H>
0 b3 s) E$ {7 ^+ B* a0 }) m#include <STDLIB.H>8 e7 _! P4 Z) j7 a- f
#include <STDIO.H>3 [, m8 S1 A0 J& Z! o7 F
#include <CONIO.H></FONT></P>
3 k5 K) u: F/ e+ F0 `<><FONT color=#0000ff>int main(void)
, U3 g, u7 e3 A% C( x5 E# d{ $ P) L# W4 g1 J( Z3 K9 @6 }, q
/* request auto detection */
% V5 I1 E* ^9 Mint gdriver = DETECT, gmode, errorcode; </FONT></P>
) z+ w0 ~  L+ O# g+ H1 s! J<><FONT color=#0000ff>/* initialize graphics mode */
- g1 y7 L. P' @/ t* {initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>! k' I0 S$ T0 }/ g9 w2 a" t
<><FONT color=#0000ff>/* read result of initialization */
( \" y% r& F: y$ ~errorcode = graphresult(); </FONT></P>
" n+ t# a* x0 a: g1 R<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */ % Z; b& q0 w7 j! V7 H0 _  m
{
1 ~9 H3 k/ u  ]+ U4 h2 `* E6 [printf("Graphics error: %s\n", grapherrormsg(errorcode));
$ _/ k$ o3 S/ E1 u" [4 h' ]2 q( Lprintf("ress any key to halt:");
9 K7 x6 d' i& B4 G; J& _4 ~getch(); * i& l$ f* ^: b6 \
exit(1); /* return with error code */ # [5 O8 N$ i9 L& ~
} </FONT></P>7 ]0 [5 t' r7 v
<><FONT color=#0000ff>/* draw a line */
$ @# J. ^( m# m; }; ]" J  ?7 Qline(0, 0, getmaxx(), getmaxy()); </FONT></P>
2 \( Z0 e( H3 D- n, W( ?4 R/ ?# t<><FONT color=#0000ff>/* clean up */
" C6 V; U' _) _- X9 I* ~( vgetch(); 7 [1 }( h6 m$ G/ \' `+ M3 D
closegraph();
8 \4 x. L( w9 f/ ~: mreturn 0;
6 s  S) [- E+ h" M: N} </FONT>* ]' c/ ~* w: U2 O5 l! z# z
# L8 o# `3 q7 k  J- H
</P>! P9 [" F: N% c' k% V* j
<><FONT color=#ff0000>函数名: inport </FONT>
; g5 u& \: O7 c% s  x9 F! G功 能: 从硬件端口中输入
3 A+ m: W2 @" b" f. ^1 p, z: X用 法: int inp(int protid);
0 [: V+ t' D0 x0 A  V% m: @程序例: </P>2 Z( W2 J0 m( e+ v0 ~9 W
<><FONT color=#0000ff>#include <STDIO.H>; r( i) G; X. u' {* G! I; y
#include <DOS.H></FONT></P>* M0 {( r- D3 j" }
<P><FONT color=#0000ff>int main(void) + r5 W) x) w  L' q! k5 L* y1 v
{
4 X* @9 h4 x7 }$ a" cint result; $ K+ e/ P2 w/ e+ J2 `+ G. `
int port = 0; /* serial port 0 */ </FONT></P>
% ]; [7 r! H: |4 T1 S8 E. c# a  t<P><FONT color=#0000ff>result = inport(port); 3 r# Z; [: ^! D  {
printf("Word read from port %d = 0x%X\n", port, result);
0 C* t$ R1 N6 v! b' X8 }return 0; 4 f7 _, G, w" f; t7 w4 }  ?
} 6 A% \* W0 o% p9 D: w& _; W8 k

3 L  C- x) h3 r/ R+ Z</FONT></P>
6 B% C/ {# b* Q% R<P><FONT color=#ff0000>函数名: insline </FONT>: P9 L) E' Q. L& w3 E" |
功 能: 在文本窗口中插入一个空行
$ \* j" H8 z6 I2 H  w用 法: void insline(void); 7 j8 e( M5 E$ `* [4 S; ~
程序例: </P>6 x/ _' L0 c* o1 \& L* o+ c# s
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>4 L; q7 P. Z' [  U
<P><FONT color=#0000ff>int main(void)
. X7 i7 j7 v  b1 M$ A6 s; t{ ! @& |5 N" L1 G0 J* q1 u
clrscr();
5 P9 \( k6 b4 y; H/ N0 r& Pcprintf("INSLINE inserts an empty line in the text window\r\n"); ! e5 o6 k9 A6 v$ ?
cprintf("at the cursor position using the current text\r\n");
9 G% V0 a% D1 m4 k/ Scprintf("background color. All lines below the empty one\r\n"); " W3 K& q- ~9 o: ]/ F' t8 L' k
cprintf("move down one line and the bottom line scrolls\r\n");
0 l  Z4 \& i$ b! m) U. ~1 x9 Jcprintf("off the bottom of the window.\r\n");
0 H1 V  ]9 u% k' Z; a* ncprintf("\r\nPress any key to continue:"); 6 r6 J# `& u4 {- B6 N/ |( y. M! M
gotoxy(1, 3);
, G) L; @4 M1 U/ Z- s9 }getch(); 0 d4 C& q; h5 ^7 ^0 L3 w
insline(); ! \, i7 J. x' _5 X- p4 j/ r
getch();
& k: ~) D4 S. vreturn 0; 2 X: ?4 W, O  ?% O& c
} / H0 q( Z  K$ F8 m: d- i
</FONT>
6 B' K5 b+ H% Q5 B# P: j/ x5 X3 z1 j! P
  `# g6 D( |: B3 B' E# g. I</P>
2 e2 K% r( G) w<P><FONT color=#ff0000>函数名: installuserdriver </FONT>
6 [4 W4 f- H2 A, p5 b功 能: 安装设备驱动程序到BGI设备驱动程序表中
* a+ I( j9 B4 m: b! q9 G用 法: int far installuserdriver(char far *name, int (*detect)(void)); 7 n2 u6 M; Q5 p# r3 N0 b" M! n
程序例: </P>$ E' X  E9 ^7 {3 C% a9 \
<P><FONT color=#0000ff>#include <GRAPHICS.H>
- o$ ?- A1 M9 T. L3 t: Y/ s, J#include <STDLIB.H>0 e) e* z1 X( ]5 X
#include <STDIO.H>
) c# i8 Z/ D3 z% T# {& [  {, g$ H#include <CONIO.H></FONT></P>, y2 t  ^) a, d
<P><FONT color=#0000ff>/* function prototypes */ 4 K$ s, ^# c1 s* c- r6 b; A# {" h( p
int huge detectEGA(void);
! Z4 S2 w/ w9 S5 wvoid checkerrors(void); </FONT></P>+ Q( J( S0 e" ?
<P><FONT color=#0000ff>int main(void)
3 b; {) s0 J+ r$ F; N{ ; R5 Y% |( J# K9 C8 V
int gdriver, gmode; </FONT></P>5 n4 M3 ]3 v% G& s
<P><FONT color=#0000ff>/* install a user written device driver */
) o8 l8 Y; H0 v2 ^gdriver = installuserdriver("EGA", detectEGA); </FONT></P>  y7 \* E+ Q( p
<P><FONT color=#0000ff>/* must force use of detection routine */ 8 ~% ], m# _0 Z2 o9 h- i
gdriver = DETECT; </FONT></P>- n. u  y9 B% g0 D% v. ~1 v4 o
<P><FONT color=#0000ff>/* check for any installation errors */
8 h) x% N  w# zcheckerrors(); </FONT></P>
3 x( n' {4 F# k0 a6 n<P><FONT color=#0000ff>/* initialize graphics and local variables */
: Q7 |1 N# }. J) _initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
1 J, T* S& z$ Q$ v* {' P5 `$ @<P><FONT color=#0000ff>/* check for any initialization errors */
/ r' ]. e8 S; P' wcheckerrors(); </FONT></P>3 I' D1 w6 q5 G3 L$ ~/ Y5 M* y6 R6 _
<P><FONT color=#0000ff>/* draw a line */ - e) L* b: J8 A1 g
line(0, 0, getmaxx(), getmaxy()); </FONT></P>$ T8 |) h# m7 M5 `# R* C  i
<P><FONT color=#0000ff>/* clean up */
1 n5 p* g. e/ \4 N/ T, v0 [: r3 rgetch(); ( H4 e7 L) r3 G  d8 ^, z
closegraph(); ( J0 k1 k( S# k7 i( ]1 Q
return 0; # F" v4 A3 d. \9 S: C% v( |
} </FONT></P>
4 p4 p- k! P* m2 L2 l! ]  U6 B<P><FONT color=#0000ff>/* detects EGA or VGA cards */
9 F& ~+ N' k5 s# H8 F+ m1 Uint huge detectEGA(void)
8 h- e' @* ^  @! J{ 2 ?$ a  `* W# s
int driver, mode, sugmode = 0; </FONT></P>
+ y  h$ @0 {' M% N/ ?1 Y7 t. }+ I<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode);
5 d9 _9 e) D2 t6 q; H, n$ D, Uif ((driver == EGA) || (driver == VGA))
+ [( |8 J1 p- h( D/* return suggested video mode number */
/ o5 g7 `* @+ Q/ Ireturn sugmode; 6 o4 v7 z, x5 c9 h' Q, h
else 7 d3 M+ G4 |, c7 t2 U0 J
/* return an error code */
" ], x8 T1 L- l- b) M2 q: M' h5 ^return grError;
) s& ~- |) X9 n, L$ o} </FONT></P>
9 J! H3 U2 j( Y$ w$ h<P><FONT color=#0000ff>/* check for and report any graphics errors */
: Y8 F  ]; s0 W. Y4 w; E: pvoid checkerrors(void)
6 ^9 H: _4 E8 [; J6 F{
; I9 b9 q. t$ g4 ~7 mint errorcode; </FONT></P>0 X; M4 [7 w9 `3 ^7 b' j% e( G
<P><FONT color=#0000ff>/* read result of last graphics operation */ 4 L! o, y/ E' ]$ ~0 ~/ o
errorcode = graphresult();
; x) m6 S2 L/ {) H& i3 cif (errorcode != grOk)
5 J# [. z6 U% q# d{
5 n7 r. I! C. J8 p. U) G# F- n3 u/ f+ d+ _printf("Graphics error: %s\n", grapherrormsg(errorcode));
& M3 W. N3 g1 q9 u1 P! x3 q2 R: Qprintf("Press any key to halt:"); , ^5 E& J- \1 S# Y' E
getch();
2 b+ J8 ?6 \  E3 A" \+ z7 Kexit(1); ; ~8 o- j6 c5 N. Q* W: E( d, P$ {: h
} 9 M; |6 g# M" V) z& W3 F
} </FONT></P>
- n0 n0 y0 Y1 |1 x2 S<P><FONT color=#ff0000>函数名: installuserfont </FONT>7 }& G2 _$ P! r3 [/ l7 ]/ R
功 能: 安装未嵌入BGI系统的字体文件(CHR) * p# v# f# X% ~3 j+ N
用 法: int far installuserfont(char far *name);
) v6 Q' Z8 K* C4 _3 t$ \8 G程序例: </P>
* ~4 r& o& S( w% B: z<P><FONT color=#0000ff>#include <GRAPHICS.H>
$ K6 {, ~* I% ]9 J# b+ a$ ~#include <STDLIB.H>
5 @2 {1 \1 ^7 r% v8 F& k#include <STDIO.H>
. W* r; I+ q$ f1 l1 E# @" p0 y#include <CONIO.H></FONT></P>2 e, T! h/ F6 E6 v
<P><FONT color=#0000ff>/* function prototype */
0 w9 ?' y) I* O4 i0 k/ C& A4 [void checkerrors(void); </FONT></P>7 A+ Q' c7 V0 f7 w. @1 k
<P><FONT color=#0000ff>int main(void) 4 \6 G  {7 Z% b+ d
{ ( |/ i& ?. F9 {$ O# ]! ?/ f* z
/* request auto detection */ $ `. w4 M3 B! |4 }( i
int gdriver = DETECT, gmode;
- H3 v7 _$ ]: M$ U8 y4 u# d/ gint userfont; " H5 q# Q  S) k! S1 u  r% e2 q
int midx, midy; </FONT></P>8 S+ Z- ?  N6 Q' e( E
<P><FONT color=#0000ff>/* initialize graphics and local variables */
, P4 y6 M" t8 y/ I' k# kinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>& o6 Y; X% f  \" X5 T
<P><FONT color=#0000ff>midx = getmaxx() / 2; + h' U; k  D2 i3 c. J$ u4 x, O
midy = getmaxy() / 2; </FONT></P>
* ]' r+ O! n4 G! B5 |: E<P><FONT color=#0000ff>/* check for any initialization errors */ 0 j, F; o2 M7 e  y
checkerrors(); </FONT></P>
; S0 X5 U7 D$ d1 A<P><FONT color=#0000ff>/* install a user defined font file */
: T  l' R( A+ W! h' p7 [% E& T' s! ?userfont = installuserfont("USER.CHR"); </FONT></P>
& F2 c7 x% a( {! T3 L: D<P><FONT color=#0000ff>/* check for any installation errors */   I2 L# r* Q& w, q7 T; B' C
checkerrors(); </FONT></P>
" J' N( p8 `( {2 S9 P7 g<P><FONT color=#0000ff>/* select the user font */
9 z4 u3 F" A/ Q8 x1 d+ isettextstyle(userfont, HORIZ_DIR, 4); </FONT></P>
& U4 z& j2 s/ \0 y: N<P><FONT color=#0000ff>/* output some text */
& x1 N2 U3 T! J: R% _- Pouttextxy(midx, midy, "Testing!"); </FONT></P>
1 K/ i8 h* G' V6 q& b<P><FONT color=#0000ff>/* clean up */ $ m& E! I2 A/ j: x
getch(); ' A- q* z- ?: c' _7 p$ q
closegraph();
4 b; I% V( w7 f4 mreturn 0;
6 ]7 n0 N7 ]: w9 `+ Y4 C: y( Q} </FONT></P>8 {6 ?: d0 `; _  p: L3 h; Z
<P><FONT color=#0000ff>/* check for and report any graphics errors */
' M2 O4 v; n' w  I9 Wvoid checkerrors(void) 3 ?& b* v, V; _! i% ^( e
{
1 h' X0 m, y/ s7 Gint errorcode; </FONT></P>& \; i# w1 s; {- G3 |$ `! {
<P><FONT color=#0000ff>/* read result of last graphics operation */ 6 V0 x: w: S( H2 Y; O& \
errorcode = graphresult();
9 N7 I; m/ Z  `. E5 Iif (errorcode != grOk) + F& w' b2 B3 W) U! z  m7 [
{ ; r& d% b3 v6 s( [9 V
printf("Graphics error: %s\n", grapherrormsg(errorcode));
" [7 }+ U5 Y2 m8 B1 xprintf("Press any key to halt:");
0 ?( S; O$ X' ggetch();
0 X: i8 }' G! X% F; F7 [  A2 Jexit(1); 0 Q5 Q% j5 t0 l7 O& r3 X' q) y
} . {6 \/ u: j0 ^, h2 _: G
} </FONT>
/ x, B6 b, J7 {& E- R
' A7 `! }2 ?- R
# Z3 R1 I3 w# z. P+ C& p7 V/ W</P>5 U( t/ G* A. g' A
<P><FONT color=#ff0000>函数名: int86 </FONT>
5 h( C3 x- e6 O  w; a. X功 能: 通用8086软中断接口
4 V% M2 G; `) Q% f2 S, u用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); - m! g$ a/ e7 P
程序例: </P># E6 H# a0 b2 X3 g) P' t7 C
<P><FONT color=#0000ff>#include <STDIO.H>
3 S- K" p/ d- W#include <CONIO.H>6 |' `5 V7 `* ^* ]: H
#include <DOS.H></FONT></P>
% a8 V$ M0 S, V. S. ^$ h9 g<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>( T% e0 n7 p7 |0 j. M4 J
<P><FONT color=#0000ff>void movetoxy(int x, int y) 8 c0 a+ D% f0 o) U
{
  ^+ t  u$ W) R! V6 Lunion REGS regs; </FONT></P>7 O" ^. Z1 z2 `: C/ U
<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ * A* r4 A; t( @7 d4 s
regs.h.dh = y;
/ s3 \" x4 o9 J4 }+ q' F# N* k+ P6 Kregs.h.dl = x; ' _$ n$ q0 u# l! g
regs.h.bh = 0; /* video page 0 */
7 z' Q6 _1 [, V: \4 ?8 Xint86(VIDEO, &reg;s, &reg;s); 0 b4 [8 n* O6 g  G6 ?! P
} </FONT></P>0 V$ |7 V. p% I! I" o
<P><FONT color=#0000ff>int main(void) . b8 Q. b0 {, z3 f" B
{
- m5 {2 R) u$ l5 W: q) X- kclrscr();
5 l+ M# N  g3 b" I; K/ |movetoxy(35, 10); 1 l' s! R8 X5 W: n- P, y+ q
printf("Hello\n");
  m% z/ @1 O/ p5 Y8 J1 Ereturn 0;
3 v* n4 d' h0 ~# o* b} </FONT>
7 m* k2 J( m8 @3 m, }& N! ^9 O: S7 c+ g; K- K: Y" N4 o8 M' j8 l
</P>
( D; G  H  j3 j+ P<P><FONT color=#ff0000>函数名: int86x </FONT>2 D& X3 F% P8 B, P& @, D" ]( i
功 能: 通用8086软中断接口 3 O* _9 A$ D* Q! k; D
用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, , a7 m$ p& ?* _; N5 U. W
struct SREGS *segregs); 4 [' n. h, b8 q# B% S% L* K5 `
程序例: </P>
: p* R+ V: y) T( o1 r5 Q+ J<P><FONT color=#0000ff>#include <DOS.H>
; h! V' x9 u* V# T#include <PROCESS.H>( F8 c" N* b: G& n4 y
#include <STDIO.H></FONT></P>& U5 Q, O: J% _* i# w0 K
<P><FONT color=#0000ff>int main(void)
: B/ h- S0 J" }{
/ d0 C3 |! L0 t" j& Nchar filename[80]; " E9 ]" g# K; a
union REGS inregs, outregs; 3 W% i$ }% q" Q. {7 U0 Y  o
struct SREGS segregs; </FONT></P>
1 z$ U, d$ G' h<P><FONT color=#0000ff>printf("Enter filename: ");
# y. p5 V5 m0 ^* t/ k  t: Kgets(filename);
: h" m' d1 L% U1 q% H7 iinregs.h.ah = 0x43;
' W3 H! J8 x0 H' ginregs.h.al = 0x21; # D4 Z  B5 L* X' K. w8 z. x
inregs.x.dx = FP_OFF(filename); 3 L( c9 z9 h: P1 r6 W
segregs.ds = FP_SEG(filename);
5 O1 R% Q0 S* B' K8 i/ \% m9 K2 zint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs); 0 Y1 ?$ k! j8 I/ g9 |2 K. d
printf("File attribute: %X\n", outregs.x.cx); ) K! c7 A7 W, ?% b0 _. g
return 0; 4 M! K; Q4 t/ c; K. p1 \$ J
} . o2 c/ c! e$ e1 I
( F6 q0 ~+ H; O" y- r+ Z
</FONT>
" D" `: j5 V( [* c: i4 {</P>) B2 j3 T  a- n  q
<P><FONT color=#ff0000>函数名: intdos </FONT>
7 e5 ~! o/ I5 J7 i& U# U% ?功 能: 通用DOS接口 ( l" {- q7 v. @# b6 }  m
用 法: int intdos(union REGS *inregs, union REGS *outregs);
( e0 f: g4 l6 s2 W3 `" c程序例: </P>
. q% b5 t- h/ c' P/ T. g<P><FONT color=#0000ff>#include <STDIO.H>5 {& c6 c+ ~6 M2 d
#include <DOS.H></FONT></P>
" b+ C6 o; p) H4 K  t2 x! H<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */ 9 }( Y( I6 a) ^/ Q6 B5 f6 g
int delete_file(char near *filename)
4 l, a  M3 A# j5 K$ x4 N$ l{ 0 _. \6 ]3 V( f3 i; {4 m% C
union REGS regs; ) g- Y. [2 B2 d( P2 H, x/ T
int ret; ! C9 k& I/ o9 |$ W3 d0 b5 D
regs.h.ah = 0x41; /* delete file */ 0 ?! R+ S7 i) y" |- t* j) L
regs.x.dx = (unsigned) filename;
3 Q- G/ X6 u" h$ }  b/ S9 a  fret = intdos(&reg;s, &reg;s); </FONT></P>
$ A% f3 H. m: j2 a1 W- B9 p5 }( l<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ 2 y' g( r! I* s. _0 I
return(regs.x.cflag ? ret : 0); ! y! x( M# F+ k' ]
} </FONT></P>' O8 N& F/ A) x
<P><FONT color=#0000ff>int main(void)
0 X% |" A. i/ p/ p{ : |% B5 G  s/ i
int err; * U& D: H1 ^9 K4 M& k3 Z! K% R
err = delete_file("NOTEXIST.$$$");
* m& M) N2 T% `& Xif (!err)
' W% p5 `4 @4 {1 i6 O3 z8 Eprintf("Able to delete NOTEXIST.$$$\n");
& Q0 n; N& H3 b, Q" kelse 2 Z& \' l. ~5 I$ P: `) p
printf("Not Able to delete NOTEXIST.$$$\n");
, d7 f" y- x; w- g) `) j2 Yreturn 0; ' c: y$ d& {, S2 @- ]0 ?
}
+ n" ~+ Z- P/ N" F: y
$ f  _" y% c( H; ~% G0 s0 Y</FONT>
) S) ]1 k: i3 u% A. ]</P>
3 @2 o- ~- c6 U<P><FONT color=#ff0000>函数名: intdosx </FONT>
& o1 J+ z8 I$ _/ Y: ]( B! ^, I0 |5 v功 能: 通用DOS中断接口 1 N! ^' x& \  u/ q
用 法: int intdosx(union REGS *inregs, union REGS *outregs, . ]' t: Y3 U5 p( _  Y# p( o
struct SREGS *segregs);
4 K" V1 a4 O5 m7 Z程序例: </P>
* c. y/ q3 N! z: T! b9 a" ~<P><FONT color=#0000ff>#include <STDIO.H>/ o- |% }4 v, v. W9 `6 j- ?
#include <DOS.H></FONT></P>) G' @8 ~. T. i7 q2 U/ U2 S
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
0 y3 F# r9 V& f/ Aint delete_file(char far *filename)
" I& f3 `9 z+ r9 M{
3 @* B5 ^1 J  qunion REGS regs; struct SREGS sregs; . d" N! A4 S* x5 t5 F1 a! W
int ret; - {6 j4 Z1 \4 J! r5 q  j
regs.h.ah = 0x41; /* delete file */
$ s2 |+ r; B- z8 V( Lregs.x.dx = FP_OFF(filename); 1 C9 c# N. c" ?
sregs.ds = FP_SEG(filename);
4 [7 m! O% K7 X" Qret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>
# F- I  X3 X- c4 {) Z9 J/ y: J<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
) w7 I# O& {; Z  ]" g* T6 i9 Breturn(regs.x.cflag ? ret : 0);
  g% |* ~* t4 h6 B+ L} </FONT></P>
5 k, ]: [% x6 y6 {1 V% P<P><FONT color=#0000ff>int main(void) " |" s" u8 t( {. Q$ A3 o9 S
{ , S  Y2 B' q$ N  Y) X
int err;
! H  t0 q9 |1 R% p) F6 Aerr = delete_file("NOTEXIST.$$$");
% X, z8 X7 y3 cif (!err)
( f' L' L& N# Uprintf("Able to delete NOTEXIST.$$$\n");
/ ~- \4 j/ B3 [, M2 Velse
% U( y$ _4 H- pprintf("Not Able to delete NOTEXIST.$$$\n"); ( e. f! \+ F1 e9 n9 j; z+ {8 h  {" u
return 0;
  y6 D% x9 Y5 Z3 Q% A$ _} - z$ f* F6 t) z9 _' n4 R' }+ {. }
</FONT>5 }5 u% y2 Y* u
</P>
) `/ b$ W" e6 r. j# A<P><FONT color=#ff0000>函数名: intr </FONT>
2 W0 H: W0 B# A功 能: 改变软中断接口
3 X. V' _) ?& t3 Z用 法: void intr(int intr_num, struct REGPACK *preg);
! o; t' {' X6 ~( h, g; s程序例: </P>) }1 H: V6 f- F7 w( K. I. k
<P><FONT color=#0000ff>#include <STDIO.H>+ q( C) X) ]' K
#include <STRING.H>
- @2 n7 f* I6 m. W$ i2 K#include <DIR.H>
  @# i; u0 ?. `* C  C, }2 _) Z1 ]#include <DOS.H></FONT></P>) ^; R$ V) s* p  @- Y1 i' x* P
<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>% [4 D* C! ~, [0 \9 w
<P><FONT color=#0000ff>int main(void)
: ?: r8 E$ C* @' w{
. V$ d" V- l: \! Ochar directory[80];   h: j- m/ y9 \8 y
struct REGPACK reg; </FONT></P>2 ~+ W0 ?! W: c/ L  t1 T! t& R. F
<P><FONT color=#0000ff>printf("Enter directory to change t ");
  U3 G# a5 `, x  o) Wgets(directory);
# L0 s6 i. K& a0 e7 B( L5 z+ O# greg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */
$ U; d/ K4 p3 Qreg.r_dx = FP_OFF(directory);
# v+ ?! n8 c4 S8 D/ ]' k, yreg.r_ds = FP_SEG(directory);
, P9 |- ^" l, L; J6 ?intr(0x21, &reg;); ! m4 Y* r# G' V$ W
if (reg.r_flags &amp; CF) 4 S7 W, Y6 Q/ l* \6 g% ~
printf("Directory change failed\n"); 2 B1 m4 q0 E8 O; k8 H7 w+ A
getcwd(directory, 80);
4 W. i1 d( K" @printf("The current directory is: %s\n", directory); " l* h1 e0 k5 t$ n3 m: _, f
return 0;
- s- U4 T9 i# r* d* N5 F, F# u6 I}
7 n6 G  ?2 L$ h! k5 z& D</FONT>* V# W  o7 A" x
</P>
: T9 e0 R4 o" P" o7 I: M' p<P><FONT color=#ff0000>函数名: ioctl </FONT>
1 t$ }' e9 T$ ]* X% f" B功 能: 控制I/O设备
2 ?- c, x( q8 G3 C6 t用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]); % D+ [0 t* N2 U
程序例: </P>
( s9 V" p, G  a; Z/ o<P><FONT color=#0000ff>#include <STDIO.H>
( H* j* t3 w5 L* n) ], e, B3 ]" g#include <DIR.H>
, L- |& f; A/ {  O9 S) k' D#include <IO.H></FONT></P>$ n6 ^' _% J7 H9 d, w+ ?
<P><FONT color=#0000ff>int main(void) ; E  @1 w7 ^  V9 _% K; r( \! I5 W
{
. y: i$ V2 L: U4 n% w9 sint stat; </FONT></P>; S/ g9 b/ K0 J
<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */ - ^* j' j# J% K+ E* c- g3 c# S
stat = ioctl(0, 8, 0, 0); ( Q; C7 d$ A  |, B
if (!stat) 2 l9 P! z; U5 F% z! ^& e
printf("Drive %c is removable.\n", getdisk() + 'A'); : V5 L6 l- ?" I! V3 }
else
' d& L3 m, [- G( y+ J7 E: iprintf("Drive %c is not removable.\n", getdisk() + 'A');
1 D4 _. C/ n7 `: _' q) G0 W2 `return 0; + x) v- q; m# {9 i" x
} , q5 B2 g, i" O0 B5 P1 I
3 H0 f7 H7 ~' A" {+ U
</FONT>
4 R6 |; a& m& V! q3 j</P>$ f. k' R3 x$ }8 N
<P><FONT color=#ff0000>函数名: isatty </FONT>
, ?2 k; \% L) Y; g- S$ `功 能: 检查设备类型 6 }1 W: o4 l2 Y# ^; G
用 法: int isatty(int handle);
9 E: [7 j. ?! B( D6 M0 c6 d' q程序例: </P>% u5 N% Y) W- e7 y2 _! F* j
<P><FONT color=#0000ff>#include <STDIO.H>2 f' W: B* Q( \% D3 G& M) ^; t) T
#include <IO.H></FONT></P>
% r7 [, [+ r0 l0 E<P><FONT color=#0000ff>int main(void)
! L) ^! w! n: ?: \{
' |6 I  E# K9 _int handle; </FONT></P>
3 F3 _1 ?! @; E' d<P><FONT color=#0000ff>handle = fileno(stdprn); 3 \, Q' {& }/ @
if (isatty(handle)) " _( D* a8 m- e! w! [* U
printf("Handle %d is a device type\n", handle);
0 |* j( R; M' E& w: g8 t/ Eelse
. u8 O9 C& \5 _9 t. M4 Q/ E' Xprintf("Handle %d isn't a device type\n", handle); # o2 V, L" ?+ W# j& e" _, r: X6 M7 t
return 0; 6 x- a9 p# x5 s; y/ g, x
} 1 q2 ]% x0 S, u, ]* k  W8 \

0 u8 o4 S! ~* K0 _7 H$ ]2 D</FONT>- g4 y! v+ h( O* I
</P>5 ?4 A7 |6 m: Q+ Q7 ?
<P><FONT color=#ff0000>函数名: itoa </FONT>- J$ J4 l8 V0 V  s
功 能: 把一整数转换为字符串
6 z+ F4 H4 ~) a$ H用 法: char *itoa(int value, char *string, int radix); % i! v  e: ~' P0 Z; ^
程序例: </P>
5 f0 }5 f8 I& M/ V7 b; f<P><FONT color=#0000ff>#include <STDLIB.H>1 d7 S$ t% g  k2 M
#include <STDIO.H></FONT></P>' a3 [2 g0 w; I) T+ w  a( f" R
<P><FONT color=#0000ff>int main(void) # W/ ]- {! d2 h
{
7 ?0 D* _2 O2 B3 [; `6 E: \" iint number = 12345; , G3 H! b7 ]7 M2 A  i
char string[25]; </FONT></P>$ d7 N2 N8 i0 o- f  {
<P><FONT color=#0000ff>itoa(number, string, 10); + @1 W3 v& p7 g9 i( q
printf("integer = %d string = %s\n", number, string);
; E4 \3 |" U# w5 ereturn 0; 7 p5 _4 q6 V; u. Y5 d5 y/ q# h
} </FONT><FONT color=#0000ff>
8 ]8 F; g4 K8 g5 W8 _  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-10-23 08:10 , Processed in 0.304403 second(s), 52 queries .

回顶部