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/ ...
随机推荐
- 如果设置http.get超时控制
var timeout_wrapper = function (req) { return function () { // do some logging, cleaning, etc. depen ...
- wm_char
用于接收键盘输入的消息 int CXuexi2View::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateS ...
- 关于webApi302跳转的问题
之前会出现"服务器无法在已发送 HTTP 标头之后设置状态"的问题,本地调试不报错,但是上产线就会报错 解决的思路是: var response = Request.CreateR ...
- jquery validation插件使用
首先需要引入jQuery.js和jquery.validate.js 以下面代码为例: <form id="mainform"> <fieldset> &l ...
- java中ExecutorService接口
一.声明 public interface ExecutorService extends Executor 位于java.util.concurrent包下 所有超级接口:Executor 所有已知 ...
- 用dup2和dup产生一份file descriptor 的拷贝
在类Unix操作系统里面,.dup2和dup都通过系统调用来产生一份file descriptor 的拷贝. dup对我来说还很简单 int dup(int filedes); dup2就 ...
- 创建一个MVC解决方案,添加一个控制器后,运行程序报错:”/"未找到服务器
1.创建一个MVC项目,如图
- 转:sprintf与snprintf
sprintf与snprintf int sprintf( char *buffer, const char *format [, argument] ... ); 除了前两个参数类型固定外,后面 ...
- Android 检查是否安装SD卡
/** * 检查是否安装SD卡 * @return */ public static boolean checkSaveLocationExists() { String sDCardStatus = ...
- 找出指定目录下,大于指定大小的文件(LINUX SHELL)
当前目录下: find ./ -size +2048k |xargs du -b|awk '{print $1/1024/1024 "M" $2}'|sort -n ...... ...