归纳整理Linux下C语言常用的库函数----字符串转换、字符测试、及内存控制

2023-10-15,,

在没有IDE的时候,记住一些常用的库函数的函数名、参数、基本用法及注意事项是很有必要的。

参照Linux_C_HS.chm的目录,我大致将常用的函数分为一下几类:

1. 内存及字符串控制及操作
2. 字符串转换
3. 字符测试
4. 文件操作
5. 时间日期
6. 常用数学函数
7. 文件内容操作
8. 文件权限控制
9. 进程操作
10. 线程操作
11. Socket操作
12. 信号处理
13. 数据结构及算法


字符串转换归类

*           函数名称                                用法                            备注
*
*. double atof(const char *nptr); convert a string to a double 不检查错误,不对就返回0
*
*. int atoi(const char *nptr); convert a string to an integer UP
*
*. long long atoll(const char *nptr); UP UP
*
*. float strtof(const char *nptr, char **endptr); UP If endptr is not NULL, a pointer to the character after the last character used in the conversion is stored in the location referenced by
endptr.
*
*. int toascii(int c); convert character to ASCII The value returned is that of the converted character.
*
*. int toupper(int c); convert letter to upper or lower case The value returned is that of the converted letter, or c if the conversion was not possible.
*
*. int tolower(int c); UP UP
*
*. char *gcvt(double number, size_t ndigit, char *buf); convert a floating-point returns the address of the string pointed to by buf.

字符串测试归类

*           函数名称                                用法                                备注
*
*. int isalnum(int c); 是否是英文或者数字 正确返回1,错误返回0
*
*. int isalpha(int c); 是否是英文字母 UP
*
*. int isascii(int c); 是否是ASCII 码 UP
*
*. int isblank(int c); a space or a tab NT
*
*. int isgraph(int c); 可打印字符,不包括空格 NT
*
*. int iscntrl(int c); NT NT
*
*. int isdigit(int c); NT NT
*
*. int isprint(int c); 可打印字符,包括空格 NT
*
*. int ispunct(int c); 标点符号或特殊字符 NT
*
*. int isspace(int c); space, form-feed ('\f'), NT
newline ('\n'), carriage
return ('\r'), horizontal tab
('\t'), and vertical tab ('\v').
*
*. int isupper(int c); NT NT
*
*. int isxdigit(int c); 十六进制 NT
*

内存控制类归纳

*       函数名称                                    用法                                    备注
*
*. void *malloc(size_t size); NT 默认不初始化
*
*. void *calloc(size_t nmemb, size_t size); 申请size个nmemb大小的空间 默认初始为0
*
*. void *realloc(void *ptr, size_t size); 扩展内存区域 新扩展的部分默认不初始化
*
*. void free(void *ptr); 释放内存区域 NT

如上,是对字符串转换、字符串测试及内存控制归纳。

归纳整理Linux下C语言常用的库函数----字符串转换、字符测试、及内存控制的相关教程结束。

《归纳整理Linux下C语言常用的库函数----字符串转换、字符测试、及内存控制.doc》

下载本文的Word格式文档,以方便收藏与打印。