QQ登录

只需要一步,快速开始

 注册地址  找回密码
查看: 2424|回复: 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>1 z/ y0 h0 h1 i2 w: T; o
< align=left><FONT color=#ff0000>函数名: imagesize</FONT> ) x  n8 ~: U& S5 [
功 能: 返回保存位图像所需的字节数
( ?% I, H' N9 d1 n' O3 f用 法: unsigned far imagesize(int left, int top, int right, int bottom);
+ G1 n+ S) X6 ]( J# R. g程序例: </P>
' }9 ^+ V8 N9 {! w7 x6 J1 F& f<><FONT color=#0000ff>#include <GRAPHICS.H>
. k3 C" Y( R# b#include <STDLIB.H>! {3 T& y* y" L+ _$ r! M$ J
#include <STDIO.H>
9 n# U, `+ Q$ M( F/ }#include <CONIO.H></FONT></P>
0 B  F2 U# i6 a6 {: g3 x: e! o" X. R, ]<><FONT color=#0000ff>#define ARROW_SIZE 10 </FONT></P>
8 K( _& k" `( I- U) a/ q% _<><FONT color=#0000ff>void draw_arrow(int x, int y); </FONT></P>
7 \; k8 B- k/ c$ w<><FONT color=#0000ff>int main(void)
" I& ~/ c7 J6 T6 _{ : O" S9 J0 q, E/ H
/* request autodetection */
2 c, i* I) N3 d) Oint gdriver = DETECT, gmode, errorcode; 5 T# y7 ]. M3 p6 q. }
void *arrow;
6 d/ O! E/ i0 s8 Y6 v: _3 R( Pint x, y, maxx; 4 A4 ?1 y3 S2 q5 ]7 p
unsigned int size; </FONT></P>
- v. x1 M# f- L. U$ S<><FONT color=#0000ff>/* initialize graphics and local variables */ 5 l6 `, R' y9 q5 E) [: c: R/ _
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
: ]) P9 ^% J  [<><FONT color=#0000ff>/* read result of initialization */
* S4 l$ _0 ~* h' O2 D/ verrorcode = graphresult();
8 n; N" u9 |6 n6 H, nif (errorcode != grOk) /* an error occurred */ 7 N1 c. E- c! U* a. c/ i0 X
{ 5 |: [8 i% }1 b- ^2 t
printf("Graphics error: %s\n", grapherrormsg(errorcode)); 3 s* ?4 o! {8 L9 @
printf("ress any key to halt:"); 5 T3 P# ~; C9 r3 L4 x! U$ l, ?
getch(); & E0 {3 t5 L7 q: u
exit(1); /* terminate with an error code */
) R$ J5 m" c1 s/ z} </FONT></P>  K5 N& ]. O: c* ^( l* ?  j/ n
<><FONT color=#0000ff>maxx = getmaxx();
# w  `6 H, Y6 v, mx = 0;
( {# v9 B- W$ A; j& Ry = getmaxy() / 2; </FONT></P>
3 O! y) f6 R0 Z# v* Y6 A<><FONT color=#0000ff>/* draw the image to be grabbed */
9 K6 B& `  H3 mdraw_arrow(x, y); </FONT></P>
4 a0 A  v# L, ~, }. X6 L- x) v<><FONT color=#0000ff>/* calculate the size of the image */ : W7 A+ _6 F4 V- n7 `3 ^: y6 W
size = imagesize(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE); </FONT></P>% P& }2 C7 \1 p* h* Z+ t
<><FONT color=#0000ff>/* allocate memory to hold the image */ ; `. R2 W* j6 a; P) z, G+ H5 W
arrow = malloc(size); </FONT></P>7 I5 o7 M3 Q" \7 V& C' {) l
<><FONT color=#0000ff>/* grab the image */
3 B2 \; T8 a- d+ I2 X& |getimage(x, y-ARROW_SIZE, x+(4*ARROW_SIZE), y+ARROW_SIZE, arrow); </FONT></P>4 f8 L, E" }2 L5 Y' Y
<><FONT color=#0000ff>/* repeat until a key is pressed */ 3 j  i# C% K: b) ~. t( q+ g- C; A
while (!kbhit())
, k+ k8 _: v6 Y' |( h{ 3 S* [. U  x* U& F
/* erase old image */
% j" Y! v7 D# t! W5 I" iputimage(x, y-ARROW_SIZE, arrow, XOR_PUT); </FONT></P>
  C" H& N' U) v! Y- e<><FONT color=#0000ff>x += ARROW_SIZE;   [* a& r) r/ _  G; v/ ^7 j
if (x &gt;= maxx)
" C* O8 @! u& l1 Nx = 0; </FONT></P>
8 g6 \5 J" [3 W/ C<><FONT color=#0000ff>/* plot new image */ " E/ w0 @; j' W  a% Z1 q
putimage(x, y-ARROW_SIZE, arrow, XOR_PUT);
- U# j) l1 o. M+ n+ n, i+ W# [+ p} </FONT></P>
- l! l( o4 O  r# ], R<><FONT color=#0000ff>/* clean up */
8 K  s% G: c4 W" ]# _free(arrow);
0 Q0 B" a5 R+ u4 t! ]  w- Nclosegraph();
+ ^; i4 P8 u4 [4 g3 a  xreturn 0; ) Z" ~4 i" u) L7 D5 R
} </FONT></P>
& k1 [. `& K/ L. y<><FONT color=#0000ff>void draw_arrow(int x, int y) " P' g8 J/ D$ B: I7 h
{ . \  A; _+ }; K$ T% O4 {- u
/* draw an arrow on the screen */
* o( Q9 i7 n/ Y1 a0 ^; S: c" C! Cmoveto(x, y); . W# R2 d( j9 C8 J, U& D4 D
linerel(4*ARROW_SIZE, 0);
- [0 X( h" w1 Z/ _* q5 _; |2 `* }5 \linerel(-2*ARROW_SIZE, -1*ARROW_SIZE);
2 E3 V% R. }0 F/ mlinerel(0, 2*ARROW_SIZE); % r% U9 E4 f- p4 L# x8 f* x5 y+ U
linerel(2*ARROW_SIZE, -1*ARROW_SIZE); 1 ~+ L* |  }; M& d6 z
}
" V1 E1 F) m$ r/ ]1 @0 e% z
' a  {, `3 @* M6 X9 k& q( Y+ L
# b2 f2 Z) D. z% n5 ]: ~</FONT></P>6 ~2 B" @! [" i0 F
<><FONT color=#ff0000>函数名: initgraph </FONT><FONT color=#0000ff>" [4 p4 t( [, N- o$ _
<FONT color=#000000>功 能: 初始化图形系统
: c! r1 ^) b( P  L2 o8 j用 法: void far initgraph(int far *graphdriver, int far *graphmode,
: P& S$ b5 ]8 h  {) e6 j, ichar far *pathtodriver); , {; J: `# i7 G6 \  q9 ^7 k5 b
程序例: </FONT></FONT></P>$ h( ]$ u5 C) ]7 J& q
<><FONT color=#0000ff>#include <GRAPHICS.H>1 r0 j5 ^& j7 B5 X
#include <STDLIB.H>
" X- C. i( h; m0 v4 [" T9 ^% O#include <STDIO.H>/ R$ B5 e4 t: Q% v, G0 q) b4 S
#include <CONIO.H></FONT></P>8 S4 x! u$ o0 O" {: [+ |
<><FONT color=#0000ff>int main(void) $ F3 J1 u/ z* d7 f# F8 ]7 Q) D. z
{
1 p* y/ e8 X- B- I/* request auto detection */ * D4 J0 o6 M4 L
int gdriver = DETECT, gmode, errorcode; </FONT></P>% T- F7 ^9 G: u$ A
<><FONT color=#0000ff>/* initialize graphics mode */
" A" @2 e- ?- d6 J8 Y! kinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>7 S8 O2 H( c$ D) x7 J& d: S+ ]
<><FONT color=#0000ff>/* read result of initialization */ ( s) |" u" i2 l  Y3 g
errorcode = graphresult(); </FONT></P>5 a0 `/ y7 G, y( P! R: c  P8 _$ t$ ~
<><FONT color=#0000ff>if (errorcode != grOk) /* an error occurred */
/ g) N* w- D5 }2 _7 C, f{ 5 d/ e" a; ]8 Y/ [
printf("Graphics error: %s\n", grapherrormsg(errorcode));
* W7 b, ^& Y* l; x- S% D; h. sprintf("ress any key to halt:");
! F$ U$ s6 N+ T5 @6 H. F" S0 v6 ]getch(); 9 }- ?1 I: A. ]/ o* I% g, M
exit(1); /* return with error code */ 7 p6 l9 s0 N( e% r2 I) y
} </FONT></P>
+ c0 |3 d) a2 \<><FONT color=#0000ff>/* draw a line */
- z: ]# Q7 c' [; g/ Dline(0, 0, getmaxx(), getmaxy()); </FONT></P>
4 K/ A1 w* s0 G/ M& V9 a<><FONT color=#0000ff>/* clean up */ 3 h7 o/ z) q) m, {% I: a
getch();
# b+ e" M* z+ X# q" e; m% X' sclosegraph();
, f9 ?. q0 W% N. G- q0 ^return 0;
! I4 m1 P! Q7 _) C& e, O1 Z} </FONT>
! n. G0 x7 E+ m- F. w! L6 M3 v- |6 Y, P! |4 f$ |, r  V5 e- [" d
</P>
( _" q! a& F. N) k/ n. \5 {<><FONT color=#ff0000>函数名: inport </FONT>
5 M( G! w, I: S9 G+ {& Y2 ~功 能: 从硬件端口中输入
2 p  }2 v7 C% ~( a8 Y用 法: int inp(int protid);
  F, \" W2 W( x6 w程序例: </P>
3 C1 c% g* c0 N) x$ H<><FONT color=#0000ff>#include <STDIO.H>7 m( A+ k7 [& T5 F
#include <DOS.H></FONT></P>: R1 h0 F8 V7 K+ K0 |5 R8 m
<P><FONT color=#0000ff>int main(void) * N0 l+ W: W! h! c8 G6 S6 V5 `
{
" d% h9 G; W: g- D. {( f5 P2 Aint result;
* A; \: s9 p4 C5 Nint port = 0; /* serial port 0 */ </FONT></P>
) N( j* O! Y6 D% }<P><FONT color=#0000ff>result = inport(port);
$ R2 w! j0 V' H, Q" Z- x) y5 nprintf("Word read from port %d = 0x%X\n", port, result);
, J- k; Z3 F; ]return 0; 4 _) w4 {! d8 Z1 L$ G7 Q  w
} . C. a, W- f3 k+ _- q: A6 v

' r- d$ w% p+ U- O  w) I7 i</FONT></P>
. p: f) E, @- x<P><FONT color=#ff0000>函数名: insline </FONT>7 `2 v2 H+ y3 t1 ^  H! `9 S5 [
功 能: 在文本窗口中插入一个空行
( r0 T9 v$ c' A用 法: void insline(void); ( g" P0 _; j- n0 Q* U: x
程序例: </P>2 Z* P: _( [: J- Y5 u
<P><FONT color=#0000ff>#include <CONIO.H></FONT></P>( h9 @& n& e+ A$ S' Y( G3 }% H
<P><FONT color=#0000ff>int main(void)
# x' G% C6 C" f$ F) h" H{ ) Z- }) A( a2 ?# w6 H7 M2 X) r  I4 B6 }* I
clrscr();
  z4 o6 V, Y5 {) Jcprintf("INSLINE inserts an empty line in the text window\r\n");
# }0 z( H6 I4 M5 y& Z  Kcprintf("at the cursor position using the current text\r\n");
6 q( W" w' ]; R& Acprintf("background color. All lines below the empty one\r\n"); ) u4 q" T+ N' c/ ~  i& l
cprintf("move down one line and the bottom line scrolls\r\n");
. E% m& L, B- c, T  ^. i1 G1 ]cprintf("off the bottom of the window.\r\n"); % T0 h' f' |" i6 F4 G
cprintf("\r\nPress any key to continue:");
, w& t# P' Y  j) {! C! o0 _' fgotoxy(1, 3);
! ?4 s8 o& B, O+ P1 f  igetch(); 8 |* r* x5 e' X* m/ T, o; o
insline(); 1 s! g2 d, X3 c
getch();
) M. k+ V( s7 D$ R8 {, z; X% ~* Mreturn 0; & }6 H8 L% ?' W3 m2 F1 N
}
+ s( f, t1 L, k! `</FONT>5 x- c( c3 O) K) T; M
4 m( m3 J: {8 H. z9 R
</P>0 V) D) U' a+ d! A6 w. w7 _6 ^
<P><FONT color=#ff0000>函数名: installuserdriver </FONT>$ o  s, n7 U$ j+ b
功 能: 安装设备驱动程序到BGI设备驱动程序表中
" ^7 I- c7 H$ \2 a* b6 W* x用 法: int far installuserdriver(char far *name, int (*detect)(void));
# Z7 u  M8 G! h程序例: </P>) w0 t" i/ v( f5 _7 D% |
<P><FONT color=#0000ff>#include <GRAPHICS.H>
4 l% K) {" H, B2 `#include <STDLIB.H>1 ]( L+ \3 ]3 T& q! H
#include <STDIO.H>/ |+ d4 \2 }7 y; n
#include <CONIO.H></FONT></P>* N) E) G9 ], v- _3 [
<P><FONT color=#0000ff>/* function prototypes */ * U$ J% [# u6 C- |- x6 V5 U+ ]3 M; e
int huge detectEGA(void); 7 ?/ g, G7 C, y/ ?
void checkerrors(void); </FONT></P>
& g( T1 {$ I4 o; Z: e! h: ^: V<P><FONT color=#0000ff>int main(void) 6 U8 v+ g, T3 j
{ ) ?+ y/ s- F4 ]6 M2 v) t
int gdriver, gmode; </FONT></P>) U- e) W  q) x
<P><FONT color=#0000ff>/* install a user written device driver */
# }4 {+ b* |0 N3 q1 o/ Vgdriver = installuserdriver("EGA", detectEGA); </FONT></P>% ]2 O5 D8 @0 H: {4 T4 c
<P><FONT color=#0000ff>/* must force use of detection routine */
; m% i! d% o. J2 K' [gdriver = DETECT; </FONT></P>
4 ~( s8 q9 l  ~7 j<P><FONT color=#0000ff>/* check for any installation errors */ ; o" {7 S$ Q7 @, M, m
checkerrors(); </FONT></P>6 f; M+ f" J, R: ^8 ]$ c$ v# R& m
<P><FONT color=#0000ff>/* initialize graphics and local variables */ : r5 f# ^( n. t0 l8 z. @, v3 [, t
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>! \. {# o- n$ ?
<P><FONT color=#0000ff>/* check for any initialization errors */
; y0 l/ w( O2 D$ h, e" vcheckerrors(); </FONT></P>% K4 @. D4 S/ x6 ?( ?7 p4 c
<P><FONT color=#0000ff>/* draw a line */
6 Q/ I9 q  {3 d) I- @line(0, 0, getmaxx(), getmaxy()); </FONT></P>
, U( `* z; N. h/ ?+ `' y% Y) t, H<P><FONT color=#0000ff>/* clean up */
; d' }" K  w+ @7 D0 P7 k  Pgetch();
3 `7 N) h3 p; [; ~7 ]# l* ]8 Nclosegraph();
% ^+ n) s/ _" i: h) v, lreturn 0; / W" i+ t7 c7 f+ y/ H+ H
} </FONT></P>
# ]  ?6 q, G, N# b, e7 g7 O5 A<P><FONT color=#0000ff>/* detects EGA or VGA cards */
( s/ f2 X) Z# e1 U5 _  Fint huge detectEGA(void)
5 I; F+ A6 E4 k6 a{ 0 |1 j0 n4 |# Q0 @3 N3 R1 ~+ U
int driver, mode, sugmode = 0; </FONT></P>
# P  Q' \3 g, E$ i8 V' |1 a1 e<P><FONT color=#0000ff>detectgraph(&amp;driver, &amp;mode); ) A5 h6 m6 D) @$ f) m- ~8 \2 X
if ((driver == EGA) || (driver == VGA)) ' o# D: v6 i3 C$ D
/* return suggested video mode number */
: G5 m2 L& g2 N# l1 p0 F: Creturn sugmode;
4 w& Z2 m* p6 d! {% ]else
$ Y# f& Y% ]& b5 M2 F! Q/* return an error code */ 9 J% t2 ^+ b5 G5 Q
return grError; / g% L% n, l( ?- n) H
} </FONT></P>
. P( r& g- y# C" d) I* y( i' p<P><FONT color=#0000ff>/* check for and report any graphics errors */
' d# r5 z% P: I1 p+ ~' i6 T! K8 yvoid checkerrors(void) 5 N+ a+ i$ \9 w- j! i4 @8 w
{
. d1 N  O# k2 H7 V/ [1 nint errorcode; </FONT></P>
* S; c7 m8 e% y5 O7 A<P><FONT color=#0000ff>/* read result of last graphics operation */
* {7 c/ v+ x5 ?! G& R& a( @errorcode = graphresult(); 3 g( T/ e% e2 r/ p5 N
if (errorcode != grOk)
6 `3 b' \8 ?9 I- M* z) \{ . w! W7 l4 K' M" N( z6 J9 y
printf("Graphics error: %s\n", grapherrormsg(errorcode));
5 i* L2 s5 ]7 Nprintf("Press any key to halt:");
1 j; I* a' K9 u! t1 D" Pgetch();
" \$ W  S" r3 q' ~- L' I. Rexit(1);
& _6 L% r4 D/ K) ?" R. S( p/ G+ G! }} . D* Q$ y6 U6 x/ J- f# U/ I
} </FONT></P>
+ A; \( ]( {$ e5 G, k& M<P><FONT color=#ff0000>函数名: installuserfont </FONT>$ D* L5 X7 y" N* E+ U
功 能: 安装未嵌入BGI系统的字体文件(CHR) ( b# v1 y) |* v( W* Z
用 法: int far installuserfont(char far *name);
, K* s8 T6 h. h1 ?) Q- h程序例: </P>3 B3 J& `0 @9 K
<P><FONT color=#0000ff>#include <GRAPHICS.H>
6 }/ a& P3 d6 L- J) H. @#include <STDLIB.H>4 \3 w8 b* Q: b7 |1 l1 e
#include <STDIO.H>  W% F- V8 c1 }5 K5 V
#include <CONIO.H></FONT></P>
  m. E! g, z! T, G" @) l+ C<P><FONT color=#0000ff>/* function prototype */ ! v. `2 {3 x' I
void checkerrors(void); </FONT></P>" v! a8 X  V0 O( T9 b8 R( N
<P><FONT color=#0000ff>int main(void) + s8 k9 o- y. y/ E, j. z9 Z& H
{
- c1 q7 X$ \% H3 K/* request auto detection */ . i% ~; G- O2 I! |* n
int gdriver = DETECT, gmode;
# q# \) `: v& d* W4 t& Nint userfont;
, _* b3 c/ b" r" xint midx, midy; </FONT></P>
; ?- |& `; J1 G  _3 c6 E<P><FONT color=#0000ff>/* initialize graphics and local variables */ 2 p/ o& T7 F; r4 d3 t5 C1 S9 Q3 o, M
initgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>
: F2 G# P9 b2 a3 h" c9 U7 z<P><FONT color=#0000ff>midx = getmaxx() / 2;
  w2 N; W9 I& ?' a9 {1 i- t- |midy = getmaxy() / 2; </FONT></P>
8 w, h4 {% r, k/ T<P><FONT color=#0000ff>/* check for any initialization errors */ % N* w7 C+ e4 a0 _
checkerrors(); </FONT></P>  z$ f. M' w; S8 ~% K
<P><FONT color=#0000ff>/* install a user defined font file */
  b- A- y+ j6 Ouserfont = installuserfont("USER.CHR"); </FONT></P>
9 [( x. c$ k+ X. Q+ z: m<P><FONT color=#0000ff>/* check for any installation errors */
$ x" h. r) g3 U; s, A; S* Z# Ucheckerrors(); </FONT></P>
; r( S% x1 r! c: U4 W# I% H<P><FONT color=#0000ff>/* select the user font */
0 h& m' X( Y& x# p: U; hsettextstyle(userfont, HORIZ_DIR, 4); </FONT></P>
7 U$ I3 X; p3 ]  W/ R3 I<P><FONT color=#0000ff>/* output some text */
3 y6 F% c, j7 J7 nouttextxy(midx, midy, "Testing!"); </FONT></P>/ L/ K" x% d' q* {
<P><FONT color=#0000ff>/* clean up */
* w: u( K8 u* T2 Y/ \getch();
! ^- {. ?8 J/ @1 w8 R+ }closegraph(); . v! U. x3 R  a5 R# v& g+ o
return 0;
% s; x% k0 @' L  s: m} </FONT></P>8 r) @/ h: @2 w1 S: V
<P><FONT color=#0000ff>/* check for and report any graphics errors */
3 T0 n8 O% Y( E4 h7 c; \4 r. T0 \void checkerrors(void) 4 X6 J! {. L9 _! Z0 a8 S! c9 R
{ - S9 h3 q4 M# `6 _# @$ C% x( U$ o
int errorcode; </FONT></P>
+ M5 Q- j$ h4 X9 m, o5 b- N<P><FONT color=#0000ff>/* read result of last graphics operation */
7 w) d+ A% C: }1 o) i1 M6 B5 \1 h  @: Derrorcode = graphresult(); 4 p( `% j# L7 e* V2 `/ Q, T! J# Z
if (errorcode != grOk)
/ @* b% C. B1 D8 N, n{
& {; I8 M0 n6 o1 R( Wprintf("Graphics error: %s\n", grapherrormsg(errorcode));
8 ?- [# d( C  z- N! G+ x, Kprintf("Press any key to halt:"); ) r) `: n. n. _+ d6 N
getch(); / f: I5 O4 b  _2 F
exit(1); 8 }+ i% G# x. Y: _
} 2 w2 M1 H8 a3 Z
} </FONT>
$ P2 ]+ c9 P8 I: m, y* [6 q$ {- X
: m8 r% {2 p# G1 w5 I  [
, H8 T! |' K7 y% X3 g/ ^- Q</P>
  g  k% X: [& R5 [. C# }/ g<P><FONT color=#ff0000>函数名: int86 </FONT>' T/ m1 r$ R. a7 {. U. t
功 能: 通用8086软中断接口 - c2 u# s, d6 Z3 p$ E
用 法: int int86(int intr_num, union REGS *inregs, union REGS *outregs); " R7 ?- w4 Z  E  p5 `
程序例: </P>
6 z8 S! ]- z1 R- h4 Z" U& x, x% G9 u! c<P><FONT color=#0000ff>#include <STDIO.H>1 ^3 K3 S  Z" `
#include <CONIO.H>
$ h$ N1 J8 R& M#include <DOS.H></FONT></P>
$ ]' v4 u/ h7 c& }$ `<P><FONT color=#0000ff>#define VIDEO 0x10 </FONT></P>
& `- j2 X2 M# ^* g3 U: W<P><FONT color=#0000ff>void movetoxy(int x, int y)
4 q2 B2 J% U2 o3 W7 O{
9 p+ V. V5 i9 s7 _& B" [. {2 Xunion REGS regs; </FONT></P>: ]5 c- k3 I% }" W
<P><FONT color=#0000ff>regs.h.ah = 2; /* set cursor postion */ ' Q  k0 u& b$ H; H" o
regs.h.dh = y; + I/ k: E: n- k; y5 c6 h6 D) ]
regs.h.dl = x;   Z: A! B# Y) C
regs.h.bh = 0; /* video page 0 */ " C. h" J' S/ k6 c! B% ]5 }9 T
int86(VIDEO, &reg;s, &reg;s); $ L5 d9 Z. E5 z& t, z
} </FONT></P>  p5 M$ p4 e* X% A6 X
<P><FONT color=#0000ff>int main(void)
3 S4 ~" ?9 B0 m, K* O% d0 y( {- W{ , D" Y" @- F* \: }8 ~1 [
clrscr();
, b+ G  b  e: Z8 |4 R% H& C. xmovetoxy(35, 10); - v4 K$ a( ~5 Q4 `, G
printf("Hello\n"); . S' ^! w) d$ V" Z' m% W( n4 t
return 0;
' J) z! R  \* L( z' y) h} </FONT>
( m! k  X) m+ U9 M/ M; {5 E5 @' Z# l# x
</P>
& f% |- L8 I0 j. S: `& m8 ^7 z" B<P><FONT color=#ff0000>函数名: int86x </FONT>; @7 c  r( N8 v) f( h% Z; D
功 能: 通用8086软中断接口
9 i' Q1 d( b6 x- n0 v, ]5 h' Y用 法: int int86x(int intr_num, union REGS *insegs, union REGS *outregs, ; J+ o8 y" p; x+ m1 ~2 [
struct SREGS *segregs);
: L) S7 k) f' N4 k! G3 C/ p9 T程序例: </P>: X( b1 [7 ^" v* R$ X  I& X
<P><FONT color=#0000ff>#include <DOS.H>
% q% i* }; d" q, d. g' M! B" Q#include <PROCESS.H>2 a( S5 s! ]0 D$ g( \
#include <STDIO.H></FONT></P>! b3 J$ m% \- I
<P><FONT color=#0000ff>int main(void) + l$ f, |5 i# |. d  U6 }7 [
{
* Z- c0 @/ F8 A/ n: y3 w9 ]+ ]8 [( achar filename[80]; 0 F% |- P6 L$ C0 c7 z  t
union REGS inregs, outregs;
. }; y$ R$ `$ v9 {8 Cstruct SREGS segregs; </FONT></P>4 K$ R! d: T  V4 {% p. _/ I
<P><FONT color=#0000ff>printf("Enter filename: "); % t) N% r8 |5 _  Z2 M! v- J
gets(filename);
: [8 D. B8 R+ x4 D  t% rinregs.h.ah = 0x43;
$ }+ X' Z* s3 g# J; ]/ k- N" ginregs.h.al = 0x21; $ y* Q0 J! R* v2 d6 f0 r
inregs.x.dx = FP_OFF(filename);
0 U8 @% l; M( wsegregs.ds = FP_SEG(filename);
% F6 B3 K8 Z2 Xint86x(0x21, &amp;inregs, &amp;outregs, &amp;segregs);
- c8 }& y# D  u" a% s( zprintf("File attribute: %X\n", outregs.x.cx);
4 c6 b! {/ W6 J" q/ _return 0;
) f6 c! d# T% t9 n: t" E7 b} 4 k9 s- \" S& q/ s" M
% {5 q- X) g  L1 _; z1 l* V2 C& y0 K
</FONT>
3 ]! ~, A. F: d  e" \1 x</P>
2 d8 x+ A  H5 r! o! d<P><FONT color=#ff0000>函数名: intdos </FONT>
, F; {. s# k% r% \- `功 能: 通用DOS接口 1 S5 l  s) ?: p( t, M
用 法: int intdos(union REGS *inregs, union REGS *outregs);
: O1 P9 c) M' N8 u: i' l# s/ s程序例: </P>
" z( z6 \* p# G* C% m<P><FONT color=#0000ff>#include <STDIO.H>0 w8 i9 s7 N7 [  c% H% ~5 N
#include <DOS.H></FONT></P>
$ G+ I( |& y5 O3 o<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
8 A+ p  b! |2 V# Y% Rint delete_file(char near *filename) ( @$ E( w$ q. J: N# @7 e+ Z3 h1 U
{ 5 s- J% Y' |# ^" B& N
union REGS regs;
, m! a2 Q( r1 l7 R' o! ^int ret; : T% @4 A( l2 _+ {& m: n
regs.h.ah = 0x41; /* delete file */ 9 r: i/ c- h* M1 {" G
regs.x.dx = (unsigned) filename;
5 B9 v* o- V& ?2 a0 W! r1 D- Jret = intdos(&reg;s, &reg;s); </FONT></P>
4 ]/ p! c7 z' D* P' Z0 G<P><FONT color=#0000ff>/* if carry flag is set, there was an error */ 6 A8 J' J/ x) @  ?4 f. c, B
return(regs.x.cflag ? ret : 0); 9 W# a- D' I& F
} </FONT></P>% z6 g% i' _4 v/ J5 i* {5 V
<P><FONT color=#0000ff>int main(void) ( {" l/ J! l6 q* L6 `0 `
{ , {! e7 S! o! P$ U0 D
int err;
  Q9 {: Z/ K+ `# Perr = delete_file("NOTEXIST.$$$"); 5 e+ I7 T  w$ H
if (!err)
" _6 A6 i$ k: W: Sprintf("Able to delete NOTEXIST.$$$\n");
% C8 T, e$ v: Relse ) p* e* R% J7 }: B0 Z
printf("Not Able to delete NOTEXIST.$$$\n"); ! d+ Y$ G8 z" U7 L# A; ]' N6 s
return 0;
# r1 D0 f  B0 ]& y0 _}
% w8 H; `6 V: G- ?/ o% N2 X& ~) w' J' z* @
</FONT>
; F0 l7 `, r  B' O' m</P>
; d1 Q3 z0 ]$ z3 |3 r3 V<P><FONT color=#ff0000>函数名: intdosx </FONT>% T% g7 N6 ^5 O' K2 `6 u
功 能: 通用DOS中断接口 4 {, i0 u0 C% |8 _  t* Z9 i. A
用 法: int intdosx(union REGS *inregs, union REGS *outregs,
; N1 B$ `- S$ w9 j! vstruct SREGS *segregs); # X- X( m) H" ?0 h# M2 M7 O! n
程序例: </P>2 @. h5 }6 S/ b3 K6 q, V1 e5 H
<P><FONT color=#0000ff>#include <STDIO.H>2 j1 d. e& s2 B, x& e$ e: H& O4 |
#include <DOS.H></FONT></P>4 D1 Y- \3 c; O! j4 ?
<P><FONT color=#0000ff>/* deletes file name; returns 0 on success, nonzero on failure */
- c" K3 Z" }+ e  iint delete_file(char far *filename) , p- e& o+ @' W/ G% m1 M) u9 I; S
{
1 F: y; Y( B" Ounion REGS regs; struct SREGS sregs;
7 t: ^& N* |# vint ret;
6 x% u8 z8 r: d( B& Jregs.h.ah = 0x41; /* delete file */
$ y: _, v3 x( c( Y# y- }3 N( z; S6 B" Dregs.x.dx = FP_OFF(filename); ! E" I% V. ^8 D. P
sregs.ds = FP_SEG(filename);
% ?! L6 a8 v, U' _+ Cret = intdosx(&reg;s, &reg;s, &amp;sregs); </FONT></P>: a; D0 \+ [0 s0 R% K7 h& V4 e
<P><FONT color=#0000ff>/* if carry flag is set, there was an error */
# C. r, o% U$ N9 w' w3 Q! ^, p7 Nreturn(regs.x.cflag ? ret : 0); + g* c& z. O+ W1 M
} </FONT></P>2 ~; q* n) d" X& J
<P><FONT color=#0000ff>int main(void) : G; e, Y7 w9 X
{ # t6 L+ z/ v& S/ A2 o: s5 o
int err;   e# w' k9 ]* U+ R2 n0 i
err = delete_file("NOTEXIST.$$$"); + K0 o; ]2 t* g6 _
if (!err) 2 A" B/ A5 ~0 N( G9 i# P
printf("Able to delete NOTEXIST.$$$\n"); 2 F  M0 W! p" Q" o& m2 [, Y  r6 x% q' R
else
3 J) G' `5 W' Z4 q4 Z6 z- g4 wprintf("Not Able to delete NOTEXIST.$$$\n"); % R+ h9 `, B) }4 |( a% K
return 0; * H/ G) T1 G! J6 w" s  g
}
& s( E8 P0 F9 C. k# U2 h- X" i</FONT>+ _7 O; O  `" j5 z) y, C
</P>
5 @# W4 v7 ]% j/ ^; K/ M<P><FONT color=#ff0000>函数名: intr </FONT>
5 U1 s5 `" P6 G" {+ Q( I, s' |1 u功 能: 改变软中断接口 7 f7 C1 |+ y  T$ b) H3 [, d9 r2 x
用 法: void intr(int intr_num, struct REGPACK *preg); 2 s0 t) A! e5 b3 y
程序例: </P>$ R, \/ ?$ A  Q* R
<P><FONT color=#0000ff>#include <STDIO.H>
5 P8 P- N3 K0 P$ j/ M* l. a#include <STRING.H>9 q, s6 j4 q0 Q# Y  \0 t3 }
#include <DIR.H>  m& i. K1 g/ N0 D% ~! l
#include <DOS.H></FONT></P>4 o- B; G, j- f: V' [( n* y
<P><FONT color=#0000ff>#define CF 1 /* Carry flag */ </FONT></P>$ N  u4 _( v, x4 P6 s& u
<P><FONT color=#0000ff>int main(void)
- V( }1 E  [. o5 e) q! `& H{ % ^9 q3 a4 o1 j
char directory[80]; " H+ V; E" N0 m: A& x) F# V" M3 g
struct REGPACK reg; </FONT></P>
3 ]7 B3 R! ^6 X<P><FONT color=#0000ff>printf("Enter directory to change t ");
1 |6 J; A3 I5 p) m. T. i( f5 Ogets(directory);
5 l: ]7 ?5 ?/ i( T: n2 I$ h8 \3 _2 Jreg.r_ax = 0x3B &lt;&lt; 8; /* shift 3Bh into AH */
% z, ~$ {7 O8 _. w# r/ Z% @6 }' Hreg.r_dx = FP_OFF(directory); + ^. R, w1 N# v0 e
reg.r_ds = FP_SEG(directory);   C9 v6 w1 c& J' S2 t
intr(0x21, &reg;); * Y( t% T" V1 C. e1 i
if (reg.r_flags &amp; CF) 7 D3 A0 X. h# q# {; m  A; ^" G# e
printf("Directory change failed\n"); ; b4 q7 P# `0 o/ p8 f7 `9 I
getcwd(directory, 80);
" l2 i; A8 p1 Z, c2 C% ~printf("The current directory is: %s\n", directory); , U, ~( y; c( x7 U, \
return 0; ( i: H. a7 T% p5 e6 X6 O
} . y, O% _5 z" f
</FONT>
7 h* i+ S7 u, {& l: \9 `% F" N</P>
' H+ I: e8 `% M. |! J5 |<P><FONT color=#ff0000>函数名: ioctl </FONT>: \. A3 o8 q: k# l# Z7 {
功 能: 控制I/O设备
0 s. q; X* L0 s' y) N1 v& K) n用 法: int ioctl(int handle, int cmd[,int *argdx, int argcx]); / Z" \9 A, z, r+ Y) R8 _( D) n3 J" z
程序例: </P>
- I' j. g6 Q$ P# u* \* Z5 j<P><FONT color=#0000ff>#include <STDIO.H>
3 t( U8 T1 M0 Y8 y9 ?#include <DIR.H>4 X' |( d5 S$ c$ |8 U
#include <IO.H></FONT></P>2 B# B3 C. q% Q' j
<P><FONT color=#0000ff>int main(void) 1 ]7 O+ A. P( @# E
{
9 ?  U" s$ @$ u1 j/ S( tint stat; </FONT></P>% [" v& ]# h' ?2 I. n: }$ r! V, T
<P><FONT color=#0000ff>/* use func 8 to determine if the default drive is removable */
' F& j& ^: z' [' sstat = ioctl(0, 8, 0, 0); ; s. A# ~9 P" q5 v4 s( y
if (!stat)
( @# L5 f' M' \5 l/ S$ i; `printf("Drive %c is removable.\n", getdisk() + 'A');
8 _, O6 E, T# q% U/ oelse % I& w. a0 U5 o7 I' ^: R6 W+ s
printf("Drive %c is not removable.\n", getdisk() + 'A');
% U% ^- O6 \' d+ Y( p7 K" S, rreturn 0;
' D4 u4 C! {" ^. l- p} ; F% o1 w5 D+ `

: Y2 f# ]! W: l</FONT>$ c4 p6 ^! Z2 }$ }
</P>( q1 O7 a$ ]; k3 n" J% a4 o
<P><FONT color=#ff0000>函数名: isatty </FONT>
% @: i( j9 ?3 T; k& y" W功 能: 检查设备类型 ' S  _/ S. F  O* d/ a% n* ^
用 法: int isatty(int handle);
. e' s. c: N& W3 G+ W0 x6 K0 C" {程序例: </P>2 r7 h8 R$ B+ f5 f! i
<P><FONT color=#0000ff>#include <STDIO.H>. Y" Q' A! G( v2 f
#include <IO.H></FONT></P>( \5 u, W2 b& w% h: l$ D: t$ [
<P><FONT color=#0000ff>int main(void)
4 V$ E5 t! ]9 x' N( x. c{ " u& @7 x3 w) q6 h" a
int handle; </FONT></P>
2 Q) n/ _, z9 T" ^<P><FONT color=#0000ff>handle = fileno(stdprn);
" G  a' @1 G3 K: S, d1 w9 m4 P0 kif (isatty(handle)) , R# L/ O5 a# c
printf("Handle %d is a device type\n", handle); 3 c4 Y, w" d9 `8 i. J( M
else ; S; |, @; f& _0 c& A# e
printf("Handle %d isn't a device type\n", handle); - q  {' a0 U. w. F
return 0;
4 H, `7 H# y4 p, d: {0 a  P& W& r6 R}
' |. W6 A( T0 r* R( n
+ ?5 B& }- J) ^) V% U. L. o</FONT>$ f! J/ E1 O+ ~' l& g9 b
</P>. O1 a2 Q- e; n% Q, d& ~2 |9 n
<P><FONT color=#ff0000>函数名: itoa </FONT>
: ], Z8 C# W/ ~5 u$ w) O功 能: 把一整数转换为字符串 ' I6 A; I+ D0 Z& b5 g' l2 I, d
用 法: char *itoa(int value, char *string, int radix);
! Z8 W) d0 y2 E. e: m$ [) B0 n. Y. y程序例: </P>
2 Y5 i6 k( ]/ R9 z6 I" h* |+ E, k* w<P><FONT color=#0000ff>#include <STDLIB.H>; x. E+ t+ g" ]- @( i
#include <STDIO.H></FONT></P>$ ]( t% N8 B  J
<P><FONT color=#0000ff>int main(void)
* Q( r1 W% p+ O% d6 \, U{
% l2 q3 k7 Q: c2 Q5 {int number = 12345; : D$ T! L2 K6 I$ ^
char string[25]; </FONT></P>
3 e) U( W3 {) {* S. p) l5 Z' I<P><FONT color=#0000ff>itoa(number, string, 10); 2 X$ j/ G: n2 H
printf("integer = %d string = %s\n", number, string); 3 `( _' n7 N4 ^, u
return 0;
$ C7 f8 J1 z0 n% E( D# b} </FONT><FONT color=#0000ff>
6 h4 ^4 k2 d) g</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 04:02 , Processed in 2.970218 second(s), 51 queries .

回顶部