C语言中一些不常用函数
来源:互联网 发布:解压缩包的软件 编辑:程序博客网 时间:2024/04/26 05:46
time
这个用的最多就是随机数的时候,现在用一用其他特性.
#include <stdio.h>#include <time.h>int main(){ time_t sec; ///typedef long time_t struct tm * curTime; sec = time(NULL); ///获取时间,从1970.1.1到现在的秒数,也可以写成 time(&sec); curTime = localtime(&sec); ///把sec转换为当地时间,存于时间结构体curTime中,注意返回值是struct tm* 类型的 printf("asctime(curTime): %s\n", asctime (curTime)); ///asctime(struct tm*)函数将curTime转化成标准ASCII时间格式 printf("ctime(curTime): %s\n", ctime (&sec)); ///ctime(time_t*)直接将sec转换成标准时间格式 printf("%d-%d-%d %d:%d:%d\n", 1900+curTime->tm_year, 1+curTime->tm_mon, curTime->tm_mday, curTime->tm_hour, curTime->tm_min, curTime->tm_sec); ///手动输出struct tm中的字段,其中月份加1,年份要加1900, ///sec记录的是1970到现在的秒数,为什么是加1900呢??? printf("\nsec = %ld\nmktime(curTime) = %ld\n", sec, mktime(curTime)); ///time_t mktime(struct tm*)将curTime反向转化成1970到现在的秒数 return 0;}
字符转换/数学公式 #include <stdlib.h>
把字符串转化成浮点数:double atof( const char *str );
或 double strtod( const char *start, char **end );
把字符串转化成整型数:int atoi( const char *str );
长整型:long atol( const char *str );
二分查找:
void bsearch(const void *key, const void *buf, size_t num, size_t size, int (*compare)(const void , const void *));
#include <math.h>
以十为底的对数函数:double log10(double x);
以e(=2.71828)为底:double log(double x);
反正切函数:double atan(double x); //返回值范围(-PI/2,PI/2)
double atan2(double y, double x); //返回点(x,y)与原点的连线和x轴正方向的夹角(弧度制),范围(-PI,PI]
说明: 1.特别注意:参数的顺序是y,x,不是x,y.
2.结果为正表示从x 轴逆时针旋转的角度,结果为负表示从x 轴顺时针旋转的角度.
3.atan2(y, x) 与 atan(y/x) 返回值的范围不同.
4.当x=0,y=0时返回错误.
- C语言中一些不常用函数
- c语言中一些常用的函数
- C语言中关于字符串的一些常用函数
- C语言中一些常用IO函数的总结
- 关于C语言中一些常用函数的说明
- c语言中常用函数
- 一些常用的C语言函数源代码
- 慢慢总结C语言一些常用函数
- C语言一些常用内存分配函数
- Linux c中一些常用函数总结(c语言中文网。。。)
- 一些c中常用的功能函数
- C语言中字符串常用函数
- C 语言中常用 string 函数简介
- C语言中常用字符串函数锦囊
- C 语言中常用 string 函数简介
- c语言中常用转换函数
- LoadRunner中常用的C语言函数
- c语言中字符串的常用函数
- Android--在Activity中使用Thread导致的内存泄漏
- linux开发基础问题答疑
- 并查集Codeforces Round #134 (Div. 1), problem: (A) Ice Skating
- 水晶报表教程:手把手教你制作基本报表
- Eclipse文本高亮
- C语言中一些不常用函数
- 项目BUG总结2
- ScrollView里包含GridView应注意的两个问题
- 小技巧:图片的呼吸效果
- C++读取OBJ文件中的数据(VS2013)
- Auto Layout 好的博客链接
- 工业4.0与物联网云计算和大数据的关系
- IP 多播地址与MAC多播地址的映射关系
- 17. subsets