c语言函数大全(L开头)

c语言函数大全(L开头)

There is no nutrition in the blog content. After reading it, you will not only suffer from malnutrition, but also impotence.
The blog content is all parallel goods. Those who are worried about being cheated should leave quickly.

函数名: labs
用 法: long labs(long n);
程序例:
#include
#include
int main(void)
{
long result;
long x = -12345678L;
result= labs(x);
printf("number: %ld abs value: %ld\n",
x, result);
return 0;
}

函数名: ldexp
功 能: 计算value*2的幂
用 法: double ldexp(double value, int exp);
程序例:
#include
#include
int main(void)
{
double value;
double x = 2;
/* ldexp raises 2 by a power of 3
then multiplies the result by 2 */
value = ldexp(x,3);
printf("The ldexp value is: %lf\n",
value);
return 0;
}


函数名: ldiv
功 能: 两个长整型数相除, 返回商和余数
用 法: ldiv_t ldiv(long lnumer, long ldenom);
程序例:
/* ldiv example */
#include
#include
int main(void)
{
ldiv_t lx;
lx = ldiv(100000L, 30000L);
printf("100000 div 30000 = %ld remainder %ld\n", lx.quot, lx.rem);
return 0;
}

函数名: lfind
功 能: 执行线性搜索
用 法: void *lfind(void *key, void *base, int *nelem, int width,
int (*fcmp)());
程序例:
#include
#include
int compare(int *x, int *y)
{
return( *x - *y );
}
int main(void)
{
int array[5] = {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\n",key);
else
printf("Number %d not found\n",key);
return 0;
}


函数名: line
功 能: 在指定两点间画一直线
用 法: void far line(int x0, int y0, int x1, int y1);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
setcolor(getmaxcolor());
xmax = getmaxx();
ymax = getmaxy();
/* draw a diagonal line */
line(0, 0, xmax, ymax);
/* clean up */
getch();
closegraph();
return 0;
}


函数名: linerel
功 能: 从当前位置点(CP)到与CP有一给定相对距离的点画一直线
用 法: void far linerel(int dx, int dy);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
char msg[80];
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}
/* move the C.P. to location (20, 30) */
moveto(20, 30);
/* create and output a
message at (20, 30) */
sprintf(msg, " (%d, %d)", getx(), gety());
outtextxy(20, 30, msg);
/* draw a line to a point a relative
distance away from the current
value of C.P. */
linerel(100, 100);
/* create and output a message at C.P. */
sprintf(msg, " (%d, %d)", getx(), gety());
outtext(msg);
/* clean up */
getch();
closegraph();
return 0;
}

函数名: localtime
功 能: 把日期和时间转变为结构
用 法: struct tm *localtime(long *clock);
程序例:
#include
#include
#include
int main(void)
{
time_t timer;
struct tm *tblock;
/* gets time of day */
timer = time(NULL);
/* converts date/time to a structure */
tblock = localtime(&timer);
printf("Local time is: %s", asctime(tblock));
return 0;
}

函数名: 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\n");
exit(1);
}
length = filelength(handle);
status = lock(handle,0L,length/2);
if (status == 0)
printf("lock succeeded\n");
else
printf("lock failed\n");
status = unlock(handle,0L,length/2);
if (status == 0)
printf("unlock succeeded\n");
else
printf("unlock failed\n");
close(handle);
return 0;
}


函数名: 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\n", x, result);
return 0;
}


函数名: 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\n", x, result);
return 0;
}

函数名: 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\n", value);
exit(value);
}
printf("About to call subroutine ... \n");
subroutine(jumper);
return 0;
}
void subroutine(jmp_buf jumper)
{
longjmp(jumper,1);
}

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

函数名: 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\n", value, result);
return 0;
}


函数名: 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[5] = {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\n",key);
else
printf("Number %d not found\n",key);
return 0;
}

函数名: 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;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/767742.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python文件读写操作

文件操作注意点 注意点&#xff1a; 1. for line in file --> 会将偏移量移到末尾 2. buffering1 --> 缓冲区中遇到换行就刷新&#xff0c;即向磁盘中写入 3. 读操作结束后&#xff0c;文本偏移量就会移动到读操作结束位置 """编写一个程序,循环不停的写入…

简述C语言文件操作

&#x1f308; 个人主页&#xff1a;白子寰 &#x1f525; 分类专栏&#xff1a;魔法指针&#xff0c;进阶C&#xff0c;C语言&#xff0c;C语言题集&#xff0c;C语言实现游戏&#x1f448; 希望得到您的订阅和支持~ &#x1f4a1; 坚持创作博文(平均质量分79)&#xff0c;分享…

数组划分,双指针

1 移动零 题目链接&#xff1a;https://leetcode.cn/problems/move-zeroes/description/ 这道题要在原数组中交换位置&#xff0c;并且还要求算法有稳定性。我们的常规思路是划分数组&#xff0c;用双指针解决。 public static void doubleIndex3(int[] arr){for(int cur 0…

计算机网络(特南鲍姆版) 期末总结

教材《计算机网络&#xff08;第六版&#xff09;》 特南鲍姆版 介绍 互联的可以交换信息的计算机称之为计算机网络&#xff0c;如&#xff1a;英特网 用途 1.访问信息 客户-服务器模型 peer-to-peer system&#xff08;点对点技术&#xff0c;P2P&#xff09; P2P&#xf…

深入理解Linux与Java的IO模型

目录 IO模型Linux的I/O模型Java的I/O模型联系与区别 同步&#xff0c;异步&#xff0c;阻塞&#xff0c;非阻塞同步与异步阻塞与非阻塞Linux I/O模型中的应用Java I/O模型中的应用容易混淆的地方 通过交互理解IO模型用户空间与内核空间Linux I/O模型的交互过程 在软件开发领域&…

加载三维模型,加载时黑的?

JS引擎是单线程 JS和渲染引擎线程无法同时进行&#xff0c;若异步任务和同步任务过多&#xff0c;JS引擎运行&#xff0c;渲染引擎未工作&#xff0c;导致黑黑的

Delphi DataSet转JSon(字符串拼接json)

Delphi中将TDataSet转换为JSon字符串。 function Test.DataSetToJson(ADataset: TDataSet): string; varARecord: string;AField: TField;i: integer; beginResult : ;with ADataset dobegin// 如果dataset是空就退出if IsEmpty thenExit;//初始化ARecordARecord : ;//定义开头…

图论基础|841.钥匙和房间、463. 岛屿的周长

目录 841.钥匙和房间 思路&#xff1a;本题是一个有向图搜索全路径的问题。 只能用深搜&#xff08;DFS&#xff09;或者广搜&#xff08;BFS&#xff09;来搜。 463. 岛屿的周长 841.钥匙和房间 力扣题目链接 (opens new window) 有 N 个房间&#xff0c;开始时你位于 0…

git 常用命令-以及命令解析

一、Push操作 1.先git init 标识仓库地址2.git add xxx git add . 代表添加当前目录所有文件代表标识提交的文件3.git commit -m xxxx 代表git提交后需要说的什么话4.git remote add origin xxxx xxxx替换为github仓库的ssh地址5.git push origin xxx xxx为分支名称如果有报错可…

TCP重传机制详解——03DSACK

TCP重传机制详解——03DSACK 什么是DSACK DSACK是指"Duplicate Selective Acknowledgment"&#xff0c;即重复选择性确认。在TCP通信中&#xff0c;DSACK机制允许接收方向发送方发送有关重复数据包的信息&#xff0c;以帮助发送方更准确地处理重传和丢包情况。 当…

C语言- 输出班级第n个学生的平均成绩

题目描述 输出班级第 n个学生的平均成绩。每个学生有英语、数学、语文、计算机 4 科成绩。若干个学生的 4 门成绩构成一个表格&#xff0c;可以用二维数组储存&#xff0c;每行代表一个学生的 4 门成绩。以为要计算某个学生的平均成绩&#xff0c;需要快速定位到该生成绩的起始…

概率论与数理统计-条件概率题目1-两次取球问题(有放回)

题目&#xff1a; 设袋中装有r只红球,t只白球.每次自袋中任取一只球,观察其颜色例3然后放回,并再放入a只与所取出的那只球同色的球.若在袋中连续取球四次&#xff0c;试求第一、二次取到红球且第三、四次取到白球的概率. 解答&#xff1a; 涉及到条件概率和多次独立事件的概…

ColorWell for Mac 直装激活 非常实用的调色工具

ColorWell 是一款为Mac操作系统设计的实用工具&#xff0c;它旨在帮助用户快速而方便地选择、管理和应用颜色。这款应用程序特别适合设计师、插画师、网页开发者以及任何需要精确颜色匹配的专业人士使用。ColorWell 的核心功能是提供一个简单直观的界面&#xff0c;让用户可以轻…

C++一维数组练习oj(3)

为什么C的一维数组练习要出要做那么多的题目&#xff1f;因为我们是竞赛学生&#xff01;想要将每个知识点灵活运用的话就必须刷大量的题目来锻炼思维。 我使用的是jsswoj.com这个刷题网站&#xff0c;当然要钱... C一维数组练习oj(2)-CSDN博客这是上一次的题目讲解 这道题有…

vscode集成git管理项目

一、git与SVN Git&#xff1a; 是一种分布式版本控制系统&#xff0c;每个开发者都可以在本地完整地复制整个代码仓库&#xff0c;并且可以在不连接到中央服务器的情况下进行提交、分支和合并等操作。 SVN &#xff1a;是一种集中式版本控制系统&#xff0c;开发者们只能直接与…

PwnLab靶场PHP伪协议OSCP推荐代码审计命令劫持命令注入

下载链接&#xff1a;PwnLab: init ~ VulnHub 安装&#xff1a; 打开vxbox直接选择导入虚拟电脑即可 正文&#xff1a; 先用nmap扫描靶机ip nmap -sn 192.168.1.1/24 获取到靶机ip后&#xff0c;对靶机的端口进行扫描&#xff0c;并把结果输出到PwnLab文件夹下&#xff0c;命名…

java每日一题——买啤酒(递归经典问题)

前言&#xff1a; 非常喜欢的一道题&#xff0c;经典中的经典。打好基础&#xff0c;daydayup!!!啤酒问题&#xff1a;一瓶啤酒2元&#xff0c;4个盖子可以换一瓶&#xff0c;2个空瓶可以换一瓶&#xff0c;请问10元可以喝几瓶 题目如下&#xff1a; 啤酒问题&#xff1a;一瓶…

【剑指offer】17. 从尾到头打印链表(java选手)

题目链接 题目链接 题目描述 输入一个链表的头结点&#xff0c;按照 从尾到头 的顺序返回节点的值。 返回的结果用数组存储。 数据范围 0≤ 链表长度 ≤1000。 样例 输入&#xff1a;[2, 3, 5] 返回&#xff1a;[5, 3, 2] 思路 &#xff08;1&#xff09;从头到尾遍历链…

大数据实时计算的Windows功能?

Windows是数据流的时间窗口&#xff0c;流式数据特点就是源源不断没有边界&#xff0c;但是对于我们数据使用者而言很多时候业务要求对特定时间长度的数据进行切片并统计分析&#xff0c;以此来反映通过时间变化某个业务指标的变化情况&#xff0c;这个时候就需要用到流式计算引…

本地部署千问大模型笔记

使用llama.cpp运行大模型&#xff1a; main 命令有一系列参数可选&#xff0c;其中比较重要的参数有&#xff1a; -ins 交互模式&#xff0c;可以连续对话&#xff0c;上下文会保留 -c 控制上下文的长度&#xff0c;值越大越能参考更长的对话历史&#xff08;默认&#xff1a…