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个字节是否相等 |
收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人
都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!