📄 fl.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>fl</TITLE></HEAD><BODY> <P>函数名: labs<BR>功 能: 取长整型绝对值<BR>用 法: long labs(long n);<BR>程序例:<P>#include <stdio.h><BR>#include <math.h><P>int main(void)<BR>{<BR> long result;<BR> long x = -12345678L;<P> result= labs(x);<BR> printf("number: %ld abs value: %ld\n",<BR> x, result);<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: ldexp<BR>功 能: 计算value*2的幂<BR>用 法: double ldexp(double value, int exp);<BR>程序例:<P>#include <stdio.h><BR>#include <math.h><P>int main(void)<BR>{<BR> double value;<BR> double x = 2;<P> /* ldexp raises 2 by a power of 3<BR> then multiplies the result by 2 */<BR> value = ldexp(x,3);<BR> printf("The ldexp value is: %lf\n",<BR> value);<P> return 0;<BR>}<BR> <BR> <P>函数名: ldiv<BR>功 能: 两个长整型数相除, 返回商和余数<BR>用 法: ldiv_t ldiv(long lnumer, long ldenom);<BR>程序例:<P>/* ldiv example */<P>#include <stdlib.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> ldiv_t lx;<P> lx = ldiv(100000L, 30000L);<BR> printf("100000 div 30000 = %ld remainder %ld\n", lx.quot,lx.rem);<BR> return 0;<BR>}<BR> <BR> <BR> <P>函数名: lfind<BR>功 能: 执行线性搜索<BR>用 法: void *lfind(void *key, void *base, int *nelem, int width,<BR> int (*fcmp)());<BR>程序例:<P>#include <stdio.h><BR>#include <stdlib.h><P>int compare(int *x, int *y)<BR>{<BR> return( *x - *y );<BR>}<P>int main(void)<BR>{<BR> int array[5] = {35, 87, 46, 99, 12};<BR> size_t nelem = 5;<BR> int key;<BR> int *result;<P> key = 99;<BR> result = lfind(&key, array, &nelem,<BR> sizeof(int), (int(*)(constvoid *,const void *))compare);<BR> if (result)<BR> printf("Number %d found\n",key);<BR> else<BR> printf("Number %d not found\n",key);<P> return 0;<BR>}<BR> <BR> <P>函数名: line<BR>功 能: 在指定两点间画一直线<BR>用 法: void far line(int x0, int y0, int x1, int y1);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> int xmax, ymax;<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> /* an error occurred */<BR> if (errorcode != grOk)<BR> {<BR> printf("Graphics error: %s\n",<BR> grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1);<BR> }<P> setcolor(getmaxcolor());<BR> xmax = getmaxx();<BR> ymax = getmaxy();<P> /* draw a diagonal line */<BR> line(0, 0, xmax, ymax);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <BR> <P>函数名: linerel<BR>功 能: 从当前位置点(CP)到与CP有一给定相对距离的点画一直线<BR>用 法: void far linerel(int dx, int dy);<BR>程序例:<P>#include <graphics.h><BR>#include <stdlib.h><BR>#include <stdio.h><BR>#include <conio.h><P>int main(void)<BR>{<BR> /* request auto detection */<BR> int gdriver = DETECT, gmode, errorcode;<BR> char msg[80];<P> /* initialize graphics and local variables */<BR> initgraph(&gdriver, &gmode, "");<P> /* read result of initialization */<BR> errorcode = graphresult();<BR> if (errorcode != grOk)<BR> {<BR> printf("Graphics error: %s\n",<BR> grapherrormsg(errorcode));<BR> printf("Press any key to halt:");<BR> getch();<BR> exit(1);<BR> }<P> /* move the C.P. to location (20, 30) */<BR> moveto(20, 30);<P> /* create and output a<BR> message at (20, 30) */<BR> sprintf(msg, " (%d, %d)", getx(), gety());<BR> outtextxy(20, 30, msg);<P> /* draw a line to a point a relative<BR> distance away from the current<BR> value of C.P. */<BR> linerel(100, 100);<P> /* create and output a message at C.P. */<BR> sprintf(msg, " (%d, %d)", getx(), gety());<BR> outtext(msg);<P> /* clean up */<BR> getch();<BR> closegraph();<BR> return 0;<BR>}<BR> <P>函数名: localtime<BR>功 能: 把日期和时间转变为结构<BR>用 法: struct tm *localtime(long *clock);<BR>程序例:<P>#include <time.h><BR>#include <stdio.h><BR>#include <dos.h><P>int main(void)<BR>{<BR> time_t timer;<BR> struct tm *tblock;<P> /* gets time of day */<BR> timer = time(NULL);<P> /* converts date/time to a structure */<BR> tblock = localtime(&timer);<P> printf("Local time is: %s", asctime(tblock));<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: lock<BR>功 能: 设置文件共享锁<BR>用 法: int lock(int handle, long offset, long length);<BR>程序例:<P>#include <io.h><BR>#include <fcntl.h><BR>#include <sys\stat.h><BR>#include <process.h><BR>#include <share.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> int handle, status;<BR> long length;<P> /* Must have DOS Share.exe loaded for */<BR> /* file locking to function properly */<P> handle = sopen("c:\\autoexec.bat",<BR> O_RDONLY,SH_DENYNO,S_IREAD);<P> if (handle < 0)<BR> {<BR> printf("sopen failed\n");<BR> exit(1);<BR> }<P> length = filelength(handle);<BR> status = lock(handle,0L,length/2);<P> if (status == 0)<BR> printf("lock succeeded\n");<BR> else<BR> printf("lock failed\n");<P> status = unlock(handle,0L,length/2);<P> if (status == 0)<BR> printf("unlock succeeded\n");<BR> else<BR> printf("unlock failed\n");<P> close(handle);<BR> return 0;<BR>}<BR> <BR> <P>函数名: log<BR>功 能: 对数函数ln(x)<BR>用 法: double log(double x);<BR>程序例:<P>#include <math.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> double result;<BR> double x = 8.6872;<P> result = log(x);<BR> printf("The natural log of %lf is %lf\n", x, result);<P> return 0;<BR>}<BR> <BR> <P>函数名: log10<BR>功 能: 对数函数log<BR>用 法: double log10(double x);<BR>程序例:<P>#include <math.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> double result;<BR> double x = 800.6872;<P> result = log10(x);<BR> printf("The common log of %lf is %lf\n", x, result);<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: longjump<BR>功 能: 执行非局部转移<BR>用 法: void longjump(jmp_buf env, int val);<BR>程序例:<P>#include <stdio.h><BR>#include <setjmp.h><BR>#include <stdlib.h><P>void subroutine(jmp_buf);<P>int main(void)<BR>{<P> int value;<BR> jmp_buf jumper;<P> value = setjmp(jumper);<BR> if (value != 0)<BR> {<BR> printf("Longjmp with value %d\n", value);<BR> exit(value);<BR> }<BR> printf("About to call subroutine ... \n");<BR> subroutine(jumper);<P> return 0;<BR>}<P>void subroutine(jmp_buf jumper)<BR>{<BR> longjmp(jumper,1);<BR>}<BR> <BR> <BR> <P>函数名: lowvideo<BR>功 能: 选择低亮度字符<BR>用 法: void lowvideo(void);<BR>程序例:<P>#include <conio.h><P>int main(void)<BR>{<BR> clrscr();<P> highvideo();<BR> cprintf("High Intesity Text\r\n");<BR> lowvideo();<BR> gotoxy(1,2);<BR> cprintf("Low Intensity Text\r\n");<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: lrotl, _lrotl<BR>功 能: 将无符号长整型数向左循环移位<BR>用 法: unsigned long lrotl(unsigned long lvalue, int count);<BR> unsigned long _lrotl(unsigned long lvalue, int count);<BR>程序例:<P>/* lrotl example */<BR>#include <stdlib.h><BR>#include <stdio.h><P>int main(void)<BR>{<BR> unsigned long result;<BR> unsigned long value = 100;<P> result = _lrotl(value,1);<BR> printf("The value %lu rotated left one bit is: %lu\n",value, result);<P> return 0;<BR>}<BR> <BR> <P>函数名: lsearch<BR>功 能: 线性搜索<BR>用 法: void *lsearch(const void *key, void *base, size_t *nelem,<BR> size_t width, int (*fcmp)(constvoid *, const void *));<BR>程序例:<P>#include <stdio.h><BR>#include <stdlib.h><P>int compare(int *x, int *y)<BR>{<BR> return( *x - *y );<BR>}<P>int main(void)<BR>{<BR> int array[5] = {35, 87, 46, 99, 12};<BR> size_t nelem = 5;<BR> int key;<BR> int *result;<P> key = 99;<BR> result = lfind(&key, array, &nelem,<BR> sizeof(int), (int(*)(const void *,const void *))compare);<BR> if (result)<BR> printf("Number %d found\n",key);<BR> else<BR> printf("Number %d not found\n",key);<P> return 0;<BR>}<BR> <BR> <BR> <P>函数名: lseek<BR>功 能: 移动文件读/写指针<BR>用 法: long lseek(int handle, long offset, int fromwhere);<BR>程序例:<P>#include <sys\stat.h><BR>#include <string.h><BR>#include <stdio.h><BR>#include <fcntl.h><BR>#include <io.h><P>int main(void)<BR>{<BR> int handle;<BR> char msg[] = "This is a test";<BR> char ch;<P> /* create a file */<BR> handle = open("TEST.$$$", O_CREAT | O_RDWR, S_IREAD |S_IWRITE);<P> /* write some data to the file */<BR> write(handle, msg, strlen(msg));<P> /* seek to the begining of the file */<BR> lseek(handle, 0L, SEEK_SET);<P> /* reads chars from the file until we hit EOF */<BR> do<BR> {<BR> read(handle, &ch, 1);<BR> printf("%c", ch);<BR> } while (!eof(handle));<P> close(handle);<BR> return 0;<BR>}<BR> <P> <A HREF="index.html">返回目录</A><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -