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

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

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.

函数名: cabs
功 能: 计算复数的绝对值
用 法: double cabs(struct complex z);
程序例:
#include
#include
int main(void)
{
struct complex z;
double val;
z.x = 2.0;
z.y = 1.0;
val = cabs(z);
printf("The absolute value of %.2lfi %.2lfj is %.2lf", z.x, z.y, val);
return 0;
}

函数名: calloc
功 能: 分配主存储器
用 法: void *calloc(size_t nelem, size_t elsize);
程序例:
#include
#include
int main(void)
{
char *str = NULL;
/* allocate memory for string */
str = calloc(10, sizeof(char));
/* copy "Hello" into string */
strcpy(str, "Hello");
/* display string */
printf("String is %s\n", str);
/* free memory */
free(str);
return 0;
}

函数名: ceil
功 能: 向上舍入
用 法: double ceil(double x);
程序例:
#include
#include
int main(void)
{
double number = 123.54;
double down, up;
down = floor(number);
up = ceil(number);
printf("original number %5.2lf\n", number);
printf("number rounded down %5.2lf\n", down);
printf("number rounded up %5.2lf\n", up);
return 0;
}

函数名: cgets
功 能: 从控制台读字符串
用 法: char *cgets(char *str);
程序例:
#include
#include
int main(void)
{
char buffer[83];
char *p;
/* There's space for 80 characters plus the NULL terminator */
buffer[0] = 81;
printf("Input some chars:");
p = cgets(buffer);
printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
/* Leave room for 5 characters plus the NULL terminator */
buffer[0] = 6;
printf("Input some chars:");
p = cgets(buffer);
printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
return 0;
}

函数名: chdir
功 能: 改变工作目录
用 法: int chdir(const char *path);
程序例:
#include
#include
#include
char old_dir[MAXDIR];
char new_dir[MAXDIR];
int main(void)
{
if (getcurdir(0, old_dir))
{
perror("getcurdir()");
exit(1);
}
printf("Current directory is: \\%s\n", old_dir);
if (chdir("\\"))
{
perror("chdir()");
exit(1);
}
if (getcurdir(0, new_dir))
{
perror("getcurdir()");
exit(1);
}
printf("Current directory is now: \\%s\n", new_dir);
printf("\nChanging back to orignal directory: \\%s\n", old_dir);
if (chdir(old_dir))
{
perror("chdir()");
exit(1);
}
return 0;
}


函数名: _chmod, chmod
功 能: 改变文件的访问方式
用 法: int chmod(const char *filename, int permiss);
程序例:
#include
#include
#include
void make_read_only(char *filename);
int main(void)
{
make_read_only("NOTEXIST.FIL");
make_read_only("MYFILE.FIL");
return 0;
}
void make_read_only(char *filename)
{
int stat;
stat = chmod(filename, S_IREAD);
if (stat)
printf("Couldn't make %s read-only\n", filename);
else
printf("Made %s read-only\n", filename);
}

函数名: chsize
功 能: 改变文件大小
用 法: int chsize(int handle, long size);
程序例:
#include
#include
#include
int main(void)
{
int handle;
char buf[11] = "0123456789";
/* create text file containing 10 bytes */
handle = open("DUMMY.FIL", O_CREAT);
write(handle, buf, strlen(buf));
/* truncate the file to 5 bytes in size */
chsize(handle, 5);
/* close the file */
close(handle);
return 0;
}


函数名: circle
功 能: 在给定半径以(x, y)为圆心画圆
用 法: void far circle(int x, int y, int radius);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* draw the circle */
circle(midx, midy, radius);
/* clean up */
getch();
closegraph();
return 0;
}

函数名: cleardevice
功 能: 清除图形屏幕
用 法: void far cleardevice(void);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());
/* for centering screen messages */
settextjustify(CENTER_TEXT, CENTER_TEXT);
/* output a message to the screen */
outtextxy(midx, midy, "press any key to clear the screen:");
/* wait for a key */
getch();
/* clear the screen */
cleardevice();
/* output another message */
outtextxy(midx, midy, "press any key to quit:");
/* clean up */
getch();
closegraph();
return 0;
}

函数名: clearerr
功 能: 复位错误标志
用 法:void clearerr(FILE *stream);
程序例:
#include
int main(void)
{
FILE *fp;
char ch;
/* open a file for writing */
fp = fopen("DUMMY.FIL", "w");
/* force an error condition by attempting to read */
ch = fgetc(fp);
printf("%c\n",ch);
if (ferror(fp))
{
/* display an error message */
printf("Error reading from DUMMY.FIL\n");
/* reset the error and EOF indicators */
clearerr(fp);
}
fclose(fp);
return 0;
}

函数名: clearviewport
功 能: 清除图形视区
用 法: void far clearviewport(void);
程序例:
#include
#include
#include
#include
#define CLIP_ON 1 /* activates clipping in viewport */
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int ht;
/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
setcolor(getmaxcolor());
ht = textheight("W");
/* message in default full-screen viewport */
outtextxy(0, 0, "* <-- (0, 0) in default viewport");
/* create a smaller viewport */
setviewport(50, 50, getmaxx()-50, getmaxy()-50, CLIP_ON);
/* display some messages */
outtextxy(0, 0, "* <-- (0, 0) in smaller viewport");
outtextxy(0, 2*ht, "Press any key to clear viewport:");
/* wait for a key */
getch();
/* clear the viewport */
clearviewport();
/* output another message */
outtextxy(0, 0, "Press any key to quit:");
/* clean up */
getch();
closegraph();
return 0;
}

函数名: _close, close
功 能: 关闭文件句柄
用 法: int close(int handle);
程序例:
#include
#include
#include
#include
main()
{
int handle;
char buf[11] = "0123456789";
/* create a file containing 10 bytes */
handle = open("NEW.FIL", O_CREAT);
if (handle > -1)
{
write(handle, buf, strlen(buf));
/* close the file */
close(handle);
}
else
{
printf("Error opening file\n");
}
return 0;
}

函数名: clock
功 能: 确定处理器时间
用 法: clock_t clock(void);
程序例:
#include
#include
#include
int main(void)
{
clock_t start, end;
start = clock();
delay(2000);
end = clock();
printf("The time was: %f\n", (end - start) / CLK_TCK);
return 0;
}

函数名: closegraph
功 能: 关闭图形系统
用 法: void far closegraph(void);
程序例:
#include
#include
#include
#include
int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int x, y;
/* initialize graphics mode */
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error
occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}
x = getmaxx() / 2;
y = getmaxy() / 2;
/* output a message */
settextjustify(CENTER_TEXT, CENTER_TEXT);
outtextxy(x, y, "Press a key to close the graphics system:");
/* wait for a key */
getch();
/* closes down the graphics system */
closegraph();
printf("We're now back in text mode.\n");
printf("Press any key to halt:");
getch();
return 0;
}

函数名: clreol
功 能: 在文本窗口中清除字符到行末
用 法: void clreol(void);
程序例:
#include
int main(void)
{
clrscr();
cprintf("The function CLREOL clears all characters from the\r\n");
cprintf("cursor position to the end of the line within the\r\n");
cprintf("current text window, without moving the cursor.\r\n");
cprintf("Press any key to continue . . .");
gotoxy(14, 4);
getch();
clreol();
getch();
return 0;
}

函数名: clrscr
功 能: 清除文本模式窗口
用 法: void clrscr(void);
程序例:
#include
int main(void)
{
int i;
clrscr();
for (i = 0; i < 20; i++)
cprintf("%d\r\n", i);
cprintf("\r\nPress any key to clear screen");
getch();
clrscr();
cprintf("The screen has been cleared!");
getch();
return 0;
}

函数名: coreleft
功 能: 返回未使用内存的大小
用 法: unsigned coreleft(void);
程序例:
#include
#include
int main(void)
{
printf("The difference between the highest allocated block and\n");
printf("the top of the heap is: %lu bytes\n", (unsigned long) coreleft());
return 0;
}

函数名: cos
功 能: 余弦函数
用 法: double cos(double x);
程序例:
#include
#include
int main(void)
{
double result;
double x = 0.5;
result = cos(x);
printf("The cosine of %lf is %lf\n", x, result);
return 0;
}

函数名: cosh
功 能: 双曲余弦函数
用 法: dluble cosh(double x);
程序例:
#include
#include
int main(void)
{
double result;
double x = 0.5;
result = cosh(x);
printf("The hyperboic cosine of %lf is %lf\n", x, result);
return 0;
}

函数名: country
功 能: 返回与国家有关的信息
用 法: struct COUNTRY *country(int countrycode, struct country *country);
程序例:
#include
#include
#define USA 0
int main(void)
{
struct COUNTRY country_info;
country(USA, &country_info);
printf("The currency symbol for the USA is: %s\n",
country_info.co_curr);
return 0;
}

函数名: cprintf
功 能: 送格式化输出至屏幕
用 法: int cprintf(const char *format[, argument, ...]);
程序例:
#include
int main(void)
{
/* clear the screen */
clrscr();
/* create a text window */
window(10, 10, 80, 25);
/* output some text in the window */
cprintf("Hello world\r\n");
/* wait for a key */
getch();
return 0;
}

函数名: cputs
功 能: 写字符到屏幕
用 法: void cputs(const char *string);
程序例:
#include
int main(void)
{
/* clear the screen */
clrscr();
/* create a text window */
window(10, 10, 80, 25);
/* output some text in the window */
cputs("This is within the window\r\n");
/* wait for a key */
getch();
return 0;
}

函数名: _creat creat
功 能: 创建一个新文件或重写一个已存在的文件
用 法: int creat (const char *filename, int permiss);
程序例:
#include
#include
#include
#include
int main(void)
{
int handle;
char buf[11] = "0123456789";
/* change the default file mode from text to binary */
_fmode = O_BINARY;
/* create a binary file for reading and writing */
handle = creat("DUMMY.FIL", S_IREAD | S_IWRITE);
/* write 10 bytes to the file */
write(handle, buf, strlen(buf));
/* close the file */
close(handle);
return 0;
}

函数名: creatnew
功 能: 创建一个新文件
用 法: int creatnew(const char *filename, int attrib);
程序例:
#include
#include
#include
#include
#include
int main(void)
{
int handle;
char buf[11] = "0123456789";
/* attempt to create a file that doesn't already exist */
handle = creatnew("DUMMY.FIL", 0);
if (handle == -1)
printf("DUMMY.FIL already exists.\n");
else
{
printf("DUMMY.FIL successfully created.\n");
write(handle, buf, strlen(buf));
close(handle);
}
return 0;
}

函数名: creattemp
功 能: 创建一个新文件或重写一个已存在的文件
用 法: int creattemp(const char *filename, int attrib);
程序例:
#include
#include
#include
int main(void)
{
int handle;
char pathname[128];
strcpy(pathname, "\\");
/* create a unique file in the root directory */
handle = creattemp(pathname, 0);
printf("%s was the unique file created.\n", pathname);
close(handle);
return 0;
}

函数名: cscanf
功 能: 从控制台执行格式化输入
用 法: int cscanf(char *format[,argument, ...]);
程序例:
#include
int main(void)
{
char string[80];
/* clear the screen */
clrscr();
/* Prompt the user for input */
cprintf("Enter a string with no spaces:");
/* read the input */
cscanf("%s", string);
/* display what was read */
cprintf("\r\nThe string entered is: %s", string);
return 0;
}

函数名: ctime
功 能: 把日期和时间转换为字符串
用 法: char *ctime(const time_t *time);
程序例:
#include
#include
int main(void)
{
time_t t;
time(&t);
printf("Today's date and time: %s\n", ctime(&t));
return 0;
}

函数名: ctrlbrk
功 能: 设置Ctrl-Break处理程序
用 法: void ctrlbrk(*fptr)(void);
程序例:
#include
#include
#define ABORT 0
int c_break(void)
{
printf("Control-Break pressed. Program aborting ...\n");
return (ABORT);
}
int main(void)
{
ctrlbrk(c_break);
for(;;)
{
printf("Looping... Press to quit:\n");
}
return 0;
}

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

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

相关文章

sql——对于行列转换相关的操作

目录 一、lead、lag 函数 二、wm_concat 函数 三、pivot 函数 四、判断函数 遇到需要进行行列转换的数据处理需求&#xff0c;以 oracle 自带的表作为例子复习一下&#xff1a; 一、lead、lag 函数 需要行列转换的表&#xff1a; select deptno,count(empno) emp_num from…

MongoDB 入门简介

什么是 MongoDB&#xff1f; MongoDB 是一个基于分布式文件存储的开源数据库系统。它是一个 NoSQL&#xff08;Not only SQL&#xff0c;意为不仅仅是SQL&#xff09;数据库&#xff0c;使用文档&#xff08;BSON格式&#xff0c;类似于JSON&#xff09;来存储数据。MongoDB 以…

【工具】DataX 数据同步工具

简介 DataX 是阿里云 DataWorks数据集成 的开源版本&#xff0c;在阿里巴巴集团内被广泛使用的离线数据同步工具/平台。DataX 实现了包括 MySQL、Oracle、OceanBase、SqlServer、Postgre、HDFS、Hive、ADS、HBase、TableStore(OTS)、MaxCompute(ODPS)、Hologres、DRDS, databe…

基于java+springboot+vue实现的图书借阅系统(文末源码+Lw+ppt)23-328

摘 要 伴随着我国社会的发展&#xff0c;人民生活质量日益提高。于是对系统进行规范而严格是十分有必要的&#xff0c;所以许许多多的信息管理系统应运而生。此时单靠人力应对这些事务就显得有些力不从心了。所以本论文将设计一套“期待相遇”图书借阅系统&#xff0c;帮助商…

代码随想录训练营第55天 | LeetCode 583. 两个字符串的删除操作、​​​​​​LeetCode 72. 编辑距离、总结

目录 LeetCode 583. 两个字符串的删除操作 文章讲解&#xff1a;代码随想录(programmercarl.com) 视频讲解&#xff1a;LeetCode&#xff1a;583.两个字符串的删除操_哔哩哔哩_bilibili 思路 ​​​​​​LeetCode 72. 编辑距离 文章讲解&#xff1a;代码随想录(programm…

哪些行业需要在线制作电子证书系统?

哪些行业需要在线制作电子证书系统&#xff1f; 1、教育机构&#xff1a;学校和培训机构需要为学生和培训者颁发证书&#xff0c;您的系统可以帮助他们快速生成和管理这些证书。 2、企业及政府部门&#xff1a;用于员工培训、资质认证等&#xff0c;提高内部管理效率。 3、专…

小白如何兼职赚得第一桶金?六大网络赚钱方式让你轻松开启副业之旅

小白如何兼职赚得第一桶金&#xff1f;六大网络赚钱方式让你轻松开启副业之旅 无需担忧&#xff0c;以下是一些精心挑选的线上兼职建议&#xff0c;将助你迅速开启赚钱之旅。 1&#xff0c;参与网络调查&#xff1a;各大市场调研公司及品牌商常常需要了解消费者心声&#xff0c…

在JavaScript中垂直过滤

垂直过滤是一种常见的数据处理技术&#xff0c;通过该技术可以筛选出符合特定条件的数据并进行展示。在JavaScript中&#xff0c;我们可以利用数组方法和条件判断语句来实现垂直过滤功能。下面是一个简单的示例&#xff0c;演示如何利用JavaScript实现一个基本的垂直过滤功能。…

06|Java集合框架初学者指南:List、Set与Map的实战训练

Java集合框架是Java语言的核心部分,它提供了丰富的类和接口,用来高效地管理和操作大量数据。这个强大的工具箱包括多种集合类型,其中最为常用的是List、Set和Map。 1.List - 有序且可重复的数据清单 概念: List就像一个购物清单,你可以按照加入顺序存放和检索项目,而且同…

[BT]BUUCTF刷题第7天(3.25)

第7天 Web&#xff08;共5题&#xff09; [BJDCTF2020]Easy MD5 打开网站发现只有一个输入框&#xff0c;F12后也没有明显提示&#xff0c;但是在数据包中看到Hint&#xff1a;select * from admin where passwordmd5($pass,true)&#xff0c;意思是在admin表中查找password为…

oracle切换ADG后JVM组件查询报错ORA-29516处理

近期&#xff0c;某用户将数据库系统从EXADATA切换到普通X86 LINUX架构服务器上运行时&#xff0c;使用JAVA组件时报错ORA-29516: Aurora assertion failure: Assertion failure at jol.c:11157 joez mt-index botch; mt_index 65535, vtbl_len 12, static_len 2 对于此报错…

Java中的代理模式(动态代理和静态代理)

代理模式 我们先了解一下代理模式&#xff1a; 在开发中&#xff0c;当我们要访问目标类时&#xff0c;不是直接访问目标类&#xff0c;而是访问器代理类。通过代理类调用目标类完成操作。简单来说就是&#xff1a;把直接访问变为间接访问。 这样做的最大好处就是&#xff1a…

吴恩达机器学习-可选实验室:Softmax函数

文章目录 CostTensorflow稀疏类别交叉熵或类别交叉熵祝贺 在这个实验室里&#xff0c;我们将探索softmax函数。当解决多类分类问题时&#xff0c;该函数用于Softmax回归和神经网络。 import numpy as np import matplotlib.pyplot as plt plt.style.use(./deeplearning.mplstyl…

面向低成本巡线机器人的PID控制器优化——文末源码

目录 介绍 测试 电子元器件 系统特征 控制器设计 位置误差的计算 比例控制 积分控制 微分控制 改进的PID控制器 测试轨迹 源码链接 本文对经典PID控制器的改进和开环控制机制的发展进行了讨论&#xff0c;以提高差动轮式机器人的稳定性和鲁棒性。为了部署该算法&am…

【DP】动态规划基本解题步骤(求解台阶问题)

dp数组的定义和下标递推公式dp数组如何初始化&#xff0c;初始化也需要注意遍历顺序打印dp数组&#xff08;出现问题 对于高度为 n 的台阶&#xff0c;从下往上走&#xff0c;每一步的阶数为 1&#xff0c;2&#xff0c;3 中的一个。问要走到顶部一共有多少种走法 分析&#…

python中良好的编码规范

遵循PEP 8的常见规范&#xff1a; 缩进&#xff1a; 使用4个空格来缩进代码块&#xff0c;而不是使用制表符。 命名规范&#xff1a; 变量名应该使用小写字母&#xff0c;单词之间用下划线 _ 分隔&#xff08;snake_case&#xff09;。类名应该使用驼峰命名法&#xff08;Camel…

C++ 模板知识大全

模板 泛型编程 我们如何实现一个交换函数 我们实现了两种类型的交换函数&#xff0c;但是其实除了类型不一样&#xff0c;其他地方都是一样的。 void swap(int& a, int& b) {int tmp a;a b;b tmp; }void swap(char& a, char& b) {int tmp a;a b;b tmp…

关于DCMM评估的办理条件你知道多少?

DCMM&#xff08;数据管理能力成熟度评价模型&#xff09;评估划分为五个等级&#xff0c;自低向高依次为初始级、受管理级、稳健级、量化管理级和优化级&#xff0c;不同等级代表企业数据管理和应用的成熟度水平不同&#xff0c;证书自颁发之日起有效期3年 DCMM申报基础条件 …

香港科技大学(广州)先进材料学域可持续能源与环境学域智能制造学域博士招生宣讲会——北京专场(暨全额奖学金政策)

三个学域代表教授亲临现场&#xff0c;面对面答疑解惑助攻申请&#xff01;可带简历现场咨询和面试&#xff01; &#x1f4b0;一经录取&#xff0c;享全额奖学金1.5万/月&#xff01; 报名链接&#xff1a; https://www.wjx.top/vm/wF2Mant.aspx# 地点&#xff1a;中关村皇冠…

Redis中RDB的dirty机制和AOF中的后台重写机制

RDB的dirty计数器和lastsave属性 服务器除了维护saveparams数组之外&#xff0c;还维持着一个dirty计数器,以及一个lastsave属性: 1.dirty计数器记录距离上一次成功执行SAVE命令或者BGSAVE命令之后&#xff0c;服务器对数据库状态(服务器中的所有数据库)进行了多少次修改(包括…