📄 ff.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语言编程宝典之一 -->函数名: f</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>
-->函数名: f</td>
</tr>
<tr>
<td bordercolor="#8080FF" class="p9">函数名: fabs <br>
功 能: 返回浮点数的绝对值 <br>
用 法: double fabs(double x); <br>
程序例: <p>#include <stdio.h> <br>
#include <math.h> </p>
<p>int main(void) <br>
{ <br>
float number = -1234.0; </p>
<p> printf("number: %f absolute
value: %f\n", <br>
number, fabs(number)); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: farcalloc <br>
功 能: 从远堆栈中申请空间 <br>
用 法: void far *farcalloc(unsigned long units,
unsigned ling unitsz); <br>
程序例: <br>
#include <stdio.h> <br>
#include <alloc.h> <br>
#include <string.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
char far *fptr; <br>
char *str = "Hello"; </p>
<p> /* allocate memory for the far pointer */
<br>
fptr = farcalloc(10, sizeof(char)); </p>
<p> /* copy "Hello" into allocated
memory */ <br>
/* <br>
Note: movedata is used
because you <br>
might be in a small data
model, in <br>
which case a normal string
copy routine <br>
can not be used since it
assumes the <br>
pointer size is near. <br>
*/ <br>
movedata(FP_SEG(str), FP_OFF(str), <br>
FP_SEG(fptr), FP_OFF(fptr), <br>
strlen(str)); </p>
<p> /* display string (note the F modifier)
*/ <br>
printf("Far string is: %Fs\n",
fptr); </p>
<p> /* free the memory */ <br>
farfree(fptr); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: farcoreleft <br>
功 能: 返回远堆中未作用存储区大小 <br>
用 法: long farcoreleft(void); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <alloc.h> </p>
<p>int main(void) <br>
{ <br>
printf("The difference between the\ <br>
highest allocated block in the\ <br>
far\n"); <br>
printf("heap and the top of the far
heap\ <br>
is: %lu bytes\n", farcoreleft()); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: farfree <br>
功 能: 从远堆中释放一块 <br>
用 法: void farfree(void); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <alloc.h> <br>
#include <string.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
char far *fptr; <br>
char *str = "Hello"; </p>
<p> /* allocate memory for the far pointer */
<br>
fptr = farcalloc(10, sizeof(char)); </p>
<p> /* copy "Hello" into allocated
memory */ <br>
/* <br>
Note: movedata is used
because you might be in a small data model, <br>
in which case a normal
string copy routine can't be used since it <br>
assumes the pointer size
is near. <br>
*/ <br>
movedata(FP_SEG(str), FP_OFF(str), <br>
FP_SEG(fptr), FP_OFF(fptr), <br>
strlen(str)); </p>
<p> /* display string (note the F modifier)
*/ <br>
printf("Far string is: %Fs\n",
fptr); </p>
<p> /* free the memory */ <br>
farfree(fptr); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: farmalloc <br>
功 能: 从远堆中分配存储块 <br>
用 法: void far *farmalloc(unsigned long size); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <alloc.h> <br>
#include <string.h> <br>
#include <dos.h> </p>
<p>int main(void) <br>
{ <br>
char far *fptr; <br>
char *str = "Hello"; </p>
<p> /* allocate memory for the far pointer */
<br>
fptr = farmalloc(10); </p>
<p> /* copy "Hello" into allocated
memory */ <br>
/* <br>
Note: movedata is used
because we might <br>
be in a small data model,
in which case <br>
a normal string copy
routine can not be <br>
used since it assumes the
pointer size <br>
is near. <br>
*/ <br>
movedata(FP_SEG(str), FP_OFF(str), <br>
FP_SEG(fptr), FP_OFF(fptr), <br>
strlen(str)); </p>
<p> /* display string (note the F modifier)
*/ <br>
printf("Far string is: %Fs\n",
fptr); </p>
<p> /* free the memory */ <br>
farfree(fptr); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: farrealloc <br>
功 能: 调整远堆中的分配块 <br>
用 法: void far *farrealloc(void far *block,
unsigned long newsize); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <alloc.h> </p>
<p>int main(void) <br>
{ <br>
char far *fptr; </p>
<p> fptr = farmalloc(10); <br>
printf("First address: %Fp\n",
fptr); <br>
fptr = farrealloc(fptr,20); <br>
printf("New address :
%Fp\n", fptr); <br>
farfree(fptr); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: fclose <br>
功 能: 关闭一个流 <br>
用 法: int fclose(FILE *stream); <br>
程序例: </p>
<p>#include <string.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
FILE *fp; <br>
char buf[11] = "0123456789"; </p>
<p> /* create a file containing 10 bytes */ <br>
fp = fopen("DUMMY.FIL",
"w"); <br>
fwrite(&buf, strlen(buf), 1, fp); </p>
<p> /* close the file */ <br>
fclose(fp); <br>
return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: fcloseall <br>
功 能: 关闭打开流 <br>
用 法: int fcloseall(void); <br>
程序例: </p>
<p>#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
int streams_closed; </p>
<p> /* open two streams */ <br>
fopen("DUMMY.ONE", "w");
<br>
fopen("DUMMY.TWO", "w");
</p>
<p> /* close the open streams */ <br>
streams_closed = fcloseall(); </p>
<p> if (streams_closed == EOF) <br>
/* issue an error message
*/ <br>
perror("Error");
<br>
else <br>
/* print result of
fcloseall() function */ <br>
printf("%d streams
were closed.\n", streams_closed); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: fcvt <br>
功 能: 把一个浮点数转换为字符串 <br>
用 法: char *fcvt(double value, int ndigit, int
*decpt, int *sign); <br>
程序例: </p>
<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>
<br>
</p>
<p>函数名: fdopen <br>
功 能: 把流与一个文件句柄相接 <br>
用 法: FILE *fdopen(int handle, char *type); <br>
程序例: </p>
<p>#include <sys\stat.h> <br>
#include <stdio.h> <br>
#include <fcntl.h> <br>
#include <io.h> </p>
<p>int main(void) <br>
{ <br>
int handle; <br>
FILE *stream; </p>
<p> /* open a file */ <br>
handle = open("DUMMY.FIL",
O_CREAT, <br>
S_IREAD | S_IWRITE); </p>
<p> /* now turn the handle into a stream */ <br>
stream = fdopen(handle, "w"); </p>
<p> if (stream == NULL) <br>
printf("fdopen
failed\n"); <br>
else <br>
{ <br>
fprintf(stream,
"Hello world\n"); <br>
fclose(stream); <br>
} <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: feof <br>
功 能: 检测流上的文件结束符 <br>
用 法: int feof(FILE *stream); <br>
程序例: </p>
<p>#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
FILE *stream; </p>
<p> /* open a file for reading */ <br>
stream = fopen("DUMMY.FIL",
"r"); </p>
<p> /* read a character from the file */ <br>
fgetc(stream); </p>
<p> /* check for EOF */ <br>
if (feof(stream)) <br>
printf("We have
reached end-of-file\n"); </p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -