❶ c语言中各种函数的具体作用,要详细点的
字符处理函数
本类别函数用于对单个字符进行处理,包括字符的类别测试和字符的大小写转换
头文件 ctype.h
函数列表<>
函数类别 函数用途 详细说明
字符测试 是否字母和数字 isalnum
是否字母 isalpha
是否控制字符 iscntrl
是否数字 isdigit
是否可显示字符(除空格外) isgraph
是否可显示字符(包括空格) isprint
是否既不是空格,又不是字母和数字的可显示字符 ispunct
是否空格 isspace
是否大写字母 isupper
是否16进制数字(0-9,A-F)字符 isxdigit
字符大小写转换函数 转换为大写字母 toupper
转换为小写字母 tolower
地区化
本类别的函数用于处理不同国家的语言差异。
头文件 local.h
函数列表
函数类别 函数用途 详细说明
地区控制 地区设置 setlocale
数字格式约定查询 国家的货币、日期、时间等的格式转换 localeconv
数学函数
本分类给出了各种数学计算函数,必须提醒的是ANSI C标准中的数据格式并不符合IEEE754标准,一些C语言编译器却遵循IEEE754(例如frinklin C51)
头文件 math.h
函数列表
函数类别 函数用途 详细说明
错误条件处理 定义域错误(函数的输入参数值不在规定的范围内)
值域错误(函数的返回值不在规定的范围内)
三角函数 反余弦 acos
反正弦 asin
反正切 atan
反正切2 atan2
余弦 cos
正弦 sin
正切 tan
双曲函数 双曲余弦 cosh
双曲正弦 sinh
双曲正切 tanh
指数和对数 指数函数 exp
指数分解函数 frexp
乘积指数函数 fdexp
自然对数 log
以10为底的对数 log10
浮点数分解函数 modf
幂函数 幂函数 pow
平方根函数 sqrt
整数截断,绝对值和求余数函数 求下限接近整数 ceil
绝对值 fabs
求上限接近整数 floor
求余数 fmod
本分类函数用于实现在不同底函数之间直接跳转代码。 头文件 setjmp.h io.h
函数列表
函数类别 函数用途 详细说明
保存调用环境 setjmp
恢复调用环境 longjmp
信号处理
该分类函数用于处理那些在程序执行过程中发生例外的情况。
头文件 signal.h
函数列表
函数类别 函数用途 详细说明
指定信号处理函数 signal
发送信号 raise
可变参数处理
本类函数用于实现诸如printf,scanf等参数数量可变底函数。
头文件 stdarg.h
函数列表
函数类别 函数用途 详细说明
可变参数访问宏 可变参数开始宏 va_start
可变参数结束宏 va_end
可变参数访问宏 访问下一个可变参数宏 va_arg
输入输出函数
该分类用于处理包括文件、控制台等各种输入输出设备,各种函数以“流”的方式实现
头文件 stdio.h
函数列表
函数类别 函数用途 详细说明
文件操作
删除文件 remove
修改文件名称 rename
生成临时文件名称 tmpfile
得到临时文件路径 tmpnam
文件访问 关闭文件 fclose
刷新缓冲区 fflush
打开文件 fopen
将已存在的流指针和新文件连接 freopen
设置磁盘缓冲区 setbuf
设置磁盘缓冲区 setvbuf
格式化输入与输出函数 格式输出 fprintf
格式输入 fscanf
格式输出(控制台) printf
格式输入(控制台) scanf
格式输出到缓冲区 sprintf
从缓冲区中按格式输入 sscanf
格式化输出 vfprintf
格式化输出 vprintf
格式化输出 vsprintf
字符输入输出函数 输入一个字符 fgetc
字符串输入 fgets
字符输出 fputc
字符串输出 fputs
字符输入(控制台) getc
字符输入(控制台) getchar
字符串输入(控制台) gets
字符输出(控制台) putc
字符输出(控制台) putchar
字符串输出(控制台) puts
字符输出到流的头部 ungetc
直接输入输出 直接流读操作 fread
直接流写操作 fwrite
文件定位函数 得到文件位置 fgetpos
文件位置移动 fseek
文件位置设置 fsetpos
得到文件位置 ftell
文件位置复零位 remind
错误处理函数 错误清除 clearerr
文件结尾判断 feof
文件错误检测 ferror
得到错误提示字符串 perror
实用工具函数
本分类给出了一些函数无法按以上分类,但又是编程所必须要的。
头文件 stdlib.h
函数列表
函数类别 函数用途 详细说明
字符串转换函数 字符串转换为整数 atoi
字符串转换为长整数 atol
字符串转换为浮点数 strtod
字符串转换为长整数 strtol
字符串转换为无符号长整型 strtoul
伪随机序列产生函数 产生随机数 rand
设置随机函数的起动数值 srand
存储管理函数 分配存储器 calloc
释放存储器 free
存储器分配 malloc
重新分配存储器 realloc
环境通信 中止程序 abort
退出程序执行,并清除环境变量 atexit
退出程序执行 exit
读取环境参数 getenv
程序挂起,临时执行一个其他程序 system
搜索和排序工具 二分查找(数据必须已排序) bsearch
快速排序 qsort
整数运算函数 求绝对值 abs
div
得到除法运算底商和余数
求长整形底绝对值 labs
求长整形除法的商和余数 ldiv
多字节字符函数 得到多字节字符的字节数 mblen
得到多字节字符的字节数 mbtowc
多字节字符转换 wctomb
多字节字符的字符串操作 将多字节串转换为整数数组 mbstowcs
将多字节串转换为字符数组 mcstowbs
字符串处理
本分类的函数用于对字符串进行合并、比较等操作
头文件 string.h
函数列表
函数类别 函数用途 详细说明
字符串拷贝 块拷贝(目的和源存储区不可重叠) memcpy
块拷贝(目的和源存储区可重叠) memmove
串拷贝 strcpy
按长度的串拷贝 strncpy
字符串连接函数 串连接 strcat
按长度连接字符串 strncat
串比较函数 块比较 memcmp
字符串比较 strcmp
字符串比较(用于非英文字符) strcoll
按长度对字符串比较 strncmp
字符串转换 strxfrm
字符与字符串查找 字符查找 memchr
字符查找 strchr
字符串查找 strcspn
字符串查找 strpbrk
字符串查找 strspn
字符串查找 strstr
字符串分解 strtok
杂类函数 字符串设置 memset
错误字符串映射 strerror
求字符串长度 strlen
日期和时间函数
本类别给出时间和日期处理函数
头文件 time.h
函数列表
函数类别 函数用途 详细说明
时间操作函数 得到处理器时间 clock
得到时间差 difftime
设置时间 mktime
得到时间 time
时间转换函数 得到以ASCII码表示的时间 asctime
得到字符串表示的时间 ctime
得到指定格式的时间 strftime
函数库未来的发展方向
本部分用于说明各类别函数库在将来如何发展。
序号 库类别 头文件 详细说明
1 错误处理 errno.h
2 字符处理 ctype.h
3 地区化 local.h
4 数学函数 math.h
5 信号处理 signal.h
6 输入输出 stdio.h
7 实用工具程序 stdlib.h
8 字符串处理 string.h
❷ “cosh”是什么意思
“cosh”的意思:短棒,双曲余弦,用短棍打
1、读音:英[kɒʃ] 美[kɑːʃ]
2、例句:The sinh,cosh,andtanhfunctionsalsoall appearinvariouscalculationsin
specialandgeneralrelativity.
双曲正弦、双曲余弦和双曲正切函数也会以常见或特殊形式出现在各种计算中。
(2)cosh在c语言中是什么函数扩展阅读:
“cosh”的近义词介绍:stub
1、读音:英[stʌb] 美[stʌb]
2、表达意思:短棒,存根,烟蒂,树桩,断株
3、相关短语:
pay stub工资单,工资存根,工资单据
check stub支票存根
4、例句:Ifthesestructureswere notdefinedthentheuseof astub wouldrequireone
oftwoscenarios.
如果这些结构不加以定义的话,存根的使用将需要一个或两个方案。
❸ c语言中cos函数的用法
cos函数的输入值为弧度,也就是将cos函数后加上弧度,然后就可以得到想要的结果。我们需要把度化为弧度:
假设度数为d,则对应的弧度为:d * pi / 180
❹ C语言题目。输入一个不多于4位的正整数,求它的位数,并按逆序输出各位数字。
#include<stdio.h>
intmain()
{
chardigtal[20];
intcount=0;
inti;
intnum;
scanf("%d",&num);
while(num)
{
digtal[count]=num%10;
num/=10;
count++;
}
printf("输入%d,共%d位 ",num,count);
for(i=count-1;i>=0;i--)
printf("%d",digtal[i]);
return0;
}
❺ C语言中的标准函数有哪些
C语言输入输出函数有很多,标准I/O函数中包含了如下几个常用的函数:
scanf,printf,getc,putc,getchar,putchar,gets,puts,fgets,fputs,fgetc,fputc,fscanf,fprintf等.
int
getc(FILE
*fp)
getc主要是从文件中读出一个字符.常用的判断文件是否读取结束的语句为
(ch
=
getc(fp))
!=
EOF.EOF为文件结束标志,定义在stdio.h中,就像EXIT_SUCCESS,EXIT_FAILURE定义在stdlib.h中一样,文件也可以被理解为一种流,所以当fp为stdin时,getc(stdin)就等同于getchar()了.
int
putc(int
ch,FILE
*fp)
putc主要是把字符ch写到文件fp中去.如果fp为stdout,则putc就等同于putchar()了.
int
getchar(void)
getchar主要是从标准输入流读取一个字符.默认的标准输入流即stdio.h中定义的stdin.但是从输入流中读取字符时又涉及到缓冲的问题,所以并不是在屏幕中敲上一个字符程序就会运行,一般是通过在屏幕上敲上回车键,然后将回车前的字符串放在缓冲区中,getchar就是在缓冲区中一个一个的读字符.当然也可以在while循环中指定终止字符,如下面的语句:while
((c
=
getchar())
!=
'#')这是以#来结束的.
int
putchar(int
ch)
putchar(ch)主要是把字符ch写到标准流stdout中去.
char
*
gets(char
*str)
gets主要是从标准输入流读取字符串并回显,读到换行符时退出,并会将换行符省去.
int
puts(char
*str)
puts主要是把字符串str写到标准流stdout中去,并会在输出到最后时添加一个换行符.
char
*fgets(char
*str,
int
num,
FILE
*fp)
str是存放读入的字符数组指针,num是最大允许的读入字符数,fp是文件指针.fgets的功能是读一行字符,该行的字符数不大于num-1.因为fgets函数会在末尾加上一个空字符以构成一个字符串.另外fgets在读取到换行符后不会将其省略.
int
fputs(char
*str,
file
*fp)
fputs将str写入fp.fputs与puts的不同之处是fputs在打印时并不添加换行符.
int
fgetc(FILE
*fp)
fgetc从fp的当前位置读取一个字符.
int
fputc(int
ch,
file
*fp)
fputc是将ch写入fp当前指定位置.
int
fscanf(FILE
*fp,
char
*format,
输入列表)
fscanf按照指定格式从文件中出读出数据,并赋值到参数列表中.
int
fprintf(FILE
*fp,
char
*format,
输出列表)
fprintf将格式化数据写入流式文件中.
数据块读写函数
fread
(buffer,size,count,fp);
fwrite(buffer,size,count,fp);
参数说明:
buffer:是一个指针。
对fread
来说,它是读入数据的存放地址。
对fwrite来说,是要输出数据的地址(均指起始地址)。
size:
要读写的字节数。
count:
要进行读写多少个size字节的数据项。
fp:
文件型指针。
❻ 在C语言中有那些函数名
仅仅为了获取函数名,就在函数体中嵌入硬编码的字符串,这种方法单调乏味还易导致错误,不如看一下怎样使用新的C99特性,在程序运行时获取函数名吧.对象反射库、调试工具及代码分析器,经常会需要在运行时访问函数的名称,直到不久前,唯一能完成此项任务并且可移植的方法,是手工在函数体内嵌入一个带有该函数名的硬编码字符串,不必说,这种方法非常单调无奇,并且容易导致错误。本文将要演示怎样使用新的C99特性,在运行时获取函数名。
那么怎样以编程的方式从当前运行的函数中得到函数名呢?
答案是:使用__FUNCTION__ 及相关宏。
引出问题
通常,在调试中最让人心烦的阶段,是不断地检查是否已调用了特定的函数。对此问题的解决方法,一般是添加一个cout或printf()——如果你使用C语言,如下所示:
void myfunc()
{
cout<<"myfunc()"<<endl;
//其他代码
}
通常在一个典型的工程中,会包含有数千个函数,要在每个函数中都加入一条这样的输出语句,无疑难过上“蜀山”啊,因此,需要有一种机制,可以自动地完成这项操作。
获取函数名
作为一个C++程序员,可能经常遇到 __TIME__、__FILE__、__DATE__ 这样的宏,它们会在编译时,分别转换为包含编译时间、处理的转换单元名称及当前时间的字符串。
在最新的ISO C标准中,如大家所知的C99,加入了另一个有用的、类似宏的表达式__func__,其会报告未修饰过的(也就是未裁剪过的)、正在被访问的函数名。请注意,__func__不是一个宏,因为预处理器对此函数一无所知;相反,它是作为一个隐式声明的常量字符数组实现的:
static const char __func__[] = "function-name";
在function-name处,为实际的函数名。为激活此特性,某些编译器需要使用特定的编译标志,请查看相应的编译器文档,以获取具体的资料。
有了它,我们可免去大多数通过手工修改,来显示函数名的苦差事,以上的例子可如下所示进行重写:
void myfunc()
{
cout<<"__FUNCTION__"<<endl;
}
官方C99标准为此目的定义的__func__标识符,确实值得大家关注,然而,ISO C++却不完全支持所有的C99扩展,因此,大多数的编译器提供商都使用 __FUNCTION__ 取而代之,而 __FUNCTION__ 通常是一个定义为 __func__ 的宏,之所以使用这个名字,是因为它已受到了大多数的广泛支持。
在Visual Studio 2005中,默认情况下,此特性是激活的,但不能与/EP和/P编译选项同时使用。请注意在IDE环境中,不能识别__func__ ,而要用__FUNCTION__ 代替。
Comeau的用户也应使用 __FUNCTION__ ,而不是 __func__ 。
C++ BuilderX的用户则应使用稍稍不同的名字:__FUNC__ 。
GCC 3.0及更高的版本同时支持 __func__ 和__FUNCTION__ 。
一旦可自动获取当前函数名,你可以定义一个如下所示显示任何函数名的函数:
void show_name(const char * name)
{
cout<<name<<endl;
}
void myfunc()
{
show_name(__FUNCTION__); //输出:myfunc
}
void foo()
{
show_name(__FUNCTION__); //输出:foo
}
因为 __FUNCTION__ 会在函数大括号开始之后就立即初始化,所以,foo()及myfunc()函数可在参数列表中安全地使用它,而不用担心重载。
签名与修饰名
__FUNCTION__ 特性最初是为C语言设计的,然而,C++程序员也会经常需要有关他们函数的额外信息,在Visual Studio 2005中,还支持另外两种非标准的扩展特性:__FUNCDNAME__ 与 __FUNCSIG__ ,其分别转译为一个函数的修饰名与签名。函数的修饰名非常有用,例如,在你想要检查两个编译器是否共享同样的ABI时,就可派得上用场,另外,它还能帮助你破解那些含义模糊的链接错误,甚至还可用它从一个DLL中调用另一个用C++链接的函数。在下例中,show_name()报告了函数的修饰名:
void myfunc()
{
show_name(__FUNCDNAME__); //输出:?myfunc@@YAXXZ
}
一个函数的签名由函数名、参数列表、返回类型、内含的命名空间组成。如果它是一个成员函数,它的类名和const/volatile限定符也将是签名的一部分。以下的代码演示了一个独立的函数与一个const成员函数签名间的不同之处,两个函数的名称、返回类型、参数完全相同:
void myfunc()
{
show_name(__FUNCSIG__); // void __cdecl myfunc(void)
}
struct S
{
void myfunc() const
{
show_name(__FUNCSIG__); //void __thiscall S::myfunc(void) const
}
};
❼ 能不能介绍下c语言中math.h中的函数的名称和功能
abs() 好像是stdlib.h的函数吧?
math.h
The math header defines several mathematic functions.
Macros:
HUGE_VAL
Functions:
acos();
asin();
atan();
atan2();
ceil();
cos();
cosh();
exp();
fabs();
floor();
fmod();
frexp();
ldexp();
log();
log10();
modf();
pow();
sin();
sinh();
sqrt();
tan();
tanh();
2.7.1 Error Conditions
All math.h functions handle errors similarly.
In the case that the argument passed to the function exceeds the range of that function, then the variable errno is set to EDOM. The value that the function returns is implementation specific.
In the case that the value being returned is too large to be represented in a double, then the function returns the macro HUGE_VAL, and sets the variable errno to ERANGE to represent an overflow. If the value is too small to be represented in a double, then the function returns zero. In this case whether or not errno is set to ERANGE is implementation specific.
errno, EDOM, and ERANGE are defined in the errno.h header.
Note that in all cases when it is stated that there is no range limit, it is implied that the value is limited by the minimum and maximum values of type double.
2.7.2 Trigonometric Functions
2.7.2.1 acos
Declaration:
double acos(double x);
Returns the arc cosine of x in radians.
Range:
The value x must be within the range of -1 to +1 (inclusive). The returned value is in the range of 0 to pi (inclusive).
2.7.2.2 asin
Declaration:
double asin(double x);
Returns the arc sine of x in radians.
Range:
The value of x must be within the range of -1 to +1 (inclusive). The returned value is in the range of -p/2 to +p/2 (inclusive).
2.7.2.3 atan
Declaration:
double atan(double x);
Returns the arc tangent of x in radians.
Range:
The value of x has no range. The returned value is in the range of -p/2 to +p/2 (inclusive).
2.7.2.4 atan2
Declaration:
double atan2(doubly y, double x);
Returns the arc tangent in radians of y/x based on the signs of both values to determine the correct quadrant.
Range:
Both y and x cannot be zero. The returned value is in the range of -p/2 to +p/2 (inclusive).
2.7.2.5 cos
Declaration:
double cos(double x);
Returns the cosine of a radian angle x.
Range:
The value of x has no range. The returned value is in the range of -1 to +1 (inclusive).
2.7.2.6 cosh
Declaration:
double cosh(double x);
Returns the hyperbolic cosine of x.
Range:
There is no range limit on the argument or return value.
2.7.2.7 sin
Declaration:
double sin(double x);
Returns the sine of a radian angle x.
Range:
The value of x has no range. The returned value is in the range of -1 to +1 (inclusive).
2.7.2.8 sinh
Declaration:
double sinh(double x);
Returns the hyperbolic sine of x.
Range:
There is no range limit on the argument or return value.
2.7.2.9 tan
Declaration:
double tan(double x);
Returns the tangent of a radian angle x.
Range:
There is no range limit on the argument or return value.
2.7.2.10 tanh
Declaration:
double tanh(double x);
Returns the hyperbolic tangent of x.
Range:
The value of x has no range. The returned value is in the range of -1 to +1 (inclusive).
2.7.3 Exponential, Logarithmic, and Power Functions
2.7.3.1 exp
Declaration:
double exp(double x);
Returns the value of e raised to the xth power.
Range:
There is no range limit on the argument or return value.
2.7.3.2 frexp
Declaration:
double frexp(double x, int *exponent);
The floating-point number x is broken up into a mantissa and exponent.
The returned value is the mantissa and the integer pointed to by exponent is the exponent. The resultant value is x=mantissa * 2^exponent.
Range:
The mantissa is in the range of .5 (inclusive) to 1 (exclusive).
2.7.3.3 ldexp
Declaration:
double ldexp(double x, int exponent);
Returns x multiplied by 2 raised to the power of exponent.
x*2^exponent
Range:
There is no range limit on the argument or return value.
2.7.3.4 log
Declaration:
double log(double x);
Returns the natural logarithm (base-e logarithm) of x.
Range:
There is no range limit on the argument or return value.
2.7.3.5 log10
Declaration:
double log10(double x);
Returns the common logarithm (base-10 logarithm) of x.
Range:
There is no range limit on the argument or return value.
2.7.3.6 modf
Declaration:
double modf(double x, double *integer);
Breaks the floating-point number x into integer and fraction components.
The returned value is the fraction component (part after the decimal), and sets integer to the integer component.
Range:
There is no range limit on the argument or return value.
2.7.3.7 pow
Declaration:
double pow(double x, double y);
Returns x raised to the power of y.
Range:
x cannot be negative if y is a fractional value. x cannot be zero if y is less than or equal to zero.
2.7.3.8 sqrt
Declaration:
double sqrt(double x);
Returns the square root of x.
Range:
The argument cannot be negative. The returned value is always positive.
2.7.4 Other Math Functions
2.7.4.1 ceil
Declaration:
double ceil(double x);
Returns the smallest integer value greater than or equal to x.
Range:
There is no range limit on the argument or return value.
2.7.4.2 fabs
Declaration:
double fabs(double x);
Returns the absolute value of x (a negative value becomes positive, positive value is unchanged).
Range:
There is no range limit on the argument. The return value is always positive.
2.7.4.3 floor
Declaration:
double floor(double x);
Returns the largest integer value less than or equal to x.
Range:
There is no range limit on the argument or return value.
2.7.4.4 fmod
Declaration:
double fmod(double x, double y);
Returns the remainder of x divided by y.
Range:
There is no range limit on the return value. If y is zero, then either a range error will occur or the function will return zero (implementation-defined).
❽ cosh是什么函数
。。。楼主悲剧了,最佳答案都选错了,cosh是一个整体,是双曲余弦 。
参考资料是随便找的一个例子。
❾ sinh和cosh的计算公式
sinh和cosh的计算公式分别是sinh=[e^x-e^(-x)]/2和cosh=[e^x+e^(-x)]/2。在数学中,双曲函数是一类与常见的三角函数(也叫圆函数)类似的函数。sinh函数是双曲正弦函数。cosh是双曲余弦函数。
最基本的双曲函数是双曲正弦函数sinh和双曲余弦函数cosh,从它们可以导出双曲正切函数tanh等,其推导也类似于三角函数的推导。双曲函数的反函数称为反双曲函数。双曲函数的定义域是区间,其自变量的值叫做双曲角。双曲函数出现于某些重要的线性微分方程的解中,譬如说定义悬链线和拉普拉斯方程。
❿ 用C语言表示反正弦,反余弦,反正切函数
计算反正切函数(使用欧拉变换公式,精度很高),反正切函数的级数展开公式:
f(x) = x - x^3/3 + x^5/5 +...+ (-1)^k * x^(2k+1)/(2k + 1)+...
当|x| > 1时,级数绝对值发散,无法直接使用欧拉公式计算。因此可以通过下面的公式
进行等价转换之后再进行计算。
等价转换公式:
a) ATan(1/x) = Pi/2 - ATan(x)
b) ATan(-x) = - ATan(x)
特殊情况
0 = ArcTan(0)
Pi/2 = ArcTan(无穷大)
//
// 欧拉公式
//
// sum是和,term是通项值,jterm初始为1,以后按1递增。wrksp是工作单元,视jterm的
// 最大值而定。
//
void eulsum(int& nterm,double *sum,double term,int jterm,double wrksp[])
{
double tmp,m;
if(jterm == 1)
{
nterm = 1;
wrksp[1] = term;
*sum = 0.5 * term;
}
else
{
tmp = wrksp[1];
wrksp[1] = term;
for(int j=1; j <= nterm; j++)
{
m = wrksp[j+1];
wrksp[j+1] = 0.5 * (wrksp[j] + tmp);
tmp = m;
}
if(fabs(wrksp[nterm + 1]) <= fabs(wrksp[nterm]))
{
*sum = *sum + 0.5 * wrksp[nterm + 1];
nterm = nterm + 1;
}
else
{
*sum = *sum + wrksp[nterm + 1];
}
}
}
级数计算就不用我给代码了吧。