1、atoi()

原型:int atoi(const char *nptr);

函数说明:
参数nptr字符串,如果第一个非空格字符存在,是数字或者正负号则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。否则,返回零。
包含在头文件stdlib.h
 
 
2、inet_addr
inet_addr()的功能是将一个点分十进制的IP转换成一个长整数型数(u_long类型)
原型in_addr_t inet_addr(const char *cp);
参数:字符串,一个点分十进制的IP地址
返回值
如果正确执行将返回一个无符号长整数型数。如果传入的字符串不是一个合法的IP地址,将返回INADDR_NONE。
 
3、sprintf

功能

把格式化的数据写入某个字符串缓冲区。
头文件

stdio.h
原型

int sprintf( char *buffer, const char *format, [ argument] … );
参数列表

buffer:char型指针,指向将要写入的字符串的缓冲区。
format:格式化字符串。
[argument]...:可选参数,可以是任何类型的数据。
返回值:字符串长度(strlen)

 
 
*****************************************************
头文件time.h 
@函数名称:     localtime 
函数原型:     struct tm *localtime(const time_t *timer) 
函数功能:     返回一个以tm结构表达的机器时间信息 
函数返回:     以tm结构表达的时间,结构tm定义如下: 
  1. struct  tm{
  2. int tm_sec;
  3. int tm_min;
  4. int tm_hour;
  5. int tm_mday;
  6. int tm_mon;
  7. int tm_year;
  8. int tm_wday;
  9. int tm_yday;
  10. int tm_isdst;
  11. };
参数说明:     timer-使用time()函数获得的机器时间 
  1. #include <time.h>
  2. #include <stdio.h>
  3. #include <dos.h>
  4. int main() {
  5. time_t timer;
  6. struct tm *tblock;
  7. timer=time(NULL);
  8. tblock=localtime(&timer);
  9. printf("Local time is: %s",asctime(tblock));
  10. return 0;
  11. }
@函数名称:     asctime 
函数原型:     char* asctime(struct tm * ptr) 
函数功能:     得到机器时间(日期时间转换为ASCII码) 
函数返回:     返回的时间字符串格式为:星期,月,日,小时:分:秒,年 
参数说明:     结构指针ptr应通过函数localtime()和gmtime()得到 
所属文件:     <time.h> 
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <time.h>
  4. int main() {
  5. struct tm t;
  6. char str[80];
  7. t.tm_sec=1;
  8. t.tm_min=3;
  9. t.tm_hour=7;
  10. t.tm_mday=22;
  11. t.tm_mon=11;
  12. t.tm_year=56;
  13. t.tm_wday=4;
  14. t.tm_yday=0;
  15. t.tm_isdst=0;
  16. strcpy(str,asctime(&t));
  17. printf("%s",str);
  18. return 0;
  19. }
@函数名称:     ctime 
函数原型:     char *ctime(long time) 
函数功能:     得到日历时间 
函数返回:     返回字符串格式:星期,月,日,小时:分:秒,年 
参数说明:     time-该参数应由函数time获得 
所属文件:     <time.h> 
  1. #include <stdio.h>
  2. #include <time.h>
  3. int main() {
  4. time_t t;
  5. time(&t);
  6. printf("Today's date and time: %s",ctime(&t));
  7. return 0;
  8. }
@函数名称:     difftime 
函数原型:     double difftime(time_t time2, time_t time1) 
函数功能:     得到两次机器时间差,单位为秒 
函数返回:     时间差,单位为秒 
参数说明:     time1-机器时间一,time2-机器时间二.该参数应使用time函数获得 
所属文件:     <time.h> 
  1. #include <time.h>
  2. #include <stdio.h>
  3. #include <dos.h>
  4. #include <conio.h>
  5. int main() {
  6. time_t first, second;
  7. clrscr();
  8. first=time(NULL);
  9. delay(2000);
  10. second=time(NULL);
  11. printf("The difference is: %f seconds",difftime(second,first));
  12. getch();
  13. return 0;
  14. }
@函数名称:     gmtime 
函数原型:     struct tm *gmtime(time_t  *time) 
函数功能:     得到以结构tm表示的时间信息 
函数返回:     以结构tm表示的时间信息指针 
参数说明:     time-用函数time()得到的时间信息 
所属文件:     <time.h> 
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <dos.h>
  5. char *tzstr="TZ=PST8PDT";
  6. int main() {
  7. time_t t;
  8. struct tm *gmt, *area;
  9. putenv(tzstr);
  10. tzset();
  11. t=time(NULL);
  12. area=localtime(&t);
  13. printf("Local time is:%s", asctime(area));
  14. gmt=gmtime(&t);
  15. printf("GMT is:%s", asctime(gmt));
  16. return 0;
  17. }
@函数名称:     time 
函数原型:     time_t time(time_t *timer) 
函数功能:     得到机器的日历时间或者设置日历时间 
函数返回:     机器日历时间 
参数说明:     timer=NULL时得到机器日历时间,timer=时间数值时,用于设置日历时间,time_t是一个long类型 
所属文件:     <time.h> 
  1. #include <time.h>
  2. #include <stdio.h>
  3. #include <dos.h>
  4. int main() {
  5. time_t t;
  6. t=time();
  7. printf("The number of seconds since January 1,1970 is %ld",t);
  8. return 0;
  9. }
@函数名称:     tzset 
函数原型:     void tzset(void) 
函数功能:     UNIX兼容函数,用于得到时区,在DOS环境下无用途 
函数返回: 
参数说明: 
所属文件:     <time.h> 
  1. #include <time.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. int main() {
  5. time_t td;
  6. putenv("TZ=PST8PDT");
  7. tzset();
  8. time(&td);
  9. printf("Current time=%s",asctime(localtime(&td)));
  10. return 0;
  11. }

atoi()、inet_addr()等函数 time.h文件的更多相关文章

  1. C++编译错误 --- 成员函数定义在 .h 文件中出现重定义错误(Error LNK 2005)

    今天写了一个简单的类,定义在 .h 文件中, 类很简单就将其成员函数定义在了一起(class类后面).运行的时候出现了如下图所示的编译错误(error LNK2005) 查资料,大部分都是说需要加上 ...

  2. string.h文件中函数用法

    下面为string.h文件中函数的详细用法: strcpy函数名:strcpy功 能: 拷贝一个字符串到另一个用 法: char *strcpy(char *destin, char *source) ...

  3. 多个".h"文件中声明及定义 全局变量和函数

    一.".h"文件必须以如下格式书写 例:文件<CZ_efg_hi.h"> ------------文件内容----------- #ifndef CZ_Efg ...

  4. OpenGL常见错误之——glut.h文件的函数无法正常连接

    glut.h文件的函数无法正常连接,典型的错误如下:------ 已启动生成: 项目: gears, 配置: Debug Win32 ------1>正在链接...1>GEARS.obj ...

  5. c++实现atoi()和itoa()函数(字符串和整数转化)

    (0) c++类型所占的字节和表示范围 c 语言里 类型转换那些事儿(补码 反码) 应届生面试准备之道 最值得学习阅读的10个C语言开源项目代码 一:起因 (1)字符串类型转化为整数型(Integer ...

  6. .lib文件 .h文件 .dll文件

    .lib代表的是静态数据连接库,在windows系统中起到链接程序和函数的作用,存放的是函数的是函数调用的信息,是obj文件的集合.相当于linux中的.a或.0. .so文件.lib文件是不对外公开 ...

  7. 下位机多个".c, .h"文件的相互包含及排版

    一.背景: 自从接触单片机编程以来,由于工作上的需要,不可避免的时常会接手别人的代码,但常常由于上一位同事的编码随意性有点大,导致可读性非常的差,有时候不得不完全舍弃原有代码,推倒重来,无形中增加了工 ...

  8. 【C语言入门教程】5.6 函数库和文件

    函数库是为代码复用建立的,将同一类型,需要在不同的程序里使用的函数放置在一起,就组成了一个函数库.如 C 语言的标准库,它集合了开发者常用的函数.开发者自行编写的函数也可以组成函数库,通常称之为自定义 ...

  9. C语言中 *.c和*.h文件的区别!

    C语言中 *.c和*.h文件的区别!  http://blog.163.com/jiaoruijun07@126/blog/static/68943278201042064246409/        ...

随机推荐

  1. createwindow

    WNDCLASS wndclass; wndclass.hbrBackground=(HBRUSH)getstockobject(WHITE_BRUSH); wndclass.hCursor=Load ...

  2. Python自动化运维之9、模块之sys、os、hashlib、random、time&datetime、logging、subprocess

    python模块 用一砣代码实现了某个功能的代码集合. 类似于函数式编程和面向过程编程,函数式编程则完成一个功能,其他代码用来调用即可,提供了代码的重用性和代码间的耦合.而对于一个复杂的功能来,可能需 ...

  3. 【学习笔记】【oc】copy与mutableCopy

    copy 返回一个不可变的对象: mutableCopy 返回一个可变的对象: 使用copy方法时 类必须实现:<NSCopying>协议中的-(id)copyWithZone:(NSZo ...

  4. Solr自动生成ID

    在Solr中,每一个索引,都要有一个唯一的ID,类似于关系型数据库表中的主键.为了方便创建索引,需要配置自动生成的ID,即UUID. 一.配置schema.xml文件 添加uuid字段类型,修改字段i ...

  5. VHDL学习之TEXTIO在仿真中的应用

    TEXTIO 在VHDL 仿真与磁盘文件之间架起了桥梁,使用文本文件扩展VHDL 的仿真功能.本文介绍TEXTIO 程序包,以一个加法器实例说明TEXTIO 的使用方法,最后使用ModelSim 对设 ...

  6. 解决Android ListView 和 ScrollView 共存时冲突 问题 方法其一

    转载请注明出处: http://www.goteny.com/articles/2013/11/8.html http://www.cnblogs.com/zjjne/p/3428480.html 当 ...

  7. 转:6款Java转C#的最佳工

    原文来自于:http://designzum.com/2014/03/27/best-tools-to-convert-java-to-c-source-code/ ava is the class ...

  8. Big Data Analytics for Security(Big Data Analytics for Security Intelligence)

    http://www.infoq.com/articles/bigdata-analytics-for-security This article first appeared in the IEEE ...

  9. hdu Children’s Queue

    http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=3&sectionid=1&problemid=10 #incl ...

  10. Altium Designer中各层的含义

    1 Signal layer(信号层) 信号层主要用于布置电路板上的导线.Protel 99 SE提供了32个信号层,包括Top layer(顶层),Bottom layer(底层)和30个MidLa ...