QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2335|回复: 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>- F5 M1 h9 o  S; `4 R+ h
< align=left><FONT color=#ff0000>函数名: imagesize</FONT> ( H; n% u$ [/ P) E5 w1 v
功 能: 返回保存位图像所需的字节数 . _; J* c8 `# }3 N/ D. I6 d9 d( I
用 法: unsigned far imagesize(int left, int top, int right, int bottom); % p! a2 T1 ]! ~( T
程序例: </P>
% |8 h: L* @+ |4 D$ f. f<><FONT color=#0000ff>#include <GRAPHICS.H>, E; Z$ v* }6 S% Z* t, \
#include <STDLIB.H>
2 _( O5 l8 g& p3 V: y! c1 J. z5 f#include <STDIO.H>
( Z+ k9 }% a4 Y9 [" j#include <CONIO.H></FONT></P>
1 K" P7 y) D- x. w+ W; o<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>
1 C/ ]. O4 T6 G! j. N- c<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>
' ^% l4 |. O: A& R# {0 ?( I. r  \<><FONT color=#0000ff>int main(void)
# Y# n% |, m$ x2 x) a{
5 T1 M* M! g- g4 t* \/* request autodetection */ 6 ~9 R* o( C! j( s0 p/ }1 P
int gdriver = DETECT, gmode, errorcode; ' ]3 I6 P$ J( l2 o
void *arrow; . q/ o, V0 t  J3 W, @0 L
int x, y, maxx;
! O( z7 b2 `3 Gunsigned int size; </FONT></P>9 W5 C& ?: q( ?' d$ Z
<><FONT color=#0000ff>/* initialize graphics and local variables */
! Q2 S8 ]3 q8 N' z8 F, K6 a( q  ~initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
6 g, k& s" L- W<><FONT color=#0000ff>/* read result of initialization */ 6 q, q( X" N- z$ G6 X
errorcode = graphresult(); & u1 K8 N) M# }- R
if (errorcode != grOk) /* an error occurred */ 0 ]0 Y$ Q- g8 ]2 ], t3 n) B9 e) Y  L$ `( c
{
8 n% s* _) c$ T! y0 pprintf("Graphics error: %s\n", grapherrormsg(errorcode));
0 g  ~( n8 A" @! D" b5 L( k! T3 ?printf("ress any key to halt:"); + m3 V9 i1 {& H
getch();
" Q; k! {; l7 T5 I* `. iexit(1); /* terminate with an error code */ % y$ O- i7 K8 }% |8 s+ [: x
} </FONT></P>! c( e( E6 P! L5 l
<><FONT color=#0000ff>maxx = getmaxx(); 7 x' e0 q) x' ?" f
x = 0;
% O( |7 U/ n9 _3 m# ^1 |1 e% z0 cy = getmaxy() / 2; </FONT></P>2 E" D4 D  O" V) ~" X
<><FONT color=#0000ff>/* draw the image to be grabbed */ ' ?" A$ I! O7 Q* R
draw_arrow(x, y); </FONT></P>& v% a/ r- U! T3 ?$ Z5 K
<><FONT color=#0000ff>/* calculate the size of the image */
. j5 f7 V6 Z  L0 `/ n+ E( r. P8 C2 bsize = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>4 k3 p' S0 j) n& y. O" l6 b& R
<><FONT color=#0000ff>/* allocate memory to hold the image */
1 k6 X" E& }4 O0 |* Zarrow = malloc(size); </FONT></P>8 S6 {: ]: K4 b0 @; q
<><FONT color=#0000ff>/* grab the image */
+ z; r9 i! W; I9 K; L8 a! P! m* Mgetimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>
% w# e* n0 g8 M4 ^1 g, z2 Q) U: b<><FONT color=#0000ff>/* repeat until a key is pressed */
) ?7 c% z6 E3 n& g8 Q1 }0 H* ywhile (!kbhit()) ' p8 s; X. T8 `( c3 Q3 k
{
" d/ T( ?5 {4 K8 ~/ l, h/* erase old image */ " M: M2 J7 e5 f
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>/ U* N. a3 G3 w& h/ H9 n  w  Y
<><FONT color=#0000ff>x += ARROW_SIZE; 4 x/ {7 W! k1 b. n, w3 A6 i$ g
if (x &gt;= maxx) ! y% Y  x8 R4 q9 S/ y, [
x = 0; </FONT></P>3 V: G* J5 H# k- Y* W
<><FONT color=#0000ff>/* plot new image */ 5 P8 C+ i3 S, I1 `9 Y$ L" \
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
& F$ l: S; O  C3 i! z5 }$ `( U! K# [} </FONT></P>
* p$ e8 A( j2 t5 Z2 G* V# e<><FONT color=#0000ff>/* clean up */
3 F$ S. X+ G  j3 [8 @) Rfree(arrow); ) f  a$ H" V6 b+ L
closegraph();
5 t: U1 n+ k/ O( p+ r- Zreturn 0; " P) T% P! ~2 G1 B
} </FONT></P>" V. _% Y/ {# |* a" B0 k7 c
<><FONT color=#0000ff>void draw_arrow(int x, int y)
( F1 a. W" v3 F; N; g5 \. C{ ! W/ T# w% [. Y* K+ j# b0 h# c  t' S
/* draw an arrow on the screen */
. T2 _  L8 s( wmoveto(x, y);
1 `7 {  y+ o$ H( S$ y7 jlinerel(4*ARROW_SIZE, 0);
% ?: J; s/ n2 x$ x6 ~# H9 klinerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
' o3 W0 I! B9 P- ^1 r( x: Nlinerel(0, 2*ARROW_SIZE);
' M) n, r* @+ {+ Slinerel(2*ARROW_SIZE, -1*ARROW_SIZE); : [" H/ H7 N- \( P1 z- w5 l
}
  A1 e8 r& y$ j9 Y3 r9 f# V( R( E/ \: s8 W$ j5 d

5 {! o8 J/ T6 g7 v1 @- E" L  H% x</FONT></P>/ q0 d. K+ ?! q) ?( R9 Z
<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>
& a7 `6 r/ `: x' ^' _: Y* w<FONT color=#000000>功 能: 初始化图形系统 ) y9 Z, X) l4 h" r, P3 A3 M( p# g
用 法: void far initgraph(int far *graphdriver, int far *graphmode, ; j, R6 e5 i$ R- t
char far *pathtodriver);
" p& d0 {1 N; v" I) u程序例: </FONT></FONT></P># G/ k) w5 L7 o! d0 ^: `  P
<><FONT color=#0000ff>#include <GRAPHICS.H>
: K7 M4 G0 \$ p#include <STDLIB.H>0 ]- u( G! x" f# d% c, @4 ^: K
#include <STDIO.H>
  e; G4 j, G# w3 X2 e2 K" t9 Y& N: ^#include <CONIO.H></FONT></P>
3 u% u8 D) f% V4 C5 e<><FONT color=#0000ff>int main(void) $ b$ R, \! b7 u8 S6 Q0 {
{ " L9 A4 K5 A1 }7 `% Q' n8 o. |+ D
/* request auto detection */
6 \3 c! j& Y0 C( b1 N/ `int gdriver = DETECT, gmode, errorcode; </FONT></P>: j/ C) x& U" p; }
<><FONT color=#0000ff>/* initialize graphics mode */
2 }' l6 C. H' |5 L0 Rinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>' A0 u9 S' _- |  w* K
<><FONT color=#0000ff>/* read result of initialization */
8 l0 r; w- s; o! a; Z2 X0 t: Gerrorcode = graphresult(); </FONT></P>
& A+ I0 w* }6 W<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
" l: t3 {- C/ B' P, ], n. @% q4 F{ / i  [1 i  W. l$ P) S" q6 x
printf("Graphics error: %s\n", grapherrormsg(errorcode)); , K$ ~6 O+ N1 p# _
printf("ress any key to halt:"); $ d4 p1 X6 A; M
getch(); : G* D6 r( j$ ~/ i! P
exit(1); /* return with error code */ % v! v7 a5 f* q! _9 S
} </FONT></P>9 B9 X0 I) F! t2 b4 K6 u
<><FONT color=#0000ff>/* draw a line */ & R- [: C0 H7 |: Q( @6 t" ^
line(0, 0, getmaxx(), getmaxy()); </FONT></P>
8 C# ]( D# r+ h4 W% I<><FONT color=#0000ff>/* clean up */ 0 T( ]% F8 r' a5 i) O) z7 C! Q/ \
getch();
0 \  d  N2 ?& z% x# z. o6 Dclosegraph(); : ]; ]: J2 q9 z* i8 X
return 0; ! i0 U+ v" Y% P  Z
} </FONT>
$ \6 h9 j4 N) ?) `  {7 P9 F6 Z2 |' w" @2 P. |
</P>
- q6 V( r4 H+ O9 }<><FONT color=#ff0000>函数名: inport </FONT>
2 h5 T. h# B) b0 T" \0 I1 L) i功 能: 从硬件端口中输入 7 B' B3 ]0 ]# y' x0 x/ ~
用 法: int inp(int protid);
. D+ K2 o( Q6 i. x$ [7 I程序例: </P>
% H( f! e3 K5 z1 [& G" N<><FONT color=#0000ff>#include <STDIO.H>% t  N1 O, U0 x" R. F0 r6 n. t2 f, [9 l
#include <DOS.H></FONT></P>1 C6 U% M3 Y1 R+ U
<P><FONT color=#0000ff>int main(void)
3 i2 \# H( a1 }2 T* s( Z: C' l{ + ]! m1 m5 a0 I( N! r8 s
int result;
8 a7 `$ |/ b& E# z) eint port = 0; /* serial port 0 */ </FONT></P>
! N2 J3 ^" V  j4 [* L( b<P><FONT color=#0000ff>result = inport(port); 9 p4 n  R7 q) G, u% N
printf("Word read from port %d = 0x%X\n", port, result);
: ~# W* Q8 D; V" n! @7 breturn 0;
4 k: Y2 H  S3 `- M6 x8 E* S}
' O" E( }* ]9 m# M; o1 P1 ^6 E9 w1 n# G8 @
</FONT></P>
5 V( r' d2 I% C% e! i& F7 _8 o2 Q<P><FONT color=#ff0000>函数名: insline </FONT>4 v, ?/ L! a; @- `2 Y1 W! H# X
功 能: 在文本窗口中插入一个空行
  k# i& Y' s. L用 法: void insline(void); % j5 r) i4 @4 D6 d7 ~" U
程序例: </P>8 m$ I8 U7 N3 T) \: T+ L( H
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>
; P" w* z; ]9 ^  T7 L: X<P><FONT color=#0000ff>int main(void)
; n& q/ R2 f# T- Q( j# a- S{ ; j+ V) J5 H1 T& Y" [7 L6 k
clrscr();
$ C$ B2 p: j' w& u: ?cprintf("INSLINE inserts an empty line in the text window\r\n");
  e& ?) x+ Z; F# Zcprintf("at the cursor position using the current text\r\n"); : ~- N6 J: k- P# B, T# X
cprintf("background color. All lines below the empty one\r\n"); - F/ |/ z% u0 w, s
cprintf("move down one line and the bottom line scrolls\r\n");
$ [- q1 B! L4 F% bcprintf("off the bottom of the window.\r\n");
8 q2 X& U1 ?) jcprintf("\r\nPress any key to continue:");
+ R* K5 g9 |, ?gotoxy(1, 3);
+ L& \7 v1 v: u7 I; K8 bgetch(); - ~2 B$ M& O8 _! N% D% u. M, _/ E( ~
insline(); : j9 h8 w( R: ], ]5 X: u
getch(); 5 [: a9 M, T$ O( H1 @+ \" ~2 x
return 0; 2 J0 o  M7 K4 c) S, F, v6 w
}
- a% X! c% G: E- F</FONT>
' G4 r) L- ^$ p+ r- h. Y0 h  m& d: f' Y. q
</P>, F) Q+ c, K8 d: C2 N, s- q
<P><FONT color=#ff0000>函数名: installuserdriver </FONT>
1 o5 D7 u  {) H  [, n% L  F5 ?功 能: 安装设备驱动程序到BGI设备驱动程序表中
3 H6 w8 c& O( Y+ T3 ]% o- W用 法: int far installuserdriver(char far *name, int (*detect)(void));
9 m' k& }5 z+ H% U7 V0 d) e. J程序例: </P>
1 r8 e+ C& n% k8 g<P><FONT color=#0000ff>#include <GRAPHICS.H>' a, ~' C# k8 ~5 h+ W* y
#include <STDLIB.H>9 M+ C- o9 w# B' j+ z7 Y9 m. Z6 X# y
#include <STDIO.H>
1 {8 |. X2 m; F/ g! _0 `4 t#include <CONIO.H></FONT></P>' V. u5 {8 x  H
<P><FONT color=#0000ff>/* function prototypes */   V% K: g2 a; {0 F
int huge detectEGA(void); 7 A# t; B1 W9 F) h- [
void checkerrors(void); </FONT></P>9 {& W; [. l8 _; ~1 a- Z
<P><FONT color=#0000ff>int main(void) " O7 A7 O1 Y( i) T' D
{
+ h' I/ Y- }- x9 f% O5 L' \1 p5 aint gdriver, gmode; </FONT></P>) X9 a7 X4 |! B1 Y8 r$ }
<P><FONT color=#0000ff>/* install a user written device driver */ 2 \3 g' F# O' {2 J6 _" C6 b, W0 P
gdriver = installuserdriver("EGA", detectEGA); </FONT></P>
5 g" e/ |5 G2 E( K: c<P><FONT color=#0000ff>/* must force use of detection routine */ 2 `) J0 `# G6 K5 n  d
gdriver = DETECT; </FONT></P>
$ M7 \  |  `( B% g<P><FONT color=#0000ff>/* check for any installation errors */ " L2 I5 j/ O- }
checkerrors(); </FONT></P>2 a: T* T& M& B
<P><FONT color=#0000ff>/* initialize graphics and local variables */ : J8 b1 O) Z4 v* m" Z
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>3 ]' I* m9 r' |7 t+ O( F7 n+ U/ N
<P><FONT color=#0000ff>/* check for any initialization errors */ 8 X. Y) C  E" k* o  @: `$ L9 x
checkerrors(); </FONT></P>
# Z6 s0 Q, d1 z* y+ W<P><FONT color=#0000ff>/* draw a line */ % Z, h2 v& K- n0 Z
line(0, 0, getmaxx(), getmaxy()); </FONT></P>+ ~1 s; O6 O% \! e
<P><FONT color=#0000ff>/* clean up */ 2 `0 G9 F! U. }0 O
getch();
  t: y& g' M, Q) E9 Aclosegraph();
! e: }$ u, B. R* w! ?9 ~% D# Lreturn 0; - e  P, j8 U5 K. f
} </FONT></P>: t1 x" \+ R1 E9 D  U7 ~8 V- i
<P><FONT color=#0000ff>/* detects EGA or VGA cards */ 4 b% D* ]0 Q) I- N5 d8 R8 F
int huge detectEGA(void)
- V0 N! g% c( h- {' A1 Z{ 5 B- M- ^  f6 U  ?
int driver, mode, sugmode = 0; </FONT></P>
& l6 W+ ^; v6 ], `<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode);
, x$ a. |! F* j: I2 z% s& l; @if ((driver == EGA) || (driver == VGA))
( [( w! J5 K: o; k+ C& S; w( `/* return suggested video mode number */ % \4 t; Z, v% o
return sugmode;
& X( e' |+ M, L$ o8 E/ n  _0 r& yelse   u8 l( ^" K; G
/* return an error code */ 6 Y" V0 i6 a, e0 v$ ?7 W7 r
return grError;
* H3 t: h7 B5 @7 H} </FONT></P>
2 U# K5 d; F: t<P><FONT color=#0000ff>/* check for and report any graphics errors */ # I( D# R! F! {) o9 ^# n3 ^7 U0 P
void checkerrors(void)
7 _+ E* ^$ z8 h3 {- ^2 b6 S{ # v* [* }. x) _8 d- Z/ m1 O
int errorcode; </FONT></P>
4 \3 f4 B9 Z# w& ?2 `: C<P><FONT color=#0000ff>/* read result of last graphics operation */ ' z/ R2 r) `. t0 c+ [# y
errorcode = graphresult();
* d8 L" l$ z* U* k+ y7 |if (errorcode != grOk) 9 b& B# l$ C! h& j' x
{
" U* u' c6 s; e! W  ]" u  Aprintf("Graphics error: %s\n", grapherrormsg(errorcode)); 4 V, w7 P) _" ^- \% e# k9 x, e
printf("Press any key to halt:");
& T& D6 p6 q# ?* t. J& |; jgetch(); / M' q5 i, Z  w* g& m9 j
exit(1); 2 ^1 V5 B9 w6 P' U0 p. e
}
# Q' [; z. X  R6 j; O" S) x* l} </FONT></P>  G' Q' R3 X: _9 D% J# e
<P><FONT color=#ff0000>函数名: installuserfont </FONT>; L$ d6 x4 h$ i+ d7 T* L
功 能: 安装未嵌入BGI系统的字体文件(CHR)
( k* f, M1 H/ |& j用 法: int far installuserfont(char far *name); 3 Z* V6 p8 |1 a+ a! k
程序例: </P>7 l. U8 b* N% m/ Y  }, K
<P><FONT color=#0000ff>#include <GRAPHICS.H>. V* H' q, p2 [$ `  s5 R
#include <STDLIB.H>$ ]! m( F, A& }1 K& J9 V* T3 P' J' U/ x
#include <STDIO.H>( _* p( a5 y0 @) R/ P
#include <CONIO.H></FONT></P>
  v% k' S8 K* l: |6 Z! z<P><FONT color=#0000ff>/* function prototype */
8 g9 {- Z5 g: H$ Ovoid checkerrors(void); </FONT></P>
6 b+ c: F. e! G1 h; B0 Z' q6 M1 Y<P><FONT color=#0000ff>int main(void)
* d; s+ n$ J3 V5 s1 T1 r. X& s1 l6 C{ & I. Y. j. ^+ a9 ~, o
/* request auto detection */   \* \. g; N/ S& k4 d
int gdriver = DETECT, gmode; , e+ x# C9 |# I/ w/ W
int userfont;
" Y% p4 l1 l$ x* z+ l8 d5 e9 vint midx, midy; </FONT></P>% s! ^+ `5 p- J, n# U5 F3 L# Z
<P><FONT color=#0000ff>/* initialize graphics and local variables */
7 G3 H: ?% A9 o. g1 M! Yinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>/ D* w7 h! a9 t8 s- g
<P><FONT color=#0000ff>midx = getmaxx() / 2;
6 v3 T  g0 H9 jmidy = getmaxy() / 2; </FONT></P>
' S9 @! d5 e0 F. Z. K* R* ]) U<P><FONT color=#0000ff>/* check for any initialization errors */ 0 J# t1 B2 z/ u8 U1 C0 u2 g
checkerrors(); </FONT></P>7 a! h3 E1 [, D5 h  m) v: b
<P><FONT color=#0000ff>/* install a user defined font file */   u) i6 [0 N5 u; \
userfont = installuserfont("USER.CHR"); </FONT></P>
" i$ B, b2 D+ P7 c# R8 S  Z( i<P><FONT color=#0000ff>/* check for any installation errors */
2 f9 g1 P3 {: E% Z" hcheckerrors(); </FONT></P>
2 I- Y, [% z  ?<P><FONT color=#0000ff>/* select the user font */
5 E. K7 s# _8 _0 vsettextstyle(userfont, HORIZ_DIR, 4); </FONT></P>2 H+ A# q$ i6 G7 f6 t2 c
<P><FONT color=#0000ff>/* output some text */
6 ?: j( m. O. [* n2 c4 m; T% Iouttextxy(midx, midy, "Testing!"); </FONT></P>
% |1 b. l" X( w1 w. z<P><FONT color=#0000ff>/* clean up */ 8 N2 h% i2 }9 X6 I* D5 x- W
getch(); 3 `" ?+ Y! Q  d
closegraph();
5 g+ s. R" d; p; a: [return 0; 1 w3 x/ A/ I7 h- _
} </FONT></P>
: L( m4 b3 r% l, Y9 Z7 r9 I. ]<P><FONT color=#0000ff>/* check for and report any graphics errors */
4 P7 N, I: \+ }3 B6 b% V# `void checkerrors(void) ; X3 o. a0 {$ ]3 T* r2 |+ N
{
. y, r# ?) f. e' K$ k- Mint errorcode; </FONT></P>
/ r3 P! W& X; E<P><FONT color=#0000ff>/* read result of last graphics operation */
/ T! D9 \# x+ B7 D* z# c. Qerrorcode = graphresult();
- v& Y/ L! h% L% {9 cif (errorcode != grOk) : M: N1 F" H  k2 T% H# P( r; h9 F
{ 7 \- t4 x. Q8 g9 W3 b* n  u7 s
printf("Graphics error: %s\n", grapherrormsg(errorcode)); - `4 l; u' e$ }. c, Y  v' z) y& M6 E
printf("Press any key to halt:");
. o6 H1 P/ A: J7 Igetch(); 6 b1 q$ K% \6 U) m: z0 ?' f: a
exit(1); - c6 d8 C) j2 D* c& M2 j- l
} 5 d/ Q) `. E2 f4 Y
} </FONT>! i$ V2 P+ n! M
3 [" \, Z6 D; Y9 g  Y. G9 D' ]3 Q

. z- k+ y& x5 g4 g( z. g</P>
8 u( }! L  u8 z1 [. ~+ ^7 B" I<P><FONT color=#ff0000>函数名: int86 </FONT># t* {8 c6 D  L7 \5 I9 l  w! H& E8 S/ B
功 能: 通用8086软中断接口 ) R- i* {! d1 K5 C7 @- d1 h4 N
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs);
& p0 l3 i  y# k2 n, r程序例: </P>
8 E0 T1 L- m9 X5 n3 }# S<P><FONT color=#0000ff>#include <STDIO.H>: T  [/ V3 @" i% D% B5 ], n# E
#include <CONIO.H>% T. h- J% A& }
#include <DOS.H></FONT></P>0 S$ c9 ]. K* i7 d+ @% o. z3 t
<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>. `1 K2 F  F" q$ s7 y+ Q% N$ K
<P><FONT color=#0000ff>void movetoxy(int x, int y) ! v, {; Z4 P1 k+ D6 l  i
{
/ e4 J  x) F- Y2 h! ^, ]union REGS regs; </FONT></P>
7 u3 J. E) g! f) s- v3 x<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ & k9 S# I  D" X/ @1 z$ l! M
regs.h.dh = y;
7 o+ ^5 x6 F; q% ?3 vregs.h.dl = x;
/ f, S8 ?7 ]# q2 |5 J! Uregs.h.bh = 0; /* video page 0 */
9 f* Y8 P6 @. S0 ^" k! hint86(VIDEO, &reg;s, &reg;s); - I& f7 f' x7 [" x; D5 X/ d8 y) n
} </FONT></P>
- `7 M9 R8 K" P% i7 F<P><FONT color=#0000ff>int main(void)
3 x7 E* w4 v3 x3 c! l0 ~! F{
( V% h& d! k' o; m$ u" [8 ^clrscr();
; A0 r2 c6 q, e0 n9 S$ ]" W5 `movetoxy(35, 10);
2 G. d6 d2 A7 T' P7 t! d0 Bprintf("Hello\n"); % O  z! c* Q7 m" R
return 0;
9 h; \# `7 [3 x1 w$ A} </FONT>3 A0 i% {1 K0 E1 m: X! y8 h

  k4 X# Q. q2 [8 f8 W</P>
7 ^" F  K8 R- {4 `# C4 E<P><FONT color=#ff0000>函数名: int86x </FONT># L* ^) e% }+ `  q* K
功 能: 通用8086软中断接口
9 X% d: E1 F$ H9 e1 @9 j0 k用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs,
# R. e+ H( L( L/ @struct SREGS *segregs);
% C9 f) e; e+ p1 b程序例: </P>
' \) a* f. ]. V<P><FONT color=#0000ff>#include <DOS.H>: z( U" v, [* X
#include <PROCESS.H>
, v2 c* U& t# k, z#include <STDIO.H></FONT></P>2 E8 S7 e9 k5 g+ W, G* O, h" C0 }
<P><FONT color=#0000ff>int main(void) , c5 m( N7 a/ s$ U$ K) x4 r
{ ' C& \) b# [) K" X
char filename[80]; 5 F& s; [) E9 v8 w# H" s
union REGS inregs, outregs; ( y5 j( p/ k( r, Z- U8 K
struct SREGS segregs; </FONT></P>
; y  _! c. ~( J. @1 F. I6 o1 @<P><FONT color=#0000ff>printf("Enter filename: "); 0 _: s& W8 M, e6 p8 q- Z/ f
gets(filename); , Y* A) i: Q: p/ n. Y1 I
inregs.h.ah = 0x43; 0 _' s7 r% g: Q% T( R6 f# l! s
inregs.h.al = 0x21;
+ X% v) W+ ?7 j  Y9 uinregs.x.dx = FP_OFF(filename);
/ m" y2 G7 G! T, esegregs.ds = FP_SEG(filename);
5 @3 t$ j& D4 j8 Eint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs);
. z3 Q# U4 _7 r# `printf("File attribute: %X\n", outregs.x.cx);
2 G5 N' F+ H0 j" Ereturn 0;
! ?! H1 _# b( w/ r/ z3 F1 V+ y& q}
" b2 X3 v) }, b9 l
$ t/ }; b% F$ e. I</FONT>: Z# F0 _) D8 G- @* z
</P>1 v! I! |  p9 I
<P><FONT color=#ff0000>函数名: intdos </FONT>
$ X+ Z9 f! }5 c* K# c; k( s功 能: 通用DOS接口
" ^7 n% n# a- w/ s0 A用 法: int intdos(union REGS *inregs, union REGS *outregs); 5 {- Y2 j9 V' g& E6 B
程序例: </P>
3 D3 r$ A) B% `- q9 r. [* O<P><FONT color=#0000ff>#include <STDIO.H>
: _: Y8 M/ k% J  n% F#include <DOS.H></FONT></P>
& ^- z& a2 \3 \$ u3 c9 i6 Y: }/ o<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
0 H" e4 V1 p" I+ tint delete_file(char near *filename)
. n0 ]* I" n& \) R: }5 s{
5 C: D& A8 [& x; o) Z6 y, S4 Uunion REGS regs;
. e* N7 W% X' {$ z/ Bint ret; + n8 D' X: ?  g& w5 f
regs.h.ah = 0x41; /* delete file */
" K3 _' s3 _2 K8 c$ N, k( f* x! kregs.x.dx = (unsigned) filename; ' m3 M  c2 u, F
ret = intdos(&reg;s, &reg;s); </FONT></P>
6 U% w8 F: }) p& U( [* f<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ ) Z9 I) G) i2 I) m
return(regs.x.cflag ? ret : 0);
) n7 Z7 O3 s" I0 P: N9 r- S( p- u: _8 i} </FONT></P>
/ |4 x, D9 B1 s# j- M<P><FONT color=#0000ff>int main(void) 1 W( R* E) A) R% C  T7 B; d5 v
{
! b1 G7 f5 u& zint err; 1 X# f8 W6 k3 [: M) _+ a: }* I
err = delete_file("NOTEXIST.$$$"); 1 a  j9 s: J* Z5 t  K% V$ M
if (!err) / ?/ |# s: l) g7 }, M# Y/ _
printf("Able to delete NOTEXIST.$$$\n"); 6 c% b& i, f& E9 ~7 u* q& D
else
  ^8 ]$ Y% N, _, G% c% G( j! gprintf("Not Able to delete NOTEXIST.$$$\n");
) D- H9 u. X3 j; Breturn 0; / p  ~9 u( ^( t# x# u6 u! q) d
}
9 Z; e4 ~( R( i' A; r0 J2 C2 X9 @
/ g9 q7 i. N8 e/ \0 I</FONT>
! ^. q& C6 Y9 S9 N7 s' A- J' t</P>
  Z" G) y% x* d<P><FONT color=#ff0000>函数名: intdosx </FONT># m* P7 G( B. n
功 能: 通用DOS中断接口
, P( s$ F8 n% F; o0 G. a5 r用 法: int intdosx(union REGS *inregs, union REGS *outregs,
- W2 g1 A( V& C7 |: astruct SREGS *segregs);
1 V) b% p4 J3 U) z- C1 Y: y程序例: </P>7 v5 Z: O- I3 w3 w
<P><FONT color=#0000ff>#include <STDIO.H>' \: n6 q- x3 H
#include <DOS.H></FONT></P>9 d! z( c# c) q( K+ i
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
4 D# j2 n) |$ V; ^- X$ Xint delete_file(char far *filename) ) I: P) Z! H3 R* E: x
{
& N. R, b' z$ C1 A) j$ Qunion REGS regs; struct SREGS sregs; 7 ]$ J% w) W7 `4 _, z6 `' i
int ret; : V+ o; ], Z4 h
regs.h.ah = 0x41; /* delete file */
/ Y1 ~5 p' A; \1 n/ rregs.x.dx = FP_OFF(filename);
. p+ w' [& k) x6 f6 [' o' vsregs.ds = FP_SEG(filename);
9 b5 W) X. P, X5 b' b8 `) Iret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>( h7 J2 e, f' {1 K$ p
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ ; t7 Z8 P9 ]) v4 b% E' q# e
return(regs.x.cflag ? ret : 0);
1 \" q: G; v) l2 C  N1 ]} </FONT></P>! J0 V' y/ _  G% j, n
<P><FONT color=#0000ff>int main(void) * w, G+ c' e% b3 I- |% o4 e
{
6 U6 R- r7 |  _int err; , i, o; ?7 ]5 Z2 W2 n0 P. k
err = delete_file("NOTEXIST.$$$"); . B4 p) T5 b8 F
if (!err)
( j3 U/ Q% x8 Z- K+ Cprintf("Able to delete NOTEXIST.$$$\n"); 5 U/ \- w. \) V" n5 M3 x
else
5 i; P. a  C% X5 ]. `. F* qprintf("Not Able to delete NOTEXIST.$$$\n"); 8 {- N/ I6 q5 S# w, Z! Q. n
return 0;
+ X. k6 l; g6 B) Q} 3 o# }/ k9 J& f/ f& `+ @
</FONT>
- C2 n' ~- \' l</P>
4 F7 e- Z; g7 @. g$ r<P><FONT color=#ff0000>函数名: intr </FONT>1 q& T8 ?5 q( u$ I( |" z! d6 l: P3 r
功 能: 改变软中断接口 # P9 A- Q  Q; O2 p0 ]6 v  d* l
用 法: void intr(int intr_num, struct REGPACK *preg); 2 T" O9 j9 q0 t. O# X6 U
程序例: </P>% {" M$ ]# H( ^# {+ y
<P><FONT color=#0000ff>#include <STDIO.H>
" r7 \8 _0 n0 }6 h  ]#include <STRING.H>: v7 _2 I) @1 Q5 \1 R; {
#include <DIR.H>) e4 O" ]8 K. ^3 C3 |
#include <DOS.H></FONT></P>0 O  c6 g7 [, Q/ ~' _
<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>1 B* A8 V! z3 w* M; s2 ]8 u
<P><FONT color=#0000ff>int main(void)
. u& O3 n3 a( w0 q$ x( e{ 8 r) D, [2 b- O! C
char directory[80]; * F) h: H" ^. d+ G
struct REGPACK reg; </FONT></P>
4 }* `" v- _1 }0 N<P><FONT color=#0000ff>printf("Enter directory to change t ");
3 [( M( t$ s/ P9 }0 o/ O2 Ugets(directory); ; A! C" I* X# ?) }
reg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */ 1 V! z( U3 M& r) T7 x# @0 f
reg.r_dx = FP_OFF(directory);
" ~" X) ^/ J/ ^% i, K; @* J! S! Vreg.r_ds = FP_SEG(directory);
7 ~- X) K8 @* X9 q& ^, C. q1 Dintr(0x21, &reg;);
- K7 @9 q" T7 Y+ ^if (reg.r_flags &amp; CF) + N( l7 U. w0 R; h/ \
printf("Directory change failed\n"); - b6 x- A2 n1 k5 D& f
getcwd(directory, 80); 1 n! \) E* m! o( H
printf("The current directory is: %s\n", directory); 8 u3 `  }! n# P) A8 R, N
return 0;
# ]  G- s  V% V, t/ V8 f}
& V* z# z4 T* P% K2 k$ ?( Q</FONT>
9 C% S: r9 k/ d. {% [</P>- `1 T5 @7 k- V, P6 @9 m7 G
<P><FONT color=#ff0000>函数名: ioctl </FONT>
8 x# a* w, v; D  ?+ m功 能: 控制I/O设备
) C  J3 I, @9 p/ `+ o用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]);
0 g% r1 U! U+ ~" D/ i) f0 v程序例: </P>
- a3 F% I( M# x: @; R, Y. |<P><FONT color=#0000ff>#include <STDIO.H>
8 Q0 E9 w: V0 ~. ~0 z4 c5 D0 r#include <DIR.H>
) O- ]9 _; `+ R% E#include <IO.H></FONT></P># k0 m) P7 x6 z: @- g  M
<P><FONT color=#0000ff>int main(void)
2 k5 W' Y9 t! [{
1 C+ F2 m, w& l7 Q+ g0 U( Sint stat; </FONT></P>
0 {) K7 q- h  h! ~1 k<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */
  E( h  m0 L3 b9 Gstat = ioctl(0, 8, 0, 0); ) ^, x1 P: V, T1 r5 T; E+ _, B2 {
if (!stat)
# k3 K; K/ g# a! n$ U; @$ Pprintf("Drive %c is removable.\n", getdisk() + 'A');
$ n' q6 L5 [0 x# [) c. E( Pelse 2 f: J( K' q8 q; N# b7 _: @% b8 {
printf("Drive %c is not removable.\n", getdisk() + 'A'); $ n3 r' c% c) v
return 0;
1 [3 v) D) `( {' i$ r$ {! e# K: p} * I; ?$ h' p* A5 S
2 T0 U: z5 c6 _: r/ i2 |
</FONT>
' G$ _% B4 Q5 P</P>
8 u* B" F; Y2 [0 r<P><FONT color=#ff0000>函数名: isatty </FONT>
$ q% s& m$ _# f  m! O7 r' A功 能: 检查设备类型
7 D" W5 g7 }5 o用 法: int isatty(int handle); 5 @! I2 L1 s& Y
程序例: </P>
5 O. J3 _( v0 e. g, @- }- z+ o6 v<P><FONT color=#0000ff>#include <STDIO.H>8 ~+ `  h; V3 z9 H
#include <IO.H></FONT></P>
9 z2 Q! t' I0 X( ^  d) n1 D! O5 d4 }- p<P><FONT color=#0000ff>int main(void) & `" M" _  T3 Z: D
{
7 {: y1 G6 K' ?2 a; Rint handle; </FONT></P>
: r. M" M; N7 u/ E3 i1 a<P><FONT color=#0000ff>handle = fileno(stdprn);
* O! c6 U- c. s7 R5 A3 Gif (isatty(handle))
( @3 }( {' o0 G3 v1 D" q& fprintf("Handle %d is a device type\n", handle); ( y! P2 X2 b  l9 W
else
! `5 m7 n# j5 A* Y' g( ~' Nprintf("Handle %d isn't a device type\n", handle); , i( p8 E9 d9 d/ h& ~- i* e, a- w
return 0;
# M7 @1 j# Z2 R5 z& w} ' {( O4 k+ ?# N5 ^- K! Q

5 l3 _+ e& z) C3 x</FONT>
0 D8 ~, x/ X5 N0 y7 O0 G1 }</P>& ]' j4 r3 B  e. P9 C* M
<P><FONT color=#ff0000>函数名: itoa </FONT>
% k/ r: V0 u$ \功 能: 把一整数转换为字符串 3 X' j2 G& l) q$ U- K* k; ~
用 法: char *itoa(int value, char *string, int radix);
! a" @9 Z5 n% l6 s4 X1 ^程序例: </P>+ f+ ~4 C. i  t+ e1 c
<P><FONT color=#0000ff>#include <STDLIB.H>
# L/ U6 u) L' Y#include <STDIO.H></FONT></P>% b  s9 V9 y4 A# w9 _; r; W, j8 A
<P><FONT color=#0000ff>int main(void) 8 z% ?3 v8 b7 o  Z' G( I: a
{
# U- r( t8 R9 |int number = 12345;
% u) E% K5 \8 U7 K2 m, Mchar string[25]; </FONT></P>
3 ]: l$ G) s# o$ f<P><FONT color=#0000ff>itoa(number, string, 10); ! P0 i" m5 N& {, j5 z& `  T7 o
printf("integer = %d string = %s\n", number, string);
- N& H5 ^) I4 u' Freturn 0;
4 x+ e$ R& t$ _+ ^} </FONT><FONT color=#0000ff>
. E2 I& z2 p0 s! G" S5 Y* 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-4-21 01:35 , Processed in 0.602544 second(s), 51 queries .

回顶部