墙角野猫 发表于 2006-7-13 00:09

函数名: lock
功 能: 设置文件共享锁
用 法: int lock(int handle, long offset, long length);
程序例:
#include
#include
#include
#include
#include
#include
int main(void)
{
int handle, status;
long length;
/* Must have DOS Share.exe loaded for */
/* file locking to function properly */
handle = sopen("c:\\autoexec.bat",
O_RDONLY,SH_DENYNO,S_IREAD);
if (handle < 0)
{
printf("sopen failed
");
exit(1);
}
length = filelength(handle);
status = lock(handle,0L,length/2);
if (status == 0)
printf("lock succeeded
");
else
printf("lock failed
");
status = unlock(handle,0L,length/2);
if (status == 0)
printf("unlock succeeded
");
else
printf("unlock failed
");
close(handle);
return 0;
}

墙角野猫 发表于 2006-7-13 00:09

函数名: log
功 能: 对数函数ln(x)
用 法: double log(double x);
程序例:
#include
#include
int main(void)
{
double result;
double x = 8.6872;
result = log(x);
printf("The natural log of %lf is %lf
", x, result);
return 0;
}

墙角野猫 发表于 2006-7-13 00:10

函数名: log10
功 能: 对数函数log
用 法: double log10(double x);
程序例:
#include
#include
int main(void)
{
double result;
double x = 800.6872;
result = log10(x);
printf("The common log of %lf is %lf
", x, result);
return 0;
}

墙角野猫 发表于 2006-7-13 00:10

函数名: longjump
功 能: 执行非局部转移
用 法: void longjump(jmp_buf env, int val);
程序例:
#include
#include
#include
void subroutine(jmp_buf);
int main(void)
{
int value;
jmp_buf jumper;
value = setjmp(jumper);
if (value != 0)
{
printf("Longjmp with value %d
", value);
exit(value);
}
printf("About to call subroutine ...
");
subroutine(jumper);
return 0;
}
void subroutine(jmp_buf jumper)
{
longjmp(jumper,1);
}

墙角野猫 发表于 2006-7-13 00:10

函数名: lowvideo
功 能: 选择低亮度字符
用 法: void lowvideo(void);
程序例:
#include
int main(void)
{
clrscr();
highvideo();
cprintf("High Intesity Text\r
");
lowvideo();
gotoxy(1,2);
cprintf("Low Intensity Text\r
");
return 0;
}

墙角野猫 发表于 2006-7-13 00:10

函数名: lrotl, _lrotl
功 能: 将无符号长整型数向左循环移位
用 法: unsigned long lrotl(unsigned long lvalue, int count);
unsigned long _lrotl(unsigned long lvalue, int count);
程序例:
/* lrotl example */
#include
#include
int main(void)
{
unsigned long result;
unsigned long value = 100;
result = _lrotl(value,1);
printf("The value %lu rotated left one bit is: %lu
", value, result);
return 0;
}

墙角野猫 发表于 2006-7-13 00:11

函数名: lsearch
功 能: 线性搜索
用 法: void *lsearch(const void *key, void *base, size_t *nelem,
size_t width, int (*fcmp)(const void *, const void *));
程序例:
#include
#include
int compare(int *x, int *y)
{
return( *x - *y );
}
int main(void)
{
int array = {35, 87, 46, 99, 12};
size_t nelem = 5;
int key;
int *result;
key = 99;
result = lfind(&key, array, &nelem,
sizeof(int), (int(*)(const void *,const void *))compare);
if (result)
printf("Number %d found
",key);
else
printf("Number %d not found
",key);
return 0;
}

墙角野猫 发表于 2006-7-13 00:12

完了,左手小指抽筋了

墙角野猫 发表于 2006-7-13 00:12

按ctrl c ctrl v按得累死

墙角野猫 发表于 2006-7-13 00:34

函数名: lseek
功 能: 移动文件读/写指针
用 法: long lseek(int handle, long offset, int fromwhere);
程序例:
#include
#include
#include
#include
#include
int main(void)
{
int handle;
char msg[] = "This is a test";
char ch;
/* create a file */
handle = open("TEST.$$$", O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
/* write some data to the file */
write(handle, msg, strlen(msg));
/* seek to the begining of the file */
lseek(handle, 0L, SEEK_SET);
/* reads chars from the file until we hit EOF */
do
{
read(handle, &ch, 1);
printf("%c", ch);
} while (!eof(handle));
close(handle);
return 0;
}
页: 7 8 9 10 11 12 13 14 15 16 [17] 18 19 20 21 22 23 24 25 26
查看完整版本: c语言函数大全