QQ登录

只需要一步,快速开始

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

函数大全(e开头)

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

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

跳转到指定楼层
1#
发表于 2004-10-4 03:01 |只看该作者 |倒序浏览
|招呼Ta 关注Ta
< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(e开头)</FONT></B></FONT>; a. v  q* P, B( {2 |1 f
</P>
) Q" Q' h. `; H7 V4 E3 V$ e5 f6 J) ~; m4 H+ W
% N5 K- |0 f" j  a( \
<><FONT color=#ff0000>函数名: ecvt </FONT>4 o  o% o- I2 N) N3 u
功 能: 把一个浮点数转换为字符串
  d8 V  Y/ X* Y" {; ]$ ^# V6 O用 法: char ecvt(double value, int ndigit, int *decpt, int *sign);
/ g  g, M4 l' w5 r. N# E. s+ `0 [  `程序例: </P>
. \2 |: j' J7 {4 Z; g: _/ V<><FONT color=#0000ff>#include <STDLIB.H>
, P7 @( W( P5 T5 T: D#include <STDIO.H>- Y! i5 {9 I/ Q1 V7 ], ~
#include <CONIO.H></FONT></P>" @- _4 s" }; o, n. ^
<><FONT color=#0000ff>int main(void) ) H* U( U% q. J; G
{ # ]2 G" Q3 J7 E) q1 A  ]5 E
char *string; 5 b) r/ P# c, l5 I' v0 j
double value;
! g. x. W, X" ?* v, i5 i1 Q: Vint dec, sign; ( ?4 r& Y: ]' W& X( j; Y
int ndig = 10; </FONT></P># V; S4 {; y% I0 X# v0 i6 \9 |% z' G
<><FONT color=#0000ff>clrscr();
# }( }) b8 v( N8 E, A* ^* W! C6 fvalue = 9.876; / o1 _( T4 K0 A9 r1 _7 s( e! J
string = ecvt(value, ndig, &amp;dec, &amp;sign);
# \, f3 i0 x) G) z) w6 k9 q. ~1 ^, Uprintf("string = %s dec = %d \
0 G, o$ {7 E$ n8 Fsign = %d\n", string, dec, sign); </FONT></P>
! b& i) d' ]1 f2 E# {4 m<><FONT color=#0000ff>value = -123.45; 2 x; I1 v# @+ P  Y6 [
ndig= 15;   {9 N% L! D# T
string = ecvt(value,ndig,&amp;dec,&amp;sign);
5 i! U, {  j$ m# d+ jprintf("string = %s dec = %d sign = %d\n",
: `. v( m) b) B5 ystring, dec, sign);
8 T! m  @1 m2 U6 \  U6 ~</FONT></P>0 P7 d2 |  Z+ V
<><FONT color=#0000ff>value = 0.6789e5; /* scientific
7 X* @+ G0 }* g. e9 Mnotation */   f: ]2 T1 @7 P+ o$ a* }
ndig = 5; % }4 n5 S" o8 s0 Q+ ~; D8 M# q
string = ecvt(value,ndig,&amp;dec,&amp;sign); - o  `2 b- S" v/ }& w& T' x: S! ?
printf("string = %s dec = %d\
) D) q" D0 S2 Z: d# _% @sign = %d\n", string, dec, sign); </FONT></P>; b+ Y4 @5 O. i! I* f5 _7 n" S( N
<><FONT color=#0000ff>return 0; 3 J3 o- M# K8 u4 p9 w( C
} </FONT>. F! E2 |5 G& j

: U6 a; V0 q& e: l</P>2 p7 O8 O- `2 o
<><FONT color=#ff0000>函数名: ellipse </FONT>
9 T& F" z! k" k& ]6 G' F# s功 能: 画一椭圆 - n* M1 f5 [/ R! F4 x; {# D
用 法: void far ellipse(int x, int y, int stangle, int endangle,
' B1 C0 d9 e8 G+ I! d1 C  q( J+ _! `int xradius, int yradius); 9 C" W, p& G( e( Y3 y
程序例: </P>
' u4 ?. ^. v. a- F<><FONT color=#0000ff>#include <GRAPHICS.H># C: g1 C" J; m" H; k
#include <STDLIB.H>
/ D+ y. ]8 a# r# r; B/ U#include <STDIO.H>/ I8 i+ \) I8 K+ m( d& }
#include <CONIO.H></FONT></P>
7 ~0 C( M$ o5 u' E<><FONT color=#0000ff>int main(void) + y3 ~0 x8 r- y2 h
{
  @- j- P% k4 d* i/ X/ b3 S$ s* ]/* request auto detection */ 8 p4 F, _, L8 z9 L3 j
int gdriver = DETECT, gmode, errorcode; ! W/ }" l9 R3 O
int midx, midy;
! L. @# O% h' T1 ~; Eint stangle = 0, endangle = 360;
& a! k0 f% P: W% e$ s2 dint xradius = 100, yradius = 50; </FONT></P>0 z" u) f# J1 \; t
<><FONT color=#0000ff>/* initialize graphics, local variables */
/ `# H0 w3 O% b: G6 Z4 c( Uinitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P>, C, H6 B  T. v( i
<><FONT color=#0000ff>/* read result of initialization */
8 Y) \# |$ M' T8 R7 derrorcode = graphresult(); 7 u" R& `( e) e& x5 q$ i2 o5 P! h
if (errorcode != grOk) 6 r+ F5 N( K) Q6 b; b# K; B1 }  f. g. F
/* an error occurred */ : T$ D2 p4 b& ?
{ & }& q% `8 O% [
printf("Graphics error: %s\n",
5 {+ Z( b3 j7 L, i9 O) A4 g9 zgrapherrormsg(errorcode));
, I- }# ]4 G5 m. lprintf("ress any key to halt:"); 4 J/ K1 R. g5 i8 f( K
getch(); 3 ^- U/ j7 R) w- `7 B' U; I4 X
exit(1); 2 B! k6 r$ M4 r/ f/ L
/* terminate with an error code */ & ^9 s5 o: A$ R9 o
} </FONT></P>
& x1 s- j4 {# S3 [* S8 D<><FONT color=#0000ff>midx = getmaxx() / 2; & ~& p' x4 p2 p6 l$ s: M7 |
midy = getmaxy() / 2; # k5 m  m% }# ?2 H. F! [6 z* w
setcolor(getmaxcolor()); </FONT></P>7 d1 X. Q& _: {* d& I
<><FONT color=#0000ff>/* draw ellipse */ " h0 E  Z8 q+ H) V( k( a
ellipse(midx, midy, stangle, endangle, - e0 ]$ c: y7 M% H6 C( C
xradius, yradius); </FONT></P>6 T7 [/ [6 _; y4 R3 R* r
<><FONT color=#0000ff>/* clean up */
3 ^4 x0 f+ ], G5 e7 V$ k. e1 c' Kgetch(); $ a9 J- g  j8 P4 w# I& r! }, N
closegraph();
: F2 h4 V" x' x! Hreturn 0;
! q% Z1 H& W# P} </FONT>3 c4 d+ r0 `8 N, C2 J

: S( E9 t, w& I$ N/ C8 g</P>% [5 K: z6 j$ N1 ]
<><FONT color=#ff0000>函数名: enable </FONT>
1 \9 M8 l8 A1 U2 _' g- N功 能: 开放硬件中断
7 w9 k% A5 [2 |* O3 O, I+ W用 法: void enable(void); . c+ R8 h. H! M. ?3 t/ W
程序例: </P>
" c1 ?( U) ?8 ^$ Q<><FONT color=#0000ff>/* ** NOTE:   L) Y8 i7 g$ f7 y3 E8 K
This is an interrupt service routine. You can NOT compile this program
  [1 L% D1 U. }+ y: qwith Test Stack Overflow turned on and get an executable file which will
: Y5 \$ G) |. c' ^+ c' `0 boperate correctly.
8 H. v4 `4 ^& E*/ </FONT></P>
- V; I, j  P1 A4 ~8 d8 z) c0 U& S<><FONT color=#0000ff>#include <STDIO.H>' G+ h) q; i' p
#include <DOS.H>: i9 P' n% ]' s, Q8 M: ?/ m
#include <CONIO.H></FONT></P>
3 M/ K) J3 v' M' Q1 C+ t& H5 c<><FONT color=#0000ff>/* The clock tick interrupt */ 4 L; ^3 n# }  X# R, P
#define INTR 0X1C </FONT></P>
. O1 I' ?  a. ]7 \<><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P>$ i& I# ]: o/ c0 ?: {8 c
<><FONT color=#0000ff>int count=0; </FONT></P>
& D& N6 C, N' Y) }& B. L# j  i<><FONT color=#0000ff>void interrupt handler(void) ( e# i6 z) `& T0 c
{ % Q6 C# w: e/ L% j5 J
/* 5 s: U4 ^" T1 r& O; U+ V
disable interrupts during the handling of the interrupt
9 h3 [0 G, R! _! h*/
' k; \6 F4 P3 X$ v+ P4 [disable(); * h* n; v" w% K( h; I
/* increase the global counter */
7 r  o; f% E+ `5 _( E4 J- pcount++;
  ]6 }- W% _/ {7 y' l/* - G4 i' ~' M5 b8 ^6 E2 `' _
re enable interrupts at the end of the handler
2 \& G- X& \6 U( h+ O  B*/ 2 H. K4 }8 ^3 v8 y: C
enable();
# g4 l2 `( v& ]+ n+ |& |/* call the old routine */
1 T2 w2 [" \6 _: k- @$ doldhandler(); ( c' Q3 u3 Q: J/ D" ~) e* A( s
} </FONT></P>) h9 K' Z. G& l
<><FONT color=#0000ff>int main(void) 9 Y9 u7 v( I" q3 g7 w1 c
{
$ j% J& g# d. Y* s2 }- ~+ u/* save the old interrupt vector */ 7 h9 e; G, i5 e3 \3 S8 E
oldhandler = getvect(INTR); </FONT></P>% A& q0 Y9 O/ y. s9 q4 c; g
<><FONT color=#0000ff>/* install the new interrupt handler */ 5 u9 }1 I% S* h6 H% a( d9 O( L
setvect(INTR, handler); </FONT></P>2 R: `, }! O8 y
<><FONT color=#0000ff>/* loop until the counter exceeds 20 */
2 n2 o( m3 }! G* @! H/ w; e2 iwhile (count &lt; 20)
7 s3 w9 R6 l& A# Yprintf("count is %d\n",count); </FONT></P>+ h5 W0 c; W" t: B" g
<><FONT color=#0000ff>/* reset the old interrupt handler */
0 {$ q# ?: u  S, {! @setvect(INTR, oldhandler); </FONT></P>
! G4 f4 z% h" p5 i3 ?, o<><FONT color=#0000ff>return 0; . t% ^/ ^% p' K
} </FONT>
1 Y4 @  ~& m4 i% _
2 `/ L0 K1 V/ m3 g; B4 g$ ~( y2 \</P>2 n" H6 j4 `" E' I: U
<><FONT color=#ff0000>函数名: eof </FONT># G% P* g1 `5 v
功 能: 检测文件结束 % z3 T# q2 H, X' T1 {
用 法: int eof(int *handle); ( {4 |5 U& B( x
程序例: </P>
- K1 x! v' }: v4 g1 ]( s9 c<P><FONT color=#0000ff>#include <SYS\STAT.H># |% b3 O- Q* \/ \9 h) o
#include <STRING.H>) ]6 D6 A2 |1 N* x; _4 X3 ~
#include <STDIO.H>% i7 r9 h3 G3 G; Q" v
#include <FCNTL.H>
! n+ [" p7 f) N#include <IO.H></FONT></P>% ~( d% c, V4 k7 ~
<P><FONT color=#0000ff>int main(void)
( {( D, d" F' t, p# Q0 A* g0 `{ 1 s) W' @) g4 X
int handle;
/ i( C4 z) }+ Y% @, t/ h3 pchar msg[] = "This is a test"; + C, R( a' K( k! p
char ch; </FONT></P>  _: t( x* N# H' A' B9 [' s/ \9 q
<P><FONT color=#0000ff>/* create a file */
! ]! k% g5 v  Bhandle = open("DUMMY.FIL",
" D8 B- P3 H) f6 _0 \O_CREAT | O_RDWR,
7 G! e, Z2 d; Z3 d3 ?0 eS_IREAD | S_IWRITE); </FONT></P>
0 w+ D3 G+ `' H; `( ~. k<P><FONT color=#0000ff>/* write some data to the file */ 1 b8 Y) C  n! D
write(handle, msg, strlen(msg)); </FONT></P>4 N3 D. c6 U# {* `; B  b
<P><FONT color=#0000ff>/* seek to the beginning of the file */
: k: y# W% Y. S) }  [! ^1 Jlseek(handle, 0L, SEEK_SET); </FONT></P>0 g: Q6 j6 G; j
<P><FONT color=#0000ff>/* 3 e; M, f9 g2 M, z% R6 q
reads chars from the file until hit EOF
7 A4 R9 q" L- B; X/ o, `*/ . d/ u+ }( A' n% G9 z* R6 o' [
do
0 T9 _0 @. ^. X, L2 f9 W7 N  f  g{
. [+ N9 R7 j' @" g* B' tread(handle, &amp;ch, 1); # H1 x/ h- ]  e5 ~0 B3 G
printf("%c", ch);
4 i" B+ B5 q) t6 h' ~} while (!eof(handle)); </FONT></P>0 V# Q" K+ B' Z+ b4 T9 ~
<P><FONT color=#0000ff>close(handle);
& q$ n( h8 v. I, Y6 Hreturn 0; / ~% y8 _( K4 o% C0 e8 Z. P! [
}
; x* Z: H  y. M6 c' W+ j. o) y</FONT>
& ]; I& ]  O7 d" J) T7 W</P>
$ T+ Q3 T' ]& N# \<P><FONT color=#ff0000>函数名: exec... </FONT>. G) |5 L4 k9 f, ~
功 能: 装入并运行其它程序的函数 ; Z- k; q! ^& U6 [
用 法: int execl(char *pathname, char *arg0, arg1, ..., argn, NULL); # X4 |7 v5 C! O* R5 U+ B
int execle(char *pathname, char *arg0, arg1, ..., argn, NULL, 3 M* o; I. o+ ?  [: x4 E5 g6 i& b. m  i( Y
char *envp[]);
, ]8 f8 Q$ n' ]int execlp(char *pathname, char *arg0, arg1, .., NULL);   t+ r. Z; D/ O' e2 N0 v' ^
int execple(char *pathname, char *arg0, arg1, ..., NULL,
$ a4 x. @! w2 M- hchar *envp[]); ! s# ~/ P# ~6 s
int execv(char *pathname, char *argv[]); ! Z/ H& ^' A& J5 B
int execve(char *pathname, char *argv[], char *envp[]); 8 q! Y9 g( s7 i7 n: L' [
int execvp(char *pathname, char *argv[]);
3 R% }- A0 {& T% H& Mint execvpe(char *pathname, char *argv[], char *envp[]); " [2 g( C) j! T/ f, `  k% ]3 q1 _1 D! `
程序例: </P>; L( P8 e9 ^- n; p% h" x7 Q
<P><FONT color=#0000ff>/* execv example */
+ Q2 S8 }5 Y5 G, Q2 f3 L7 a#include <PROCESS.H>8 @6 q& A" P9 D" g) W6 o
#include <STDIO.H>
+ d9 E" V: O9 m" H#include <ERRNO.H></FONT></P>  d; c7 {& x# V1 I/ `* D$ G
<P><FONT color=#0000ff>void main(int argc, char *argv[]) ) ^; g9 y) \9 j' ~
{ 0 }, H3 {4 \1 R- ~5 I+ o
int i; </FONT></P>/ c* e7 b% o  N: z. ]) P1 \: M
<P><FONT color=#0000ff>printf("Command line arguments:\n"); 3 q) r' T& @. c  W: Z, J
for (i=0; i<ARGC; <br i++)> printf("[%2d] : %s\n", i, argv); </FONT></P>
$ s. a4 f  @7 ]' [( F" V# q<P><FONT color=#0000ff>printf("About to exec child with arg1 arg2 ...\n");
3 }2 _" l& o7 L' Texecv("CHILD.EXE", argv); </FONT></P>2 S, Q& L7 l1 X2 j
<P><FONT color=#0000ff>perror("exec error"); </FONT></P>
% Y9 f  i5 {8 b' M& d' r<P><FONT color=#0000ff>exit(1);
4 P( P; o& v  P* K  T- D}   S9 S( }2 ]8 \4 F; x& Y+ a
</FONT>
$ O: O1 t8 j0 q</P>
; q* W  Q; g  |4 v<P><FONT color=#ff0000>函数名: exit </FONT>& ~0 B! Z2 C2 |  J
功 能: 终止程序 3 F; ?1 Z1 M1 `; e! y" t
用 法: void exit(int status);
5 b' s  Q- e) d: {+ X  Y程序例: </P>
, ^9 a% s6 X: O, O" C1 o4 w4 r<P><FONT color=#0000ff>#include <STDLIB.H>
3 p0 ?  ^) v# {& a#include <CONIO.H>- M# q( s+ g' Q7 g2 ^* @6 E" ?+ m
#include <STDIO.H></FONT></P>
% k4 `" l$ G1 z$ W<P><FONT color=#0000ff>int main(void) 9 J! u( S% n; U. K' Z% j
{ ( y) z1 z; x# M5 f9 H
int status; </FONT></P>! u, z# o& L5 X: D$ {' @% p4 ]2 ^
<P><FONT color=#0000ff>printf("Enter either 1 or 2\n"); % z" Q  t' ~9 h- ?- }3 Q2 ]7 h0 ?
status = getch(); ; T0 I4 C) G" s( w- r
/* Sets DOS errorlevel */ ' L4 q1 r/ d8 t. K8 W8 C# H6 ]
exit(status - '0'); </FONT></P>
, m/ h$ E2 O2 ]6 X<P><FONT color=#0000ff>/* Note: this line is never reached */ $ _- j2 a. S: E- p
return 0;
5 s6 Y+ t  g4 ?1 E! E( l} ! }9 q0 ], f: m, w
</FONT>
5 y* \; b' i/ G% Q2 k</P>
; n( ~" s& S" ~5 z! p1 N6 r+ D<P><FONT color=#ff0000>函数名: exp </FONT>
8 {4 H6 e9 ^+ G: m& v  Q; X功 能: 指数函数
% I8 L! Y5 y! C# a! t* g, O- G用 法: double exp(double x);
# U/ h; u. K8 b6 w" ]& G" m$ \, u程序例: </P>
( v: f# C- q, b5 O2 e6 g: Y<P><FONT color=#0000ff>#include <STDIO.H>
/ k8 \8 p4 }" @6 ]9 N#include <MATH.H></FONT></P>. ^& q: @9 m: E& t
<P><FONT color=#0000ff>int main(void)
: Z$ |" g& k  m' K/ X$ o{ + g7 N/ o- ]7 |# k
double result;
3 y5 e; x5 n* w" w) D; ydouble x = 4.0; </FONT></P>" _+ W9 T/ s) z& C5 m. O5 r
<P><FONT color=#0000ff>result = exp(x);
, B" l8 N5 S  y0 ?4 t- q. `, K0 Aprintf("'e' raised to the power \ 2 f6 k; c/ \$ e( F
of %lf (e ^ %lf) = %lf\n", 0 n2 g/ K- E  Z- ~4 h& k7 Y$ }% `8 c% h
x, x, result); </FONT></P>
3 P) [6 a3 O: k+ Y3 v<P><FONT color=#0000ff>return 0; 3 f0 [1 U+ M' g- r5 x- P% s
}$ \+ W9 `( h. M0 |) \
</FONT></P>
zan
转播转播0 分享淘帖0 分享分享0 收藏收藏0 支持支持0 反对反对0 微信微信
韩冰        

823

主题

3

听众

4048

积分

我的地盘我做主

该用户从未签到

发帖功臣 元老勋章

< align=center><FONT color=#0000ff size=3><B><FONT color=#cc0000>函数大全(d开头)</FONT></B></FONT>
% x8 N6 c7 I7 X, r+ ?7 F</P>
8 ]2 t9 j1 D0 D+ W, M+ ]<p><><FONT color=#ff0000>函数名: delay </FONT>+ M7 s0 C8 Y* d' g- d3 F; u$ E' i
功 能: 将程序的执行暂停一段时间(毫秒)
! m7 W* Z- F! a5 I( b  K, v9 d用 法: void delay(unsigned milliseconds); $ T" S& t6 n/ v
程序例:
$ r; b/ W6 c* r8 A<FONT color=#0000ff>/* Emits a 440-Hz tone for 500 milliseconds */
9 }1 R% U, r6 ]$ B#include <DOS.H></FONT></P><><FONT color=#0000ff>int main(void) % ]) m3 s6 q# m7 l
{ ( }5 ?3 e' Q2 ~; b
sound(440);
; S$ g6 s& R4 U% K* l0 Z' tdelay(500); . F" H5 a$ {; q6 |! M/ j4 D% h5 _
nosound(); </FONT></P><><FONT color=#0000ff>return 0;   D) F" n( M, q5 W! I) u; w
} : W% O& O- E2 e- R. K

, Q: H3 P5 ]  S4 Z$ a- a& C0 u! @</FONT></P><><FONT color=#ff0000>函数名: delline </FONT>" S4 G1 c6 Z# S3 S
功 能: 在文本窗口中删去一行
% u: W  x/ @" `* e: f用 法: void delline(void);
* p& ~2 }8 p0 B4 }9 ?程序例: </P><><FONT color=#0000ff>#include <CONIO.H></FONT></P><><FONT color=#0000ff>int main(void)
! J, A& ]) V; `{ / L/ [1 p& I+ ~, f) h
clrscr(); * h* ?  E6 h7 i9 Y
cprintf("The function DELLINE deletes \ $ G7 B& r% M9 |- D3 {9 e
the line containing the\r\n");
* Q7 q- Q& T1 F! ]$ O2 wcprintf("cursor and moves all lines \
" }# Y$ T2 t* v2 r% l# [below it one line up.\r\n");
# N2 |% ]: I* `6 Z9 xcprintf("DELLINE operates within the \
6 o4 a* S& h7 Q" N, W/ \2 Tcurrently active text\r\n"); / }: q; x' P  P! q( Z& Z5 I$ F
cprintf("window. Press any key to \
* v' Z3 f/ u; Y$ _, j$ ncontinue . . ."); ! t: ?8 |. l, ?
gotoxy(1,2); /* Move the cursor to the
3 X) J, ~, H9 ^. O! B+ K5 msecond line and first column */ # _* Z9 I+ z7 G  A/ r
getch(); </FONT></P><><FONT color=#0000ff>delline(); - |- ^  ]( n+ a& ]0 {7 U
getch(); </FONT></P><><FONT color=#0000ff>return 0;
& k4 V5 `4 Q( r7 s9 d} </FONT>0 b" z4 w* M  U0 o
</P><><FONT color=#ff0000>函数名: detectgraph </FONT>3 \& S: j5 _# V1 U  I* J+ V
功 能: 通过检测硬件确定图形驱动程序和模式
6 u+ t2 h  ?$ ]( h7 B/ C用 法: void far detectgraph(int far *graphdriver, int far *graphmode);
' r' o* q& c+ ^. K' W( U! [5 j程序例: </P><><FONT color=#0000ff>#include <GRAPHICS.H>' {6 u3 n+ ~9 t  _( S/ U( b0 _
#include <STDLIB.H>3 ~" s8 y# C2 v# O7 w5 `* G' T5 q
#include <STDIO.H>
1 \: G- t/ F. o7 C$ A- l3 c; }, b#include <CONIO.H></FONT></P><><FONT color=#0000ff>/* names of the various cards supported */ & T/ p1 R! T6 D* k* [+ |& h' x
char *dname[] = { "requests detection",
& X( E& o2 k+ v" o) \"a CGA",
$ ?5 V4 s7 L; w3 A  O  D+ a"an MCGA", 6 d9 l  F1 r( a# V+ ]- X2 _0 y
"an EGA", 6 Y2 }' P$ r: `% V2 e9 v7 `* P
"a 64K EGA",
) d" k! n# t( J) O8 N"a monochrome EGA", 2 H% O9 j% @) t& x' {
"an IBM 8514",
! t& A% v4 ?2 r; m/ I3 H9 W# L"a Hercules monochrome",
" J7 y% U, n3 c( F"an AT&amp;T 6300 PC", # f7 s4 d1 [( V6 F! @
"a VGA",
2 O" d3 {9 P1 I' r' }6 p"an IBM 3270 PC" % u7 Z; x- J& j) G
}; </FONT></P><><FONT color=#0000ff>int main(void)
! `. v  n3 E  u, {' u{ " l4 ~0 Q% X% B7 Y. D9 S
/* returns detected hardware info. */ % b/ _, Z0 [/ _' f0 X9 ^
int gdriver, gmode, errorcode; </FONT></P><><FONT color=#0000ff>/* detect graphics hardware available */
6 m; E6 Z9 ?4 M0 \$ S% c$ odetectgraph(&amp;gdriver, &amp;gmode); </FONT></P><><FONT color=#0000ff>/* read result of detectgraph call */ ) d8 t0 h& M4 ^& A; v0 P) w) \' {
errorcode = graphresult();
/ D$ @8 V2 \) ~. K1 K& h0 @) U- A+ q+ Iif (errorcode != grOk) /* an error $ r, {8 s3 _) [; A! a
occurred */
) `: I4 R8 S( A8 l% n1 _0 K{ 0 ]* |& a6 X$ W. i6 ^4 X+ e7 p
printf("Graphics error: %s\n", \
" ]9 L3 k( F, jgrapherrormsg(errorcode)); ( z7 ?8 ^. K9 J' ?# X+ [- C9 x1 N
printf("ress any key to halt:"); " j* {1 Q$ o7 W0 M3 e2 U
getch();
, a; Q3 s* p; jexit(1); /* terminate with an error
* j9 W* R4 l' ]5 n/ L0 {+ scode */ : @1 b: o. k2 \; M1 B' p( B
} </FONT></P><><FONT color=#0000ff>/* display the information detected */ . U2 n) H6 z4 F
clrscr();
8 o4 g, u+ Y% w7 qprintf("You have %s video display \
6 T  R+ v/ _1 ]  I5 i* w6 mcard.\n", dname[gdriver]);
6 I, _( a/ K' u; o3 e( mprintf("ress any key to halt:"); 3 J4 o" m6 a, S0 o# P1 \+ X' o
getch();
# Y* _3 }' [' J2 ?1 \1 jreturn 0; $ k3 l- F9 R6 Q1 ?1 \
} </FONT>
( c  `. C8 F0 p
1 j8 R$ E" f6 M# R! i8 b2 \. j6 G# ?$ a0 m- _( P6 h
</P><><FONT color=#ff0000>函数名: difftime </FONT>3 l3 J: F7 k4 N: y* r7 x
功 能: 计算两个时刻之间的时间差
$ N- i- v& n" n  {2 r用 法: double difftime(time_t time2, time_t time1); . E7 i# Q) q5 a6 j8 d1 U# Y
程序例: </P><><FONT color=#0000ff>#include <TIME.H>
9 F( h6 z$ Y# [% \  c) o1 H#include <STDIO.H>
8 M; ]) B9 p0 y+ D& E#include <DOS.H>
4 M1 b5 a6 U, J& K/ n7 t#include <CONIO.H></FONT></P><><FONT color=#0000ff>int main(void)
9 |  ~; I' X/ B  }$ g{ 1 F4 g: s/ U1 R: A% k( X% @1 [
time_t first, second; </FONT></P><><FONT color=#0000ff>clrscr();
% Q7 |4 g7 P% Q+ m! mfirst = time(NULL); /* Gets system
; m7 D( |4 `0 P2 \- H5 |3 |1 Ttime */
5 b& |, J, r4 h1 a9 l: @/ E' Kdelay(2000); /* Waits 2 secs */
' T0 A- u. N0 ]0 ]: Y# W5 Esecond = time(NULL); /* Gets system time ' ?, G) g3 O- c3 C3 Z$ D& o  x
again */ </FONT></P><><FONT color=#0000ff>printf("The difference is: %f \ ) A& j5 ^- C7 X
seconds\n",difftime(second,first));
: v  I/ D; a% l& F9 P* U' F1 Xgetch(); </FONT></P><><FONT color=#0000ff>return 0; 8 Z, f" Y" [8 g1 o6 P0 E' W
}
. ?. h) J$ T# e9 L0 H</FONT>
: S) v5 g( Q9 h5 F: n6 |3 v</P><><FONT color=#ff0000>函数名: disable </FONT># o1 a. J0 o9 I; W, w+ B! {
功 能: 屏蔽中断 1 _; p. [4 z/ v, c! k
用 法: void disable(void);   w0 k# |2 m  L* H+ F; ~
程序例: </P><><FONT color=#0000ff>/***NOTE: This is an interrupt service
+ Z+ c2 T- v* u' H. }& Froutine. You cannot compile this program 3 @" w; }2 }5 U$ V3 }) `
with Test Stack Overflow turned on and ; M' a) f8 n  a5 k
get an executable file that operates
/ ~" D8 d3 D5 x( L" p6 e( n2 k9 i, {$ [correctly. */ </FONT></P><><FONT color=#0000ff>#include <STDIO.H>- T6 D8 P# g$ x! S
#include <DOS.H>
6 ^6 {  ^2 P7 y#include <CONIO.H></FONT></P><><FONT color=#0000ff>#define INTR 0X1C /* The clock tick $ w6 l- [" J$ C' E1 }* z8 ?; @1 q
interrupt */ </FONT></P><><FONT color=#0000ff>void interrupt ( *oldhandler)(void); </FONT></P><><FONT color=#0000ff>int count=0; </FONT></P><P><FONT color=#0000ff>void interrupt handler(void) ! y3 @6 G( g9 V
{
5 {% ~4 p- B  l3 |) K: X2 S* `/* disable interrupts during the handling of
0 h$ L. S/ k4 m1 g8 @8 |% @the interrupt */ . `, ~( j; o$ B+ d* M8 n% y9 B
disable();
: \0 O+ p5 p8 ~3 _8 M7 P1 M/* increase the global counter */
5 J4 B! n; p( R2 }; E& Q# Q1 ~2 Pcount++;
$ K* e3 O% L5 f8 s8 O' }3 c( o/* reenable interrupts at the end of the
7 |- N; Y6 N2 Hhandler */ , T! A* K( L$ G& u1 c) J
enable();
% t' O/ |0 ^1 q; Z/* call the old routine */ 0 _4 k" O) R$ K. W4 j+ p3 ?. Q: C6 c  w
oldhandler(); $ `! @3 a: Y5 l! }) I# u
} </FONT></P><P><FONT color=#0000ff>int main(void)
! a" \7 A' d8 s- K% j{ " ?- Q! ^) y  {3 f2 {8 [' a
/* save the old interrupt vector */
' V9 G+ i( r8 v+ {9 q" xoldhandler = getvect(INTR); </FONT></P><P><FONT color=#0000ff>/* install the new interrupt handler */ & _" L) w+ W2 U% {% `
setvect(INTR, handler); </FONT></P><P><FONT color=#0000ff>/* loop until the counter exceeds 20 */ , Z, e  P1 j* B; u
while (count &lt; 20) / M) A8 }$ a9 g6 {3 `
printf("count is %d\n",count); </FONT></P><P><FONT color=#0000ff>/* reset the old interrupt handler */ 4 M8 y" z7 V/ Q
setvect(INTR, oldhandler); </FONT></P><P><FONT color=#0000ff>return 0; * U0 Z; F7 D0 ~
} </FONT></P><P><FONT color=#ff0000>函数名: div </FONT>
$ N1 x2 v) A. c! [8 G功 能: 将两个整数相除, 返回商和余数
/ F- X* c7 X' Z  w$ _& T2 \- }用 法: div_t (int number, int denom); 5 P' v: _6 M: C& ^2 D1 D
程序例: </P><P>#<FONT color=#0000ff>include <STDLIB.H>
/ E- I/ w6 O- a& k#include <STDIO.H></FONT></P><P><FONT color=#0000ff>div_t x; </FONT></P><P><FONT color=#0000ff>int main(void)
$ P: Z/ F$ @1 w9 N- J& N! g& K' `  j+ I{ / O9 Q+ \; b1 W5 a2 n- Z
x = div(10,3); ; U. p* j  M3 |
printf("10 div 3 = %d remainder %d\n", x.quot, x.rem); </FONT></P><P><FONT color=#0000ff>return 0; 9 c! Q7 R2 ]6 V* V2 b5 I
}
$ u# V0 [) b9 A& I* j, a9 a</FONT>
+ G9 w$ ^- W! I, L6 H4 l7 n+ \& O( S</P><P><FONT color=#ff0000>函数名: dosexterr </FONT>. M: Z$ C% x) w  E$ _
功 能: 获取扩展DOS错误信息 # V, X8 y, a4 r; I$ @& y& B) e
用 法: int dosexterr(struct DOSERR *dblkp); . m5 U( K9 y+ k9 p6 ]
程序例: </P><P><FONT color=#0000ff>#include <STDIO.H>
- X$ o& l4 Z0 J# p8 d" j#include <DOS.H></FONT></P><P><FONT color=#0000ff>int main(void)
6 R% h4 j+ G! g& ?: [7 C{ ! w" v. t1 m/ j5 u& ~; S9 Q
FILE *fp;
3 k# y( e4 o# D5 k* |% _! lstruct DOSERROR info; </FONT></P><P><FONT color=#0000ff>fp = fopen("perror.dat","r"); ) _6 g5 I- c2 f, ]
if (!fp) perror("Unable to open file for   D. P7 @6 e+ {
reading"); - _7 G7 M3 c/ o6 b4 g& d
dosexterr(&amp;info); </FONT></P><P><FONT color=#0000ff>printf("Extended DOS error \ * `3 _8 c) T# n# g
information:\n");
6 R1 e7 G8 g( x" X, qprintf(" Extended error: \
8 J+ K1 G% s$ F% J! \5 M%d\n",info.exterror); ! X# E. @  R7 }; A) R+ O
printf(" Class: \ $ g3 R4 n% o% @4 p
%x\n",info.class);
9 D! [, s6 P( O- ?- Zprintf(" Action: \ $ s! a2 a1 I0 v0 i  M
%x\n",info.action); ; M7 d8 U" b8 R9 Z) R
printf(" Error Locus: \ ! ]; J) S: F, s! Q
%x\n",info.locus); </FONT></P><P><FONT color=#0000ff>return 0; $ m% G0 y* S3 B( R6 S& [
} </FONT>
# T. C" V5 ]$ x# N0 [; G  j+ N# S7 W( x. I" N& u5 Q( R
</P><P><FONT color=#ff0000>函数名: dostounix </FONT>, q( T1 ?: V+ {7 T/ c* C
功 能: 转换日期和时间为UNIX时间格式
; n0 G, G$ o- M  ~* o% P, @, g用 法: long dostounix(struct date *dateptr, struct time *timeptr); # H/ y8 f2 t1 w4 `$ Q2 _
程序例: </P><P><FONT color=#0000ff>#include <TIME.H>
% D9 \7 [9 A! b+ `#include <STDDEF.H>9 m* N0 ?% U' a
#include <DOS.H>- j& t0 y* u- b, Q4 }* i7 F* X1 z# ?
#include <STDIO.H></FONT></P><P><FONT color=#0000ff>int main(void) 1 m0 q7 |$ q. h) j/ {  F5 q
{ % M$ q- J+ j- ]7 B7 ~6 K' n
time_t t; , m5 K! v+ c& x% ^8 K/ ^% k+ s
struct time d_time;
& ~( d& o5 y8 V, g/ w4 d3 Jstruct date d_date; + ], j" Q  C; ]7 o1 m
struct tm *local; </FONT></P><P><FONT color=#0000ff>getdate(&amp;d_date); " k# D9 _8 l% {, A6 ^; W+ F
gettime(&amp;d_time); </FONT></P><P><FONT color=#0000ff>t = dostounix(&amp;d_date, &amp;d_time);
! `1 e4 T0 V& q8 T( }% [$ A0 xlocal = localtime(&amp;t);
$ f. A4 E& B1 s% j8 Z8 Wprintf("Time and Date: %s\n", \ 3 X' C8 _7 I) Y  c( {4 m
asctime(local)); </FONT></P><P><FONT color=#0000ff>return 0;
' c- i7 ?, Y# i. a1 k4 H' z} </FONT>' b1 c2 C1 |0 E+ r3 X- q  J

* H% Z6 T' r& G! |9 U1 w</P><P><FONT color=#ff0000>函数名: drawpoly </FONT>7 j7 V) n1 R, _( q! P6 z( n
功 能: 画多边形
  ~3 s$ H' T- Y用 法: void far drawpoly(int numpoints, int far *polypoints);
& S5 @) O6 C  h, ?. _* k& X程序例: </P><P><FONT color=#0000ff>#include <GRAPHICS.H>" J5 F2 }- [* T$ n& M3 @4 \% b
#include <STDLIB.H>) Q5 M! g! a' x( ?" `5 A
#include <STDIO.H>
' {( z7 n2 L- U- t1 `. \#include <CONIO.H></FONT></P><P><FONT color=#0000ff>int main(void)
8 ]) L3 h) H3 e( L( m" u6 k. W' Z{ 7 ^, T( B: o0 O& B% g
/* request auto detection */
* q- l. H1 d: w; x5 L' `int gdriver = DETECT, gmode, errorcode;
2 P$ ~5 X! ]/ H6 T- T) s3 D& Hint maxx, maxy; </FONT></P><P><FONT color=#0000ff>/* our polygon array */
$ B, I3 Y  R6 t9 W2 `; zint poly[10]; </FONT></P><P><FONT color=#0000ff>/* initialize graphics and local # f  U/ n; Y( X% u. h8 n( G' b
variables */
4 B/ t# K( e4 O' F% Ninitgraph(&amp;gdriver, &amp;gmode, ""); </FONT></P><P><FONT color=#0000ff>/* read result of initialization */
+ j/ a; D: E! H0 Z1 Xerrorcode = graphresult();
# _( h- T1 t9 T7 h6 Zif (errorcode != grOk) + V( @) j: f5 k8 I* Y* p9 n
/* an error occurred */
% @% y9 o8 o- {% i{ 1 e; H/ }+ y1 r' a" A, `, I
printf("Graphics error: %s\n", \
, |3 P9 A$ l- ~7 m" Y. Sgrapherrormsg(errorcode));
4 C- y8 x# E7 S# R6 q9 n$ sprintf("Press any key to halt:");
. w; V' g  F- _) `! C! @2 r+ @getch(); & L' ~6 [+ X, {0 T& P) n
/* terminate with an error code */ 8 Z, K) G7 q% n' Y# t
exit(1);
# y; s# E# a+ P. p} </FONT></P><P><FONT color=#0000ff>maxx = getmaxx(); % X- b; s% I) C# K4 o1 [
maxy = getmaxy(); </FONT></P><P><FONT color=#0000ff>poly[0] = 20; /* 1st vertext */ 8 E. U% r/ J9 F" O
poly[1] = maxy / 2; </FONT></P><P><FONT color=#0000ff>poly[2] = maxx - 20; /* 2nd */ + Z+ S" U% U: E6 P" w4 Y6 j
poly[3] = 20; </FONT></P><P><FONT color=#0000ff>poly[4] = maxx - 50; /* 3rd */
) @& E! u' f6 m9 z( l% tpoly[5] = maxy - 20; </FONT></P><P><FONT color=#0000ff>poly[6] = maxx / 2; /* 4th */ : s; g1 H* _1 \* a! [/ P2 p
poly[7] = maxy / 2;
& L# R# O/ K, W/ S& Z& J. a; B/*
" a% w/ a: U2 @; e( ^3 hdrawpoly doesn't automatically close
! C3 c6 t; j2 x' l% d. J+ r1 Cthe polygon, so we close it.
  ], q. ^7 P6 E  v. t8 l*/ 9 z/ b: V" E0 J) y* G$ R1 D" A) u5 `' e
poly[8] = poly[0]; . S) C) x4 Z4 l+ l- \
poly[9] = poly[1]; </FONT></P><P><FONT color=#0000ff>/* draw the polygon */ + G. d- A2 N8 Y. N7 j% H6 [
drawpoly(5, poly); </FONT></P><P><FONT color=#0000ff>/* clean up */
* Z* s; o7 }1 D. h; Z* Q% V' xgetch();
/ j* |: U; Y+ L2 @" |closegraph();
; @" w6 {! [, W, T( d( }, P4 G3 jreturn 0;
! c1 |' b6 J5 B) ^0 ^} " p1 g# W3 X$ H
</FONT>
8 v0 q* f3 N/ f1 p2 E9 k</P><P><FONT color=#ff0000>函数名: dup </FONT>
% F- V+ e3 u; X6 D5 ]3 D功 能: 复制一个文件句柄 9 x* g4 q, m6 B# ~) D
用 法: int dup(int handle); & N" V3 x7 F6 {% i1 @0 H8 r
程序例: </P><P><FONT color=#0000ff>#include <STRING.H>4 g, b* y( I) t
#include <STDIO.H>
  X) V; L) ~  p! g0 D: o) w#include <CONIO.H>
# N+ p" J3 t) _3 m$ l$ G+ M#include <IO.H></FONT></P><P><FONT color=#0000ff>void flush(FILE *stream); </FONT></P><P><FONT color=#0000ff>int main(void) 9 h3 ^8 e2 A: ?9 k8 a; Q, Q3 k
{ " n! U3 F  `8 T; q" o* j  C
FILE *fp; ( z3 R7 y8 C  F# R) S3 I( Z
char msg[] = "This is a test"; </FONT></P><P><FONT color=#0000ff>/* create a file */
) l$ U2 s) ^5 z7 W% `1 l+ wfp = fopen("DUMMY.FIL", "w"); </FONT></P><P><FONT color=#0000ff>/* write some data to the file */
, x( J7 }% ~) Mfwrite(msg, strlen(msg), 1, fp); </FONT></P><P><FONT color=#0000ff>clrscr();
* k" H* s0 |: Q# H. U* Tprintf("Press any key to flush \
3 e" @6 b5 G" F: f  g% V8 G- P+ QDUMMY.FIL:"); # T( v4 z7 w6 M
getch(); </FONT></P><P><FONT color=#0000ff>/* flush the data to DUMMY.FIL without 0 {8 y7 @# U* F! ?+ P# ~, R' J' @
closing it */ 4 ]% l  o1 A, K, P! v6 z! N
flush(fp); </FONT></P><P><FONT color=#0000ff>printf("\nFile was flushed, Press any \
. Q8 B& J/ k5 u, b0 t  O. y8 Kkey to quit:"); , M" z  |0 A( J7 h( H! o
getch();
. {* \- O0 X7 ]) Ereturn 0; $ g8 k/ S) R/ w' L: K
} </FONT></P><P><FONT color=#0000ff>void flush(FILE *stream)
! B3 _, t* B# f/ s3 n+ Q{ . I4 Q; @+ |9 V  A7 Z
int duphandle; </FONT></P><P><FONT color=#0000ff>/* flush TC's internal buffer */
* A" H0 b# D6 \# ]fflush(stream); </FONT></P><P><FONT color=#0000ff>/* make a duplicate file handle */
, M' W* f- N  m# K! Oduphandle = dup(fileno(stream)); </FONT></P><P><FONT color=#0000ff>/* close the duplicate handle to flush the
) o+ e2 w8 d% z: P5 C2 jDOS buffer */ 9 j! d; _* q6 ]/ S0 [  f
close(duphandle); 8 ?- c& o! |4 T$ }- n2 c* L
} 4 L1 R( U5 u$ ]& O& ^
+ W' s1 d* a+ _( V8 M- P
</FONT></P><P><FONT color=#ff0000>函数名: dup2 </FONT>
% L- }. [( p* p$ e8 n' ?' Z$ l( g功 能: 复制文件句柄
. ?1 D4 m1 [0 k用 法: int dup2(int oldhandle, int newhandle); 4 d' C8 ?+ ~, @+ |2 M& f- u0 T6 Q9 L
程序例: </P><P><FONT color=#0000ff>#include <SYS\STAT.H>, T$ I, t/ T# {" f, N; @
#include <STRING.H>
! F2 h2 B& _3 Y; j+ o# {#include <FCNTL.H>
: g6 K1 D) K7 F#include <IO.H></FONT></P><P><FONT color=#0000ff>int main(void)
: J2 U0 z+ v: ]  V{
- X, i* V1 d4 F# S8 l5 ?4 Q" b) k7 B# }#define STDOUT 1 </FONT></P><P><FONT color=#0000ff>int nul, oldstdout; " |3 n' N2 ?6 t5 a
char msg[] = "This is a test"; </FONT></P><P><FONT color=#0000ff>/* create a file */ 0 k8 d1 ^" w' E$ F
nul = open("DUMMY.FIL", O_CREAT | O_RDWR,
' l* M/ c# |# O+ f3 c( d. _( {. zS_IREAD | S_IWRITE); </FONT></P><P><FONT color=#0000ff>/* create a duplicate handle for standard
' i, _) O# v9 ?$ H+ xoutput */
/ W! E  A* k5 m9 Z! W0 Roldstdout = dup(STDOUT); ' z, }' N: [9 G: ~4 r
/*
; }6 T3 \$ x" _8 e  t& G" _$ ]redirect standard output to DUMMY.FIL ' x) i3 q/ L3 A: T: M, ?6 E
by duplicating the file handle onto the ) b+ j9 P! F; D3 B5 n# @5 u
file handle for standard output.   |2 s! D2 F/ Y) N# A! V' [
*/
+ |, P$ S3 y4 d% o  H( `dup2(nul, STDOUT); </FONT></P><P><FONT color=#0000ff>/* close the handle for DUMMY.FIL */
& f' J# r9 p+ o2 A4 hclose(nul); </FONT></P><P><FONT color=#0000ff>/* will be redirected into DUMMY.FIL */
% {; {/ ^+ t2 g( Dwrite(STDOUT, msg, strlen(msg)); </FONT></P><P><FONT color=#0000ff>/* restore original standard output ) @4 c/ V$ O8 b/ ?
handle */ " `( W. u' E( k- o0 C
dup2(oldstdout, STDOUT); </FONT></P><P><FONT color=#0000ff>/* close duplicate handle for STDOUT */
8 w( s0 X4 ?6 z, tclose(oldstdout); </FONT></P><P><FONT color=#0000ff>return 0; & ~/ x7 R* E& }/ O% _9 k' C9 p
} # ~& g; L1 f9 T" p: U# n% m- @
</FONT></P>
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册地址

qq
收缩
  • 电话咨询

  • 04714969085
fastpost

关于我们| 联系我们| 诚征英才| 对外合作| 产品服务| QQ

手机版|Archiver| |繁體中文 手机客户端  

蒙公网安备 15010502000194号

Powered by Discuz! X2.5   © 2001-2013 数学建模网-数学中国 ( 蒙ICP备14002410号-3 蒙BBS备-0002号 )     论坛法律顾问:王兆丰

GMT+8, 2026-10-24 08:11 , Processed in 1.254696 second(s), 56 queries .

回顶部