注意:资料来源较早,以下使用float类型的函数参数目前已经全部改为double。
数学函数:
#include <math.h>

int abs(int x);
float fabs(float x);
float sin(float x);
float asin(float x); //x in [-1.0, 1.0]
float cos(float x);
float acos(float x); //x in [-1.0, 1.0]
float tan(float x);
float atan(float x);
float atan2(float x, float y); //求x/y的反正切值
float sinh(float x); //求x的双曲正弦值,(e^x – e^(-x)) / 2
float cosh(float x); //求x的双曲余弦值,(e^x + e^(-x) / 2)
float tanh(float x); //求x的双曲正切值,(e^x – e^(-x)) / (e^x + e^(-x))
float ceil(float x);
float floor(float x);
float exp(float x);
float fmod(float x, float y); //求x/y的余数,x – x / y
float frexp(float x, int *exp); //把x分解成尾数和2的指数,返回数是尾数,exp是指数
float ldexp(float x, int exp); //转载浮点数,返回x*2^exp的值
float modf(float x, float *i); //将x分解成整数和小数,返回值是小数部分,i是整数部分
float hypot(float x, float y); //根据勾股定理返回斜边
float log(float x); //x > 0
float log10(float x); //x > 0
float pow(float x, float y); //x > 0
float sqrt(float x); //x > 0
字符函数:
#include <ctype.h>

int isalnum(int c); //判断是否为0-9、a-z、A-z中的字符
int isalpha(int c);
int isaldigit(int c);
int iscntrl(int c); //判断c是否为控制字符,0X00-0X1F之间或0X7F(DEL)
int islower(int c);
int isupper(int c);
int isascii(int c); //判断是否为ASCII码,指0X00-0X7F之间的字符
int isgraph(int c); //c是否为除空格之外的可打印字符,指0X21-0X7E
int isprint(int c); //c是否为可打印字符,包含空格,指0x20-0x7E
int ispunct(int c); //c是否为标点符号,指非字符数字,非空格的可打印字符
int isspace(int c); //空白符指空格、制表符、换页符、回车符、换行符
int isxdigit(int c); //是否16进制数字,指0-9、A-F、a-f之间的字符
int toascii(int c); //将c转换成ascii码,即高位清零,仅保留低7位
int tolower(int c);
int toupper(int c);
动态内存分配:
#include <stdlib.h>

void *malloc(unsigned int num_bytes);
void *realloc(void *mem_address, unsigned int newsize);
void *alloc(int num_elems, int elem_size);
字符串函数:
#include <string.h>
void *memchr(void *buf, char ch, unsigned count);
//在buf所指内存前count个字节查找字符ch,返回指向ch的指针或NULL
int memcmp(void *buf1, void *buf2, unsigned int count);
//比较buf1和buf2的前count个字节,< = > 分别返回 <0 =0 >0
int memicmp(void *buf1, void *buf2, unsigned int count);
//比较buf1和buf2的前count个字节,但不区分字母大小写
void *memccpy(void *dest, void *src, unsigned char ch, unsigned int count);
//从src中复制不多于count个字节到dest,遇到字符ch则停止复制。返回指向ch后的第一个字符的指针,没有遇到ch则返回NULL,注意ch也被复制
void *memcpy(void *dest, void *src, unsigned int count);
//从src中复制不多于count个字节到dest,返回指向dest的指针,注意dest和src不能重叠
void *memmove(void *dest, const void *src, unsigned int count);
//从src中复制不多于count个字节到dest,返回指向dest的指针,其中dest和src所指内存区域可以重叠,但是src内容会被更改
void *memeset(void *buffer, int c, int count);
//将buffer所指区域前count个字节设置成c字符,返回buffer指针
//××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××× //分界线 //×××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××

char *strcpy(char *dest, char *src);
// src所有字符串复制到dest中,两者区域不可重叠,且dest必须要有足够空间,返回dest指针
char *strncpy(char *dest, char *src, int n);
// src前n个字符复制到dest中,两者区域不可重叠,且dest必须要有足够空间,返回dest指针。如果src前n个字符不含"\0",则dest不以"\0"结束;如果src长度小于n,则用"\0"填充dest直到n个字节复制完毕
char *strdup(char *s);
//函数内malloc()分配空间,返回指向被复制的字符串的指针,需要在函数中人工free掉分配的空间
char *strcat(char *dest, char *src);
//联接dest和src,dest改变,两者区域不可重叠,且dest必须要有足够空间,返回dest指针
char *strncat(char *dest, char *src, int c);
//联接dest和src前n个字符,两者区域不可重叠,且dest必须要有足够空间,返回dest指针
int strcmp(char *s1, char *s2);
//比较s1和s2,< = > 分别为 <0 =0 >0
int strncmp(char *s1, char *s2, int n);
//比较s1和s2前n个字符,同上
int stricmp(char *s1, char *s2);
//比较s1和s2,不区分字符大小写
int strnicmp(char *s1, char *s2, int n);
//比较s1和s2前n个字符,不区分字符大小写
char *strchr(char *s, char c);
//查找s中c的首次出现位置,返回c位置指针或者NULL
int strcspn(char *s1, char *s2);
//在s1中搜索s2中出现的字符,返回第一个出现在s1中的下标值,亦即在s1中出现而s2中没有出现的字符串长度
char *strpbrk(char *s1, char *s2);
//在s1中搜索s2中出现的字符,返回第一个出现在s1中的字符指针或者NULL char *strstr(char *haystack, char *needle);
//从haystack中寻找needle第一次出现的位置,返回第一次出现的位置指针或者NULL
int strlen(char *s);
//返回s的长度,不包括结束符NULL
char *strlwr(char *s);
//将s转换为小写字母形式,返回指向s的指针
char *strupr(char *s);
//将s转换为大写字母形式,返回指向s的指针
char *strrev(char *s);
//将s的所有字符顺序颠倒过来,不包括“\0”,返回s指针
char *strset(char *s, char c);
//将s的字符设置成字符c("\0"不变),返回s的指针
|
|
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
30 | 31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|
留言簿(3)
随笔分类(93)
收藏夹(2)
搜索
积分与排名
最新评论

阅读排行榜
|
|