c++ string 头文件_“延期不延学” 第25期 | C++篇 | C/C++常用函数
在c/c++的課程和課設中,函數的應用都是至關重要的,這里就為大家收集整理了c/c++常用的一些函數,希望大家多加應用以熟練。
1、字符處理函數
本類別函數用于對單個字符進行處理,包括字符的類別測試和字符的大小寫轉換
頭文件ctype.h
?int isalpha(int ch)?若ch是字母('A'-'Z','a'-'z')返回非0值,否則返回0?
int isalnum(int ch) 若ch是字母('A'-'Z','a'-'z')或數字('0'-'9'),返回非0值,否則返回0?
int isascii(int ch) 若ch是字符(ASCII碼中的0-127)返回非0值,否則返回0?
int iscntrl(int ch)
若ch是作廢字符(0x7F)或普通控制字符(0x00-0x1F),返回非0值,否則返回0?
int isdigit(int ch) 若ch是數字('0'-'9')返回非0值,否則返回0?
int isgraph(int ch) 若ch是可打印字符(不含空格)(0x21-0x7E)返回非0值,否則返回0?
int islower(int ch) 若ch是小寫字母('a'-'z')返回非0值,否則返回0?
int isprint(int ch) 若ch是可打印字符(含空格)(0x20-0x7E)返回非0值,否則返回0?
int ispunct(int ch) 若ch是標點字符(0x00-0x1F)返回非0值,否則返回0?
int isspace(int ch) 若ch是空格(' '),水平制表符('\t'),回車符('\r'), 走紙換行('\f'),垂直制表符('\v'),換行符('\n'), 返回非0值,否則返回0?
int isupper(int ch) 若ch是大寫字母('A'-'Z')返回非0值,否則返回0?
int isxdigit(int ch) 若ch是16進制數('0'-'9','A'-'F','a'-'f')返回非0值, 否則返回0?
int tolower(int ch) 若ch是大寫字母('A'-'Z')返回相應的小寫字母('a'-'z')?
int toupper(int ch) 若ch是小寫字母('a'-'z')返回相應的大寫字母('A'-'Z')
2、數學函數?
本分類給出了各種數學計算函數
頭文件math.h
int abs(int i) 返回整型參數i的絕對值?
double cabs(struct complex znum) 返回復數znum的絕對值?
double fabs(double x) 返回雙精度參數x的絕對值?
long labs(long n) 返回長整型參數n的絕對值?
double exp(double x) 返回指數函數ex的值?
double frexp(double value,int *eptr) 返回value=x*2n中x的值,n存貯在eptr中?
double ldexp(double value,int exp); 返回value*2exp的值?
double log(double x) 返回logex的值?
double log10(double x) 返回log10x的值?
double pow(double x,double y) 返回xy的值?
double pow10(int p) 返回10p的值?
double sqrt(double x) 返回x的開方?
double acos(double x) 返回x的反余弦cos-1(x)值,x為弧度?
double asin(double x) 返回x的反正弦sin-1(x)值,x為弧度?
double atan(double x) 返回x的反正切tan-1(x)值,x為弧度?
double atan2(double y,double x) 返回y/x的反正切tan-1(x)值,y的x為弧度?
double cos(double x) 返回x的余弦cos(x)值,x為弧度?
double sin(double x) 返回x的正弦sin(x)值,x為弧度?
double tan(double x) 返回x的正切tan(x)值,x為弧度?
double cosh(double x) 返回x的雙曲余弦cosh(x)值,x為弧度?
double sinh(double x) 返回x的雙曲正弦sinh(x)值,x為弧度?
double tanh(double x) 返回x的雙曲正切tanh(x)值,x為弧度?
double hypot(double x,double y) 返回直角三角形斜邊的長度(z), x和y為直角邊的長度,z2=x2+y2?
double ceil(double x) 返回不小于x的最小整數?
double floor(double x) 返回不大于x的最大整數?
void srand(unsigned seed) 初始化隨機數發生器?
int rand() 產生一個隨機數并返回這個數?
double modf(double value,double *iptr) 將雙精度數value分解成尾數和階?
double fmod(double x,double y) 返回x/y的余數?
3、字符串處理函數
本分類的函數用于對字符串進行合并、比較等操作
頭文件string.h?
char stpcpy(char *dest,const char *src) 將字符串src復制到dest?
char strcat(char *dest,const char *src) 將字符串src添加到dest末尾?
char strchr(const char *s,int c) 眷索并返回字符c在字符串s中第一次出現的位置?
int strcmp(const char *s1,const char *s2) 比較字符串s1與s2的大小,并返回s1-s2?
char strcpy(char *dest,const char *src) 將字符串src復制到dest?
size_t strcspn(const char *s1,const char *s2) 掃描s1,返回在s1中有,在s2中也有的字符個數?
char strdup(const char *s) 將字符串s復制到最近建立的單元?
int stricmp(const char *s1,const char *s2) 比較字符串s1和s2,并返回s1-s2?
size_t strlen(const char *s) 返回字符串s的長度?
char strlwr(char *s)?
將字符串s中的大寫字母全部轉換成小寫字母,并返回轉換后的字符串?
char strncat(char *dest,const char *src,size_t maxlen)?
將字符串src中最多maxlen個字符復制到字符串dest中?
int strncmp(const char *s1,const char *s2,size_t maxlen)?
比較字符串s1與s2中的前maxlen個字符?
char strncpy(char *dest,const char *src,size_t maxlen)?
復制src中的前maxlen個字符到dest中?
int strnicmp(const char *s1,const char *s2,size_t maxlen)?
比較字符串s1與s2中的前maxlen個字符?
char strnset(char *s,int ch,size_t n)?
將字符串s的前n個字符置于ch中?
char strpbrk(const char *s1,const char *s2)?
掃描字符串s1,并返回在s1和s2中均有的字符個數?
char strrchr(const char *s,int c)?
掃描最后出現一個給定字符c的一個字符串s?
char strrev(char *s)?
將字符串s中的字符全部顛倒順序重新排列,并返回排列后的字符串?
char strset(char *s,int ch)?
將一個字符串s中的所有字符置于一個給定的字符ch?
size_t strspn(const char *s1,const char *s2)?
掃描字符串s1,并返回在s1和s2中均有的字符個數?
char strstr(const char *s1,const char *s2)?
掃描字符串s2,并返回第一次出現s1的位置?
char strtok(char *s1,const char *s2)?
檢索字符串s1,該字符串s1是由字符串s2中定義的定界符所分隔?
南京理工大學本科生學業指導中心
微信公眾號 : 南理工樂學空間
地址:逸夫樓201
總結
以上是生活随笔為你收集整理的c++ string 头文件_“延期不延学” 第25期 | C++篇 | C/C++常用函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 电脑出现黑屏怎么回事啊 电脑为何突然黑屏
- 下一篇: oracle 丁勇 从零开始学_8.3.