?? ff.htm
字號:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<META NAME="Author" CONTENT="wdg">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (Win95; I) [Netscape]">
<TITLE>ff</TITLE>
</HEAD>
<BODY>
<BR>
<P>函數(shù)名: fabs
<BR>功 能: 返回浮點(diǎn)數(shù)的絕對值
<BR>用 法: double fabs(double x);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <math.h>
<P>int main(void)
<BR>{
<BR> float number = -1234.0;
<P> printf("number: %f absolute value: %f\n",
<BR> number, fabs(number));
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: farcalloc
<BR>功 能: 從遠(yuǎn)堆棧中申請空間
<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>int main(void)
<BR>{
<BR> char far *fptr;
<BR> char *str = "Hello";
<P> /* allocate memory for the far pointer */
<BR> fptr = farcalloc(10, sizeof(char));
<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> /* display string (note the F modifier) */
<BR> printf("Far string is: %Fs\n", fptr);
<P> /* free the memory */
<BR> farfree(fptr);
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: farcoreleft
<BR>功 能: 返回遠(yuǎn)堆中未作用存儲區(qū)大小
<BR>用 法: long farcoreleft(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<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> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: farfree
<BR>功 能: 從遠(yuǎn)堆中釋放一塊
<BR>用 法: void farfree(void);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<BR>#include <string.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> char far *fptr;
<BR> char *str = "Hello";
<P> /* allocate memory for the far pointer */
<BR> fptr = farcalloc(10, sizeof(char));
<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> /* display string (note the F modifier) */
<BR> printf("Far string is: %Fs\n", fptr);
<P> /* free the memory */
<BR> farfree(fptr);
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: farmalloc
<BR>功 能: 從遠(yuǎn)堆中分配存儲塊
<BR>用 法: void far *farmalloc(unsigned long size);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<BR>#include <string.h>
<BR>#include <dos.h>
<P>int main(void)
<BR>{
<BR> char far *fptr;
<BR> char *str = "Hello";
<P> /* allocate memory for the far pointer */
<BR> fptr = farmalloc(10);
<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> /* display string (note the F modifier) */
<BR> printf("Far string is: %Fs\n", fptr);
<P> /* free the memory */
<BR> farfree(fptr);
<P> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: farrealloc
<BR>功 能: 調(diào)整遠(yuǎn)堆中的分配塊
<BR>用 法: void far *farrealloc(void far *block, unsigned long newsize);
<BR>程序例:
<P>#include <stdio.h>
<BR>#include <alloc.h>
<P>int main(void)
<BR>{
<BR> char far *fptr;
<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>函數(shù)名: fclose
<BR>功 能: 關(guān)閉一個(gè)流
<BR>用 法: int fclose(FILE *stream);
<BR>程序例:
<P>#include <string.h>
<BR>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> FILE *fp;
<BR> char buf[11] = "0123456789";
<P> /* create a file containing 10 bytes */
<BR> fp = fopen("DUMMY.FIL", "w");
<BR> fwrite(&buf, strlen(buf), 1, fp);
<P> /* close the file */
<BR> fclose(fp);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: fcloseall
<BR>功 能: 關(guān)閉打開流
<BR>用 法: int fcloseall(void);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> int streams_closed;
<P> /* open two streams */
<BR> fopen("DUMMY.ONE", "w");
<BR> fopen("DUMMY.TWO", "w");
<P> /* close the open streams */
<BR> streams_closed = fcloseall();
<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> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: fcvt
<BR>功 能: 把一個(gè)浮點(diǎn)數(shù)轉(zhuǎn)換為字符串
<BR>用 法: char *fcvt(double value, int ndigit, int *decpt, int *sign);
<BR>程序例:
<P>#include <stdlib.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> char *string;
<BR> double value;
<BR> int dec, sign;
<BR> int ndig = 10;
<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> 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> 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> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: fdopen
<BR>功 能: 把流與一個(gè)文件句柄相接
<BR>用 法: FILE *fdopen(int handle, char *type);
<BR>程序例:
<P>#include <sys\stat.h>
<BR>#include <stdio.h>
<BR>#include <fcntl.h>
<BR>#include <io.h>
<P>int main(void)
<BR>{
<BR> int handle;
<BR> FILE *stream;
<P> /* open a file */
<BR> handle = open("DUMMY.FIL", O_CREAT,
<BR> S_IREAD | S_IWRITE);
<P> /* now turn the handle into a stream */
<BR> stream = fdopen(handle, "w");
<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>函數(shù)名: feof
<BR>功 能: 檢測流上的文件結(jié)束符
<BR>用 法: int feof(FILE *stream);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> FILE *stream;
<P> /* open a file for reading */
<BR> stream = fopen("DUMMY.FIL", "r");
<P> /* read a character from the file */
<BR> fgetc(stream);
<P> /* check for EOF */
<BR> if (feof(stream))
<BR> printf("We have reached end-of-file\n");
<P> /* close the file */
<BR> fclose(stream);
<BR> return 0;
<BR>}
<BR>
<BR>
<P>函數(shù)名: ferror
<BR>功 能: 檢測流上的錯(cuò)誤
<BR>用 法: int ferror(FILE *stream);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
<BR>{
<BR> FILE *stream;
<P> /* open a file for writing */
<BR> stream = fopen("DUMMY.FIL", "w");
<P> /* force an error condition by attempting to read */
<BR> (void) getc(stream);
<P> if (ferror(stream)) /* test for an error on the stream
*/
<BR> {
<BR> /* display an error message */
<BR> printf("Error reading from DUMMY.FIL\n");
<P> /* reset the error and EOF indicators
*/
<BR> clearerr(stream);
<BR> }
<P> fclose(stream);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: fflush
<BR>功 能: 清除一個(gè)流
<BR>用 法: int fflush(FILE *stream);
<BR>程序例:
<P>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<BR>#include <io.h>
<P>void flush(FILE *stream);
<P>int main(void)
<BR>{
<BR> FILE *stream;
<BR> char msg[] = "This is a test";
<P> /* create a file */
<BR> stream = fopen("DUMMY.FIL", "w");
<P> /* write some data to the file */
<BR> fwrite(msg, strlen(msg), 1, stream);
<P> clrscr();
<BR> printf("Press any key to flush\
<BR> DUMMY.FIL:");
<BR> getch();
<P> /* flush the data to DUMMY.FIL without\
<BR> closing it */
<BR> flush(stream);
<P> printf("\nFile was flushed, Press any key\
<BR> to quit:");
<BR> getch();
<BR> return 0;
<BR>}
<P>void flush(FILE *stream)
<BR>{
<BR> int duphandle;
<P> /* flush the stream's internal buffer */
<BR> fflush(stream);
<P> /* make a duplicate file handle */
<BR> duphandle = dup(fileno(stream));
<P> /* close the duplicate handle to flush\
<BR> the DOS buffer */
<BR> close(duphandle);
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: fgetc
<BR>功 能: 從流中讀取字符
<BR>用 法: int fgetc(FILE *stream);
<BR>程序例:
<P>#include <string.h>
<BR>#include <stdio.h>
<BR>#include <conio.h>
<P>int main(void)
<BR>{
<BR> FILE *stream;
<BR> char string[] = "This is a test";
<BR> char ch;
<P> /* open a file for update */
<BR> stream = fopen("DUMMY.FIL", "w+");
<P> /* write a string into the file */
<BR> fwrite(string, strlen(string), 1, stream);
<P> /* seek to the beginning of the file */
<BR> fseek(stream, 0, SEEK_SET);
<P> do
<BR> {
<BR> /* read a char from the file */
<BR> ch = fgetc(stream);
<P> /* display the character */
<BR> putch(ch);
<BR> } while (ch != EOF);
<P> fclose(stream);
<BR> return 0;
<BR>}
<BR>
<BR>
<BR>
<P>函數(shù)名: fgetchar
<BR>功 能: 從流中讀取字符
<BR>用 法: int fgetchar(void);
<BR>程序例:
<P>#include <stdio.h>
<P>int main(void)
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -