📄 fe.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=gb_2312-80">
<meta name="Author" content="wdg">
<meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
<title>网上学堂 --> C语言编程宝典之一 -->函数名: e</title>
</head>
<body>
<div align="center"><center>
<table border="1" cellpadding="4" width="640"
bordercolordark="#FFFFFF" bordercolorlight="#FFFFFF">
<tr>
<td bgcolor="#FFE6B0" bordercolor="#8080FF" class="p9"><font
color="#BB0000">导航条:--></font> <a
href="../../index.html">网上学堂</a> --> <a
href="../tcindex.htm"><font face="宋体">C</font>语言编程宝典之一</a>
-->函数名: e</td>
</tr>
<tr>
<td bordercolor="#8080FF" class="p9">函数名: ecvt <br>
功 能: 把一个浮点数转换为字符串 <br>
用 法: char ecvt(double value, int ndigit, int
*decpt, int *sign); <br>
程序例: <p>#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
char *string; <br>
double value; <br>
int dec, sign; <br>
int ndig = 10; </p>
<p> clrscr(); <br>
value = 9.876; <br>
string = ecvt(value, ndig, &dec,
&sign); <br>
printf("string = %s
dec = %d \ <br>
sign = %d\n", string, dec, sign); </p>
<p> value = -123.45; <br>
ndig= 15; <br>
string =
ecvt(value,ndig,&dec,&sign); <br>
printf("string = %s dec = %d sign =
%d\n", <br>
string, dec, sign); <br>
</p>
<p> value = 0.6789e5; /* scientific <br>
notation */ <br>
ndig = 5; <br>
string =
ecvt(value,ndig,&dec,&sign); <br>
printf("string = %s
dec = %d\ <br>
sign = %d\n", string, dec, sign); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: ellipse <br>
功 能: 画一椭圆 <br>
用 法: void far ellipse(int x, int y, int
stangle, int endangle, <br>
int xradius, int yradius); <br>
程序例: </p>
<p>#include <graphics.h> <br>
#include <stdlib.h> <br>
#include <stdio.h> <br>
#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
/* request auto detection */ <br>
int gdriver = DETECT, gmode, errorcode; <br>
int midx, midy; <br>
int stangle = 0, endangle = 360; <br>
int xradius = 100, yradius = 50; </p>
<p> /* initialize graphics, local variables
*/ <br>
initgraph(&gdriver, &gmode,
""); </p>
<p> /* read result of initialization */ <br>
errorcode = graphresult(); <br>
if (errorcode != grOk) <br>
/* an error occurred */ <br>
{ <br>
printf("Graphics
error: %s\n", <br>
grapherrormsg(errorcode));
<br>
printf("Press any key
to halt:"); <br>
getch(); <br>
exit(1); <br>
/* terminate with an error code */ <br>
} </p>
<p> midx = getmaxx() / 2; <br>
midy = getmaxy() / 2; <br>
setcolor(getmaxcolor()); </p>
<p> /* draw ellipse */ <br>
ellipse(midx, midy, stangle, endangle, <br>
xradius, yradius); </p>
<p> /* clean up */ <br>
getch(); <br>
closegraph(); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: enable <br>
功 能: 开放硬件中断 <br>
用 法: void enable(void); <br>
程序例: </p>
<p>/* ** NOTE: <br>
This is an interrupt service routine. You can NOT compile
this program <br>
with Test Stack Overflow turned on and get an executable
file which will <br>
operate correctly. <br>
*/ </p>
<p>#include <stdio.h> <br>
#include <dos.h> <br>
#include <conio.h> </p>
<p>/* The clock tick interrupt */ <br>
#define INTR 0X1C </p>
<p>void interrupt ( *oldhandler)(void); </p>
<p>int count=0; </p>
<p>void interrupt handler(void) <br>
{ <br>
/* <br>
disable interrupts during the handling of
the interrupt <br>
*/ <br>
disable(); <br>
/* increase the global counter */ <br>
count++; <br>
/* <br>
re enable interrupts at the end of the
handler <br>
*/ <br>
enable(); <br>
/* call the old routine */ <br>
oldhandler(); <br>
} </p>
<p>int main(void) <br>
{ <br>
/* save the old interrupt vector */ <br>
oldhandler = getvect(INTR); </p>
<p>/* install the new interrupt handler */ <br>
setvect(INTR, handler); </p>
<p>/* loop until the counter exceeds 20 */ <br>
while (count < 20) <br>
printf("count is
%d\n",count); </p>
<p>/* reset the old interrupt handler */ <br>
setvect(INTR, oldhandler); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: eof <br>
功 能: 检测文件结束 <br>
用 法: int eof(int *handle); <br>
程序例: </p>
<p>#include <sys\stat.h> <br>
#include <string.h> <br>
#include <stdio.h> <br>
#include <fcntl.h> <br>
#include <io.h> </p>
<p>int main(void) <br>
{ <br>
int handle; <br>
char msg[] = "This is a test"; <br>
char ch; </p>
<p> /* create a file */ <br>
handle = open("DUMMY.FIL", <br>
O_CREAT | O_RDWR, <br>
S_IREAD | S_IWRITE); </p>
<p> /* write some data to the file */ <br>
write(handle, msg, strlen(msg)); </p>
<p> /* seek to the beginning of the file */ <br>
lseek(handle, 0L, SEEK_SET); </p>
<p> /* <br>
reads chars from the file
until hit EOF <br>
*/ <br>
do <br>
{ <br>
read(handle, &ch, 1); <br>
printf("%c",
ch); <br>
} while (!eof(handle)); </p>
<p> close(handle); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: exec... <br>
功 能: 装入并运行其它程序的函数 <br>
用 法: int execl(char *pathname, char *arg0,
arg1, ..., argn, NULL); <br>
int execle(char *pathname, char *arg0, arg1, ...,
argn, NULL, <br>
char *envp[]); <br>
int execlp(char *pathname, char *arg0, arg1, ..,
NULL); <br>
int execple(char *pathname, char *arg0, arg1, ...,
NULL, <br>
char *envp[]); <br>
int execv(char *pathname, char *argv[]); <br>
int execve(char *pathname, char *argv[], char
*envp[]); <br>
int execvp(char *pathname, char *argv[]); <br>
int execvpe(char *pathname, char *argv[], char
*envp[]); <br>
程序例: </p>
<p>/* execv example */ <br>
#include <process.h> <br>
#include <stdio.h> <br>
#include <errno.h> </p>
<p>void main(int argc, char *argv[]) <br>
{ <br>
int i; </p>
<p> printf("Command line
arguments:\n"); <br>
for (i=0; i<argc; i++) <br>
printf("[%2d] :
%s\n", i, argv[i]); </p>
<p> printf("About to exec child with
arg1 arg2 ...\n"); <br>
execv("CHILD.EXE", argv); </p>
<p> perror("exec error"); </p>
<p> exit(1); <br>
} <br>
<br>
</p>
<p>函数名: exit <br>
功 能: 终止程序 <br>
用 法: void exit(int status); <br>
程序例: </p>
<p>#include <stdlib.h> <br>
#include <conio.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
int status; </p>
<p> printf("Enter either 1 or
2\n"); <br>
status = getch(); <br>
/* Sets DOS errorlevel */ <br>
exit(status - '0'); </p>
<p>/* Note: this line is never reached */ <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: exp <br>
功 能: 指数函数 <br>
用 法: double exp(double x); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <math.h> </p>
<p>int main(void) <br>
{ <br>
double result; <br>
double x = 4.0; </p>
<p> result = exp(x); <br>
printf("'e' raised to the power \ <br>
of %lf (e ^ %lf) = %lf\n", <br>
x, x, result); </p>
<p> return 0; <br>
} <br>
</p>
</td>
</tr>
</table>
</center></div><div align="center"><center>
<table border="0" cellspacing="1" width="640">
<tr>
<td class="p9" height="60"> <script>document.write("<p><a href=\"http://view.gznet.com/cgi-bin/rl_views.cgi?UID=10013421\" target=sxrl>");
document.write("<img src=\"http://refer.gznet.com/cgi-bin/rl_refer2.cgi?UID=10013421&refer="+escape(top.document.referrer)+"\" width=1 height=1 border=0 alt=\" \">");
document.write("</a>");
</script></td>
</tr>
</table>
</center></div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -