一、数学函数
在源文件中包含命令行:
#include <math.h>
函数 | 功能 | 返回值 |
int abs( int x) | 求整数x的绝对值 | 运算结果 |
double fabs(double x) | 求双精度实数x的绝对值 | 计算结果 |
double sqrt(double x) | 计算x的开方 | 计算结果 |
double pow(double x, double y) | 计算x的y次方 | 计算结果 |
二、字符串函数
在源文件中包含命令行:
#include <string.h>
函数 | 功能 | 返回值 |
char *strcat(char *s1,char *s2) | 把字符串s2接到s1后面 | s1所指地址 |
char *strchr(char *s,int ch) | 在s所指字符串中,找出第一次出现字符ch的位置 | 返回找到的字符的地址,找不到返回NULL |
int strcmp(char *s1,char *s2) | 对s1和s2所指字符串进行比较 | s1<s2,返回负数;s1= =s2,返回0; s1>s2,返回正数 |
char *strcpy(char *s1,char *s2) | 把s2指向的串复制到s1指向的空间 | s1 所指地址 |
unsigned strlen(char *s) | 求字符串s的长度 | 返回串中字符(不计最后的'\0')个数 |
三、动态分配函数
在源文件中包含命令行:
#include <stdlib.h>
函数 | 功能 | 返回值 |
void *malloc(unsigned size) | 分配size个字节的存储空间 | 分配内存空间的地址;如不成功,返回0 |
以上是个人认为初学者在学习C语言库函数时所常用的函数,供个人复习使用。