C语言常用的库函数.docVIP

  • 5
  • 0
  • 约8.25千字
  • 约 8页
  • 2016-08-21 发布于湖北
  • 举报
C语言常用的库函数

库函数并不是C语言的一部分,它是由编译系统根据一般用户的需要编制并提供给用户使用的一组程序。每一种C编译系统都提供了一批库函数,不同的编译系统所提供的库函数的数目和函数名以及函数功能是不完全相同的。ANSI C标准提出了一批建议提供的标准库函数。它包括了目前多数C编译系统所提供的库函数,但也有一些是某些C编译系统未曾实现的。考虑到通用性,本附录列出ANSI C建议的常用库函数。 由于C库函数的种类和数目很多,例如还有屏幕和图形函数、时间日期函数、与系统有关的函数等,每一类函数又包括各种功能的函数,限于篇幅,本附录不能全部介绍,只从教学需要的角度列出最基本的。读者在编写C程序时可根据需要,查阅有关系统的函数使用手册。 1.数学函数 使用数学函数时,应该在源文件中使用预编译命令: #includemath.h或#include math.h 函数名 函数原型 功能 返回值 acos double acos(double x); 计算arccos x的值,其中-1=x=1 计算结果 asin double asin(double x); 计算arcsin x的值,其中-1=x=1 计算结果 atan double atan(double x); 计算arctan x的值 计算结果 atan2 double atan2(double x, double y); 计算arctan x/y的值 计算结果 cos double cos(double x); 计算cos x的值,其中x的单位为弧度 计算结果 cosh double cosh(double x); 计算x的双曲余弦cosh x的值 计算结果 exp double exp(double x); 求ex的值 计算结果 fabs double fabs(double x); 求x的绝对值 计算结果 floor double floor(double x); 求出不大于x的最大整数 该整数的双精度实数 fmod double fmod(double x, double y); 求整除x/y的余数 返回余数的双精度实数 frexp double frexp(double val, int *eptr); 把双精度数val分解成数字部分(尾数)和以2为底的指数,即val=x*2n,n存放在eptr指向的变量中 数字部分x 0.5=x1 log double log(double x); 求lnx的值 计算结果 log10 double log10(double x); 求log10x的值 计算结果 modf double modf(double val, int *iptr); 把双精度数val分解成数字部分和小数部分,把整数部分存放在ptr指向的变量中 val的小数部分 pow double pow(double x, double y); 求xy的值 计算结果 sin double sin(double x); 求sin x的值,其中x的单位为弧度 计算结果 sinh double sinh(double x); 计算x的双曲正弦函数sinh x的值 计算结果 sqrt double sqrt (double x); 计算,其中x≥0 计算结果 tan double tan(double x); 计算tan x的值,其中x的单位为弧度 计算结果 tanh double tanh(double x); 计算x的双曲正切函数tanh x的值 计算结果 2.字符函数 在使用字符函数时,应该在源文件中使用预编译命令: #includectype.h或#include ctype.h 函数名 函数原型 功能 返回值 isalnum int isalnum(int ch); 检查ch是否字母或数字 是字母或数字返回1,否则返回0 isalpha int isalpha(int ch); 检查ch是否字母 是字母返回1,否则返回0 iscntrl int iscntrl(int ch); 检查ch是否控制字符(其ASCII码在0和0xlF之间) 是控制字符返回1,否则返回0 isdigit int isdigit(int ch); 检查ch是否数字 是数字返回1,否则返回0 isgraph int isgraph(int ch); 检查ch是否是可打印字符(其ASCII码在0x21和0x7e之间),不包括空格 是可打印字符返回1,否则返回0 islower int islower(int ch); 检查ch是否是小写字母(a~z) 是小字母返回1,否则返回0 isprint int isprint(int ch); 检查ch是否是可打印字符(其

文档评论(0)

1亿VIP精品文档

相关文档