博客
关于我
《Linux系统调用:strftime,strptime》
阅读量:247 次
发布时间:2019-03-01

本文共 631 字,大约阅读时间需要 2 分钟。

一、介绍

strftime 是将分解时间转包含日期和时间的字符串

strptime 是将包含日期和时间的字符串转为分解时间

#include 
size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);参数: s:字符数组 max:指定最大字节长度包括终止空字节 format: 和printf中的类似 tm: 保存的分解时间 返回值: max:指定最大字节长度包括终止空字节,如果超过了,函数返回0表示错误。 但是也要注意不是返回0就代表了错误,比如空字符串。 正确,将返回字符数组s中放置的字节数(不包括终止的空字节)char *strptime(const char *s, const char *format, struct tm *tm);参数: s:字符串buf format: 和printf中的类似 tm: 保存的分解时间返回值: 如果成功,返回的是一个指针,指向下一个未经处理的字符,如果程序中需要处理后面的 字符串这是比较有用的,如果无法匹配format或者默认的format 错误返回NULL,并且设置errno注意: 1. strftime 不会在字符串结尾包含换行符,除非format中定义有换行符 2. 如果都省略了format,会有一个默认的格式

转载地址:http://wqkt.baihongyu.com/

你可能感兴趣的文章
NN&DL4.8 What does this have to do with the brain?
查看>>
nnU-Net 终极指南
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
No 'Access-Control-Allow-Origin' header is present on the requested resource.
查看>>
NO 157 去掉禅道访问地址中的zentao
查看>>
no available service ‘default‘ found, please make sure registry config corre seata
查看>>
No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
查看>>
no connection could be made because the target machine actively refused it.问题解决
查看>>
No Datastore Session bound to thread, and configuration does not allow creation of non-transactional
查看>>
No fallbackFactory instance of type class com.ruoyi---SpringCloud Alibaba_若依微服务框架改造---工作笔记005
查看>>
No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalanc
查看>>
No mapping found for HTTP request with URI [/...] in DispatcherServlet with name ...的解决方法
查看>>
No mapping found for HTTP request with URI [/logout.do] in DispatcherServlet with name 'springmvc'
查看>>
No module named 'crispy_forms'等使用pycharm开发
查看>>
No module named 'pandads'
查看>>
No module named cv2
查看>>
No module named tensorboard.main在安装tensorboardX的时候遇到的问题
查看>>
No module named ‘MySQLdb‘错误解决No module named ‘MySQLdb‘错误解决
查看>>
No new migrations found. Your system is up-to-date.
查看>>
No qualifying bean of type XXX found for dependency XXX.
查看>>