atoi()、inet_addr()等函数 time.h文件
1、atoi()
原型:int atoi(const char *nptr);
参数nptr字符串,如果第一个非空格字符存在,是数字或者正负号则开始做类型转换,之后检测到非数字(包括结束符 \0) 字符时停止转换,返回整型数。否则,返回零。
功能
把格式化的数据写入某个字符串缓冲区。
头文件
stdio.h
原型
int sprintf( char *buffer, const char *format, [ argument] … );
参数列表
buffer:char型指针,指向将要写入的字符串的缓冲区。
format:格式化字符串。
[argument]...:可选参数,可以是任何类型的数据。
返回值:字符串长度(strlen)
- struct tm{
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday;
- int tm_yday;
- int tm_isdst;
- };
- #include <time.h>
- #include <stdio.h>
- #include <dos.h>
- int main() {
- time_t timer;
- struct tm *tblock;
- timer=time(NULL);
- tblock=localtime(&timer);
- printf("Local time is: %s",asctime(tblock));
- return 0;
- }
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- int main() {
- struct tm t;
- char str[80];
- t.tm_sec=1;
- t.tm_min=3;
- t.tm_hour=7;
- t.tm_mday=22;
- t.tm_mon=11;
- t.tm_year=56;
- t.tm_wday=4;
- t.tm_yday=0;
- t.tm_isdst=0;
- strcpy(str,asctime(&t));
- printf("%s",str);
- return 0;
- }
- #include <stdio.h>
- #include <time.h>
- int main() {
- time_t t;
- time(&t);
- printf("Today's date and time: %s",ctime(&t));
- return 0;
- }
- #include <time.h>
- #include <stdio.h>
- #include <dos.h>
- #include <conio.h>
- int main() {
- time_t first, second;
- clrscr();
- first=time(NULL);
- delay(2000);
- second=time(NULL);
- printf("The difference is: %f seconds",difftime(second,first));
- getch();
- return 0;
- }
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <dos.h>
- char *tzstr="TZ=PST8PDT";
- int main() {
- time_t t;
- struct tm *gmt, *area;
- putenv(tzstr);
- tzset();
- t=time(NULL);
- area=localtime(&t);
- printf("Local time is:%s", asctime(area));
- gmt=gmtime(&t);
- printf("GMT is:%s", asctime(gmt));
- return 0;
- }
- #include <time.h>
- #include <stdio.h>
- #include <dos.h>
- int main() {
- time_t t;
- t=time();
- printf("The number of seconds since January 1,1970 is %ld",t);
- return 0;
- }
- #include <time.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main() {
- time_t td;
- putenv("TZ=PST8PDT");
- tzset();
- time(&td);
- printf("Current time=%s",asctime(localtime(&td)));
- return 0;
- }
atoi()、inet_addr()等函数 time.h文件的更多相关文章
- C++编译错误 --- 成员函数定义在 .h 文件中出现重定义错误(Error LNK 2005)
今天写了一个简单的类,定义在 .h 文件中, 类很简单就将其成员函数定义在了一起(class类后面).运行的时候出现了如下图所示的编译错误(error LNK2005) 查资料,大部分都是说需要加上 ...
- string.h文件中函数用法
下面为string.h文件中函数的详细用法: strcpy函数名:strcpy功 能: 拷贝一个字符串到另一个用 法: char *strcpy(char *destin, char *source) ...
- 多个".h"文件中声明及定义 全局变量和函数
一.".h"文件必须以如下格式书写 例:文件<CZ_efg_hi.h"> ------------文件内容----------- #ifndef CZ_Efg ...
- OpenGL常见错误之——glut.h文件的函数无法正常连接
glut.h文件的函数无法正常连接,典型的错误如下:------ 已启动生成: 项目: gears, 配置: Debug Win32 ------1>正在链接...1>GEARS.obj ...
- c++实现atoi()和itoa()函数(字符串和整数转化)
(0) c++类型所占的字节和表示范围 c 语言里 类型转换那些事儿(补码 反码) 应届生面试准备之道 最值得学习阅读的10个C语言开源项目代码 一:起因 (1)字符串类型转化为整数型(Integer ...
- .lib文件 .h文件 .dll文件
.lib代表的是静态数据连接库,在windows系统中起到链接程序和函数的作用,存放的是函数的是函数调用的信息,是obj文件的集合.相当于linux中的.a或.0. .so文件.lib文件是不对外公开 ...
- 下位机多个".c, .h"文件的相互包含及排版
一.背景: 自从接触单片机编程以来,由于工作上的需要,不可避免的时常会接手别人的代码,但常常由于上一位同事的编码随意性有点大,导致可读性非常的差,有时候不得不完全舍弃原有代码,推倒重来,无形中增加了工 ...
- 【C语言入门教程】5.6 函数库和文件
函数库是为代码复用建立的,将同一类型,需要在不同的程序里使用的函数放置在一起,就组成了一个函数库.如 C 语言的标准库,它集合了开发者常用的函数.开发者自行编写的函数也可以组成函数库,通常称之为自定义 ...
- C语言中 *.c和*.h文件的区别!
C语言中 *.c和*.h文件的区别! http://blog.163.com/jiaoruijun07@126/blog/static/68943278201042064246409/ ...
随机推荐
- C#项目代码风格要求(转)
代码风格没有正确与否,重要的是整齐划一,这是我拟的一份<项目代码风格要求>,供大家参考. PDF版下载:项目代码风格要求V1.0.pdf 1. C# 代码风格要求 1.1注释 类型.属性. ...
- navicat:cannot create oci environment
1.请注意红色箭头处的配置是从oracle官网下载的安装包 ,当然百度也是很强大的.(建议是在navicat安装目录下解压) 2.红色方框内的是你本地的oracle数据库的sqlplus.exe启动地 ...
- Deep Residual Learning for Image Recognition(MSRA-深度残差学习)
转自:http://blog.csdn.net/solomonlangrui/article/details/52455638 ABSTRACT: 神经网络的训练因其层次加深而 ...
- 突破路由mac地址过滤思路
一.获取合法的mac地址 在拿到无线网络的密码时,主要思路就是,用类似airodump-ng这类监听软件(WildPackets OmniPeek,Kismet),获得合法客户端的mac地址,然后再更 ...
- Android 开源框架ActionBarSherlock初探
1:我的开发环境是Ubuntu12.04下:adt-bundle-linux-x86-20130729. ActionBarSherlock下载地址:http://actionbarsherlock. ...
- BZOJ3564 信号增幅仪
http://www.lydsy.com/JudgeOnline/problem.php?id=3564 思路:先旋转坐标系,再缩进x坐标,把椭圆变成圆,然后做最小圆覆盖. 还有,为什么用srand( ...
- codevs1044:dilworth定理
http://www.cnblogs.com/submarine/archive/2011/08/03/2126423.html dilworth定理的介绍 题目大意:求一个序列的lds 同时找出这个 ...
- NCPC 2015 - Problem A - Adjoin the Networks
题目链接 : http://codeforces.com/gym/100781/attachments 题意 : 有n个编号为0-n-1的点, 给出目前已经有的边(最多n-1条), 问如何添加最少的边 ...
- Hadoop-2.x的源码编译
由于在Hadoop-2.x中,Apache官网上提供的都是32位版本,如果是生产环境中则需要自行编译64位,编译Hadoop-2.x版本方法如下: 安装编译源码所依赖的底层库 yum install ...
- (Relax 数论1.8)POJ 1284 Primitive Roots(欧拉函数的应用: 以n为模的本原根的个数phi(n-1))
/* * POJ_2407.cpp * * Created on: 2013年11月19日 * Author: Administrator */ #include <iostream> # ...