📄 fl.htm
字号:
<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>
<p>int main(void) <br>
{ <br>
int handle, status; <br>
long length; </p>
<p> /* Must have DOS Share.exe loaded for */ <br>
/* file locking to function properly */ </p>
<p> handle =
sopen("c:\\autoexec.bat", <br>
O_RDONLY,SH_DENYNO,S_IREAD); </p>
<p> if (handle < 0) <br>
{ <br>
printf("sopen
failed\n"); <br>
exit(1); <br>
} </p>
<p> length = filelength(handle); <br>
status = lock(handle,0L,length/2); </p>
<p> if (status == 0) <br>
printf("lock
succeeded\n"); <br>
else <br>
printf("lock
failed\n"); </p>
<p> status = unlock(handle,0L,length/2); </p>
<p> if (status == 0) <br>
printf("unlock
succeeded\n"); <br>
else <br>
printf("unlock
failed\n"); </p>
<p> close(handle); <br>
return 0; <br>
} <br>
<br>
</p>
<p>函数名: log <br>
功 能: 对数函数ln(x) <br>
用 法: double log(double x); <br>
程序例: </p>
<p>#include <math.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
double result; <br>
double x = 8.6872; </p>
<p> result = log(x); <br>
printf("The natural log of %lf is
%lf\n", x, result); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: log10 <br>
功 能: 对数函数log <br>
用 法: double log10(double x); <br>
程序例: </p>
<p>#include <math.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
double result; <br>
double x = 800.6872; </p>
<p> result = log10(x); <br>
printf("The common log of %lf is
%lf\n", x, result); </p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: longjump <br>
功 能: 执行非局部转移 <br>
用 法: void longjump(jmp_buf env, int val); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <setjmp.h> <br>
#include <stdlib.h> </p>
<p>void subroutine(jmp_buf); </p>
<p>int main(void) <br>
{ </p>
<p> int value; <br>
jmp_buf jumper; </p>
<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>
<p> return 0; <br>
} </p>
<p>void subroutine(jmp_buf jumper) <br>
{ <br>
longjmp(jumper,1); <br>
} <br>
<br>
<br>
</p>
<p>函数名: lowvideo <br>
功 能: 选择低亮度字符 <br>
用 法: void lowvideo(void); <br>
程序例: </p>
<p>#include <conio.h> </p>
<p>int main(void) <br>
{ <br>
clrscr(); </p>
<p> highvideo(); <br>
cprintf("High Intesity Text\r\n");
<br>
lowvideo(); <br>
gotoxy(1,2); <br>
cprintf("Low Intensity Text\r\n");
</p>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: lrotl, _lrotl <br>
功 能: 将无符号长整型数向左循环移位
<br>
用 法: unsigned long lrotl(unsigned long lvalue,
int count); <br>
unsigned long _lrotl(unsigned long lvalue, int
count); <br>
程序例: </p>
<p>/* lrotl example */ <br>
#include <stdlib.h> <br>
#include <stdio.h> </p>
<p>int main(void) <br>
{ <br>
unsigned long result; <br>
unsigned long value = 100; </p>
<p> result = _lrotl(value,1); <br>
printf("The value %lu rotated left one
bit is: %lu\n", value, result); </p>
<p> return 0; <br>
} <br>
<br>
</p>
<p>函数名: lsearch <br>
功 能: 线性搜索 <br>
用 法: void *lsearch(const void *key, void *base,
size_t *nelem, <br>
size_t width, int
(*fcmp)(const void *, const void *)); <br>
程序例: </p>
<p>#include <stdio.h> <br>
#include <stdlib.h> </p>
<p>int compare(int *x, int *y) <br>
{ <br>
return( *x - *y ); <br>
} </p>
<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>
<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>
<p> return 0; <br>
} <br>
<br>
<br>
</p>
<p>函数名: lseek <br>
功 能: 移动文件读/写指针 <br>
用 法: long lseek(int handle, long offset, int
fromwhere); <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("TEST.$$$", O_CREAT
| O_RDWR, S_IREAD | S_IWRITE); </p>
<p> /* write some data to the file */ <br>
write(handle, msg, strlen(msg)); </p>
<p> /* seek to the begining of the file */ <br>
lseek(handle, 0L, SEEK_SET); </p>
<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>
<p> close(handle); <br>
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 + -