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. C#项目代码风格要求(转)

    代码风格没有正确与否,重要的是整齐划一,这是我拟的一份<项目代码风格要求>,供大家参考. PDF版下载:项目代码风格要求V1.0.pdf 1. C# 代码风格要求 1.1注释 类型.属性. ...

  2. navicat:cannot create oci environment

    1.请注意红色箭头处的配置是从oracle官网下载的安装包 ,当然百度也是很强大的.(建议是在navicat安装目录下解压) 2.红色方框内的是你本地的oracle数据库的sqlplus.exe启动地 ...

  3. Deep Residual Learning for Image Recognition(MSRA-深度残差学习)

    转自:http://blog.csdn.net/solomonlangrui/article/details/52455638   ABSTRACT:           神经网络的训练因其层次加深而 ...

  4. 突破路由mac地址过滤思路

    一.获取合法的mac地址 在拿到无线网络的密码时,主要思路就是,用类似airodump-ng这类监听软件(WildPackets OmniPeek,Kismet),获得合法客户端的mac地址,然后再更 ...

  5. Android 开源框架ActionBarSherlock初探

    1:我的开发环境是Ubuntu12.04下:adt-bundle-linux-x86-20130729. ActionBarSherlock下载地址:http://actionbarsherlock. ...

  6. BZOJ3564 信号增幅仪

    http://www.lydsy.com/JudgeOnline/problem.php?id=3564 思路:先旋转坐标系,再缩进x坐标,把椭圆变成圆,然后做最小圆覆盖. 还有,为什么用srand( ...

  7. codevs1044:dilworth定理

    http://www.cnblogs.com/submarine/archive/2011/08/03/2126423.html dilworth定理的介绍 题目大意:求一个序列的lds 同时找出这个 ...

  8. NCPC 2015 - Problem A - Adjoin the Networks

    题目链接 : http://codeforces.com/gym/100781/attachments 题意 : 有n个编号为0-n-1的点, 给出目前已经有的边(最多n-1条), 问如何添加最少的边 ...

  9. Hadoop-2.x的源码编译

    由于在Hadoop-2.x中,Apache官网上提供的都是32位版本,如果是生产环境中则需要自行编译64位,编译Hadoop-2.x版本方法如下: 安装编译源码所依赖的底层库 yum install ...

  10. (Relax 数论1.8)POJ 1284 Primitive Roots(欧拉函数的应用: 以n为模的本原根的个数phi(n-1))

    /* * POJ_2407.cpp * * Created on: 2013年11月19日 * Author: Administrator */ #include <iostream> # ...