C语言标准库函数大全(ctype、time 、stdio、stdlib、math、string)
文章目录
- C语言函数库:
- 一. <ctype.h>
- 二. <math.h>
- 三. <stdio.h>
- 四. <stdlib.h>
- 五. <time.h>
- 六. <string.h>
- 文档资料
C语言函数库:
C语言的常用的标准头文件有 :
<ctype.h> <time.h> <stdio.h>
<stdlib.h> <math.h> <string.h>
一. <ctype.h>
序号 | 函数原型 | 功能 |
---|---|---|
1 |
int iscntrl(int c)
|
判断字符c是否为控制字符。 |
2 |
int isalnum(int c)
|
判断字符c是否为字母或数字 |
3 |
int isalpha(int c)
|
判断字符c是否为英文字母 |
4 |
int isascii(int c)
|
判断字符c是否为ascii码 |
5 |
int isblank(int c)
|
判断字符c是否为TAB或空格 |
6 |
int isdigit(int c)
|
判断字符c是否为数字 |
7 |
int isgraph(int c)
|
判断字符c是否为除空格外的可打印字符 |
8 |
int islower(int c)
|
判断字符c是否为小写英文字母 |
9 |
int isprint(int c)
|
判断字符c是否为可打印字符(含空格) |
10 |
int ispunct(int c)
|
判断字符c是否为标点符号 |
11 |
int isspace(int c)
|
判断字符c是否为空白符 |
12 |
int isupper(int c)
|
判断字符c是否为大写英文字母 |
13 |
int isxdigit(int c)
|
判断字符c是否为十六进制数字 |
14 |
int toascii(int c)
|
将字符c转换为ascii码 |
15 |
int tolower(int c)
|
将字符c转换为小写英文字母 |
16 |
int toupper(int c);
|
将字符c转换为大写英文字母 |
二. <math.h>
序号 | 函数原型 | 功能 |
---|---|---|
1 |
float fabs(float x)
|
求浮点数x的绝对值 |
2 |
int abs(int x)
|
求整数x的绝对值 |
3 |
float acos(float x)
|
求x(弧度表示)的反余弦值 |
4 |
float asin(float x)
|
求x(弧度表示)的反正弦值 |
5 |
float atan(float x)
|
求x(弧度表示)的反正切值 |
6 |
float atan2(float y, float x)
|
求y/x(弧度表示)的反正切值 |
7 |
float ceil(float x)
|
求不小于x的最小整数 |
8 |
float cos(float x)
|
求x(弧度表示)的余弦值 |
9 |
float cosh(float x)
|
求x的双曲余弦值 |
10 |
float exp(float x)
|
求e的x次幂 |
11 |
float floor(float x)
|
求不大于x的最大整数 |
12 |
float fmod(float x, float y)
|
计算x/y的余数 |
13 |
float frexp(float x, int *exp)
|
把浮点数x分解成尾数和指数 |
14 |
float ldexp(float x, int exp)
|
返回x*2^exp的值 |
15 |
float modf(float num, float *i)
|
将浮点数num分解成整数部分和小数部分 |
16 |
float hypot(float x, float y)
|
对于给定的直角三角形的两个直角边,求其斜边的长度 |
17 |
float log(float x)
|
计算x的自然对数 |
18 |
float log10(float x)
|
计算x的常用对数 |
19 |
float pow(float x, float y)
|
计算x的y次幂 |
20 |
float pow10(float x)
|
计算10的x次幂 |
21 |
float sin(float x)
|
计算x(弧度表示)的正弦值 |
22 |
float sinh(float x)
|
计算x(弧度表示)的双曲正弦值 |
23 |
float sqrt(float x)
|
计算x的平方根 |
24 |
float tan(float x);
|
计算x(弧度表示)的正切值 |
25 |
float tanh(float x)
|
求x的双曲正切值 |
三. <stdio.h>
序号 | 函数原型 | 功能 |
---|---|---|
1 |
int printf(char *format...)
|
产生格式化输出的函数 |
2 |
int getchar(void)
|
从键盘上读取一个键,并返回该键的键值 |
3 |
int putchar(char c)
|
在屏幕上显示字符c |
4 |
FILE *fopen(char *filename, char *type)
|
打开一个文件 |
5 |
FILE *freopen(char *filename, char *type,FILE *fp)
|
打开一个文件,并将该文件关联到fp指定的流 |
6 |
int fflush(FILE *stream)
|
清除一个流 |
7 |
int fclose(FILE *stream)
|
关闭一个文件 |
8 |
int remove(char *filename)
|
删除一个文件 |
9 |
int rename(char *oldname, char *newname)
|
重命名文件 |
10 |
FILE *tmpfile(void)
|
以二进制方式打开暂存文件 |
11 |
char *tmpnam(char *sptr)
|
创建一个唯一的文件名 |
12 |
int setvbuf(FILE *stream, char *buf, int type, unsigned size)
|
把缓冲区与流相关 |
13 |
int fprintf(FILE *stream, char *format[, argument,...])
|
传送格式化输出到一个流中 |
14 |
int scanf(char *format[,argument,...])
|
执行格式化输入 |
15 |
int fscanf(FILE *stream, char *format[,argument...])
|
从一个流中执行格式化输入 |
16 |
int fgetc(FILE *stream)
|
从流中读取字符 |
17 |
char *fgets(char *string, int n, FILE *stream)
|
从流中读取一字符串 |
18 |
int fputc(int ch, FILE *stream)
|
送一个字符到一个流中 |
19 |
int fputs(char *string, FILE *stream)
|
送一个字符到一个流中 |
20 |
int getc(FILE *stream)
|
从流中取字符 |
21 |
int getchar(void)
|
从 stdin 流中读字符 |
22 |
char *gets(char *string)
|
从流中取一字符串 |
23 |
int putchar(int ch)
|
在 stdout 上输出字符 |
24 |
int puts(char *string)
|
送一字符串到流中 |
25 |
int ungetc(char c, FILE *stream)
|
把一个字符退回到输入流中 |
26 |
int fread(void *ptr, int size, int nitems, FILE *stream)
|
从一个流中读数据 |
27 |
int fwrite(void *ptr, int size, int nitems, FILE *stream)
|
写内容到流中 int fseek |
28 |
(FILE *stream, long offset, int fromwhere)
|
重定位流上的文件指针 |
29 |
long ftell(FILE *stream)
|
返回当前文件指针 |
30 |
int rewind(FILE *stream)
|
将文件指针重新指向一个流的开头 |
31 |
int fgetpos(FILE *stream)
|
取得当前文件的句柄 |
32 |
int fsetpos(FILE *stream, const fpos_t *pos)
|
定位流上的文件指针 |
33 |
void clearerr(FILE *stream)
|
复位错误标志 |
34 |
int feof(FILE *stream)
|
检测流上的文件结束符 |
35 |
int ferror(FILE *stream)
|
检测流上的错误 |
36 |
void perror(char *string)
|
系统错误信息 |
四. <stdlib.h>
序号 | 函数原型 | 功能 |
---|---|---|
1 |
char *itoa(int i)
|
把整数i转换成字符串 |
2 |
void exit(int retval)
|
结束程序 |
3 |
double atof(const char *s)
|
将字符串s转换为double类型 |
4 |
int atoi(const char *s)
|
将字符串s转换为int类型 |
5 |
long atol(const char *s)
|
将字符串s转换为long类型 |
6 |
double strtod (const char*s,char **endp)
|
将字符串s前缀转换为double型 |
7 |
long strtol(const char*s,char **endp,int base)
|
将字符串s前缀转换为long型 |
8 |
unsinged long strtol(const char*s,char **endp,int base)
|
将字符串s前缀转换为 unsinged long型 |
9 |
int rand(void)
|
产生一个0~RAND_MAX之间的伪随机数 |
10 |
void srand(unsigned int seed)
|
初始化随机数发生器 |
11 |
void *calloc(size_t nelem, size_t elsize)
|
分配主存储器 |
12 |
void *malloc(unsigned size)
|
内存分配函数 |
13 |
void *realloc(void *ptr, unsigned newsize)
|
重新分配主存 |
14 |
void free(void *ptr)
|
释放已分配的块 |
15 |
void abort(void)
|
异常终止一个进程 |
16 |
void exit(int status)
|
终止应用程序 |
17 |
int atexit(atexit_t func)
|
注册终止函数 |
18 |
char *getenv(char *envvar)
|
从环境中取字符串 |
19 |
void *bsearch(const void *key, const void *base, size_t *nelem, size_t width, int(*fcmp)(const void *, const *))
|
二分法搜索函数 |
20 |
void qsort(void *base, int nelem, int width, int (*fcmp)())
|
使用快速排序例程进行排序 |
21 |
int abs(int i)
|
求整数的绝对值 |
22 |
long labs(long n)
|
取长整型绝对值 |
23 |
div_t div(int number, int denom)
|
将两个整数相除 , 返回商和余数 |
24 |
ldiv_t ldiv(long lnumer, long ldenom)
|
两个长整型数相除 , 返回商和余数 |
五. <time.h>
序号 | 函数原型 | 功能 |
---|---|---|
1 |
clock_t clock(void)
|
确定处理器时间函数 |
2 |
time_t time(time_t *tp)
|
返回当前日历时间 |
3 |
double difftime(time_t time2, time_t time1)
|
计算两个时刻之间的时间差 |
4 |
time_t mktime(struct tm *tp)
|
将分段时间值转换为日历时间值 |
5 |
char *asctime(const struct tm *tblock)
|
转换日期和时间为ASCII码 |
6 |
char *ctime(const time_t *time)
|
把日期和时间转换为字符串 |
7 |
struct tm *gmtime(const time_t *timer)
|
把日期和时间转换为格林尼治标准时间 |
8 |
struct tm *localtime(const time_t *timer)
|
把日期和时间转变为结构 |
9 |
size_t strftime(char *s,size_t smax,const char *fmt, const struct tm *tp)
|
根据 fmt 的格式 要求将 *tp中的日期与时间转换为指定格式 |
六. <string.h>
序号 | 函数原型 | 功能 |
---|---|---|
1 |
int bcmp(const void *s1, const void *s2, int n)
|
比较字符串s1和s2的前n个字节是否相等 |
2 |
void bcopy(const void *src, void *dest, int n)
|
将字符串src的前n个字节复制到dest中 |
3 |
void bzero(void *s, int n)
|
置字节字符串s的前n个字节为零 |
4 |
void *memccpy(void *dest, void *src, unsigned char ch, unsigned int count)
|
由src所指内存区域复制不多于count个字节到dest所指内存区域,如果遇到字符ch则停止复制 |
5 |
void *memcpy(void *dest, void *src, unsigned int count)
|
由src所指内存区域复制count个字节到dest所指内存区域 |
6 |
void *memchr(void *buf, char ch, unsigned count)
|
从buf所指内存区域的前count个字节查找字符ch |
7 |
int memcmp(void *buf1, void *buf2, unsigned int count)
|
比较内存区域buf1和buf2的前count个字节 |
8 |
int memicmp(void *buf1, void *buf2, unsigned int count)
|
比较内存区域buf1和buf2的前count个字节但不区分字母的大小写 |
9 |
void *memmove(void *dest, const void *src, unsigned int count)
|
由src所指内存区域复制count个字节到dest所指内存区域 |
10 |
void *memset(void *buffer, int c, int count)
|
把buffer所指内存区域的前count个字节设置成字符c |
11 |
void setmem(void *buf, unsigned int count, char ch)
|
把buf所指内存区域前count个字节设置成字符ch |
12 |
void movmem(void *src, void *dest, unsigned int count)
|
由src所指内存区域复制count个字节到dest所指内存区域 |
13 |
char *stpcpy(char *dest,char *src)
|
把src所指由NULL结束的字符串复制到dest所指的数组中 |
14 |
char *strcpy(char *dest,char *src)
|
把src所指由NULL结束的字符串复制到dest所指的数组中 |
15 |
char *strcat(char *dest,char *src)
|
把src所指字符串添加到dest结尾处(覆盖dest结尾处的’\0’)并添加’\0’ |
16 |
char *strchr(char *s,char c)
|
查找字符串s中首次出现字符c的位置 |
17 |
int strcmp(char *s1,char * s2)
|
比较字符串s1和s2 |
18 |
int stricmp(char *s1,char * s2)
|
比较字符串s1和s2,但不区分字母的大小写 |
19 |
int stricmp(char *s1,char * s2)
|
比较字符串s1和s2,但不区分字母的大小写 |
20 |
int strcspn(char *s1,char *s2)
|
在字符串s1中搜寻s2中所出现的字符 |
21 |
char *strdup(char *s)
|
复制字符串s |
22 |
int strlen(char *s)
|
计算字符串s的长度 |
23 |
char *strlwr(char *s)
|
将字符串s转换为小写形式 |
24 |
char *strupr(char *s)
|
将字符串s转换为大写形式 |
25 |
char *strncat(char *dest,char *src,int n)
|
把src所指字符串的前n个字符添加到dest结尾处(覆盖dest结尾处的’\0’)并添加’\0’ |
26 |
int strcmp(char *s1,char * s2,int n)
|
比较字符串s1和s2的前n个字符 |
27 |
int strnicmp(char *s1,char * s2,int n)
|
比较字符串s1和s2的前n个字符但不区分大小写 |
28 |
char *strncpy(char *dest, char *src, int n)
|
把src所指由NULL结束的字符串的前n个字节复制到dest所指的数组中 |
29 |
char *strpbrk(char *s1, char *s2)
|
在字符串s1中寻找字符串s2中任何一个字符相匹配的第一个字符的位置,空字符NULL不包括在内 |
30 |
char *strrev(char *s)
|
把字符串s的所有字符的顺序颠倒过来(不包括空字符NULL) |
31 |
char *strset(char *s, char c)
|
把字符串s中的所有字符都设置成字符c |
32 |
char *strstr(char *haystack, char *needle)
|
从字符串haystack中寻找needle第一次出现的位置(不比较结束符NULL) |
33 |
char *strtok(char *s, char *delim)
|
分解字符串为一组标记串。s为要分解的字符串,delim为分隔符字符串 |
34 |
int strnicmp(char *s1,char * s2,int n)
|
比较字符串s1和s2的前n个字符但不区分大小写 |
文档资料
上面只是简单的介绍函数原型和功能,如果想对函数进一步了解可以下载以下文档 (内含详解与实例):
1. C语言标准函数库速查手册.chm
2. C语言标准函数库详解.pdf
C语言标准库函数大全(ctype、time 、stdio、stdlib、math、string)相关推荐
- c语言函数大全 pdf,C语言标准库函数大全.pdf
Page 1 of 22 Arther's Blog 准备是成功的首要前提 博客园 社区 首页 新随笔 联系 管理 订阅 随笔- 208 文章- 0 评论- 14 c语言库函数大全--资料收集 与我联 ...
- c语言标准库函数大全.chm,C语言标准库函数(word版).doc
标准库函数 exit itoa exit 原型:extern void exit(int retval); 用法:#include 功能:结束程序 说明:返回值将被忽略 举例: // exit.c # ...
- 语言库函数大全--资料收集整理
语言库函数大全–资料收集 Turbo C 2.0 函数中文说明大全 分类函数,所在函数库为ctype.h int isalpha(int ch) 若ch是字母('A'-'Z','a'-'z')返回非0 ...
- C语言标准库函数qsort( )——数据排序
大家好!我是保护小周ღ,本期为大家带来的是深度解剖C语言标准库函数 qsort(),qsort()函数他可以对任意类型的数据排序,博主会详细解释函数使用方法,以及使用快速排序的左右指针法模拟实现函数功 ...
- C语言库函数大全及应用实例四
[编程资料]C语言库函数大全及应用实例四 couble fmod (double x, double y);<?xml:nam ...
- C语言库函数大全及应用实例三
[编程资料]C语言库函数大全及应用实例三 函数名: ecvt 功 能: 把一个浮点数转换为字符串 用 法: char ecvt(double value, int ndigit, int *decpt ...
- c语言资料大全收集,C语言库函数大全(收集资料).pdf
Page 1 of 22 Arther's Blog 准备是成功的首要前提 博客园 社区 首页 新随笔 联系 管理 订阅 随笔- 208 文章- 0 评论- 14 c语言库函数大全--资料收集 与我联 ...
- 常用ANSI C语言标准库函数汇总(一)
常用ANSI C语言标准库函数汇总(一) C语言被发明出来时并没有什么库函数,随着C语言的流行,越来越多的厂商和组织开始提供C语言的编译器,同时把经常用到的函数封装成"库"的形式发 ...
- c语言库函数大全pdf 百度云,c 语言库函数大全
c 语言库函数大全 int isalpha(int ch) ch(A-Z,a-z)0,0 int isalnum(int ch) ch(A-Z,a-z)(0-9) 0,0 int isascii(in ...
- C语言库函数大全及应用实例二
[编程资料]C语言库函数大全及应用实例二 函数名: bioskey 功 能: 直接使用BIOS服务的键盘接口 ...
最新文章
- 多人在线游戏服务器端开发心得(转)
- opencv dnn 人脸 年龄
- NYOJ 84 阶乘的0 数论
- Netflix测试有线电视频道、字节11亿入股掌阅、快手香港IPO、王者荣耀日活破一亿等|Decode the Week...
- 十条实用的jQuery代码片段
- 线段树hdu1754
- 英语口语-文章朗读Week9Thursday
- Python版插入排序算法
- 在国企工作30年,单位现在协商买断工龄,3000/年该走吗?
- 【f1c200s/f1c100s】屏幕背光驱动适配
- Windows 远程桌面连接命令
- 算法——最短路径应用
- Pyecharts+高德地图实现3D地图效果
- 嵌入式数据库和数据库服务器的区别
- 总账科目往来批量导入程序
- 电信天翼物联网平台对接应用服务ctWing
- 运动控制屏蔽回原点屏蔽z_index是什么_安卓智能手表它不香吗,为什么要花 3199 买 Apple Watch?...
- 【其他】记录这次曲折的域名选择及搜索引擎seo优化的过程
- 解决电脑不能进入BIOS页面
- echarts 渲染3d地图
热门文章
- 我的世界服务器物品图标闪,我的世界中国版用资源包修改闪烁标的方法分享
- PTA程序设计综合实践1.10
- 解析搜狗等输入法右下角图标显示中英问题
- VB语言实现Http的Post和Get请求
- java基础选择题及答案_100道Java基础面试题收集整理(附答案)
- 挂载Linux镜像文件,使用镜像文件安装依赖
- ZK(1)——分布式系统概念与ZK简介
- python实用小工具之一:BMFont位图导出脚本
- VS中Windows界面开发
- wincc版本升级_【西门子】WinCC V7.4 SP1:常规信息和安装 (较新).pdf