如何解析字符串到的ctime结构?

编程入门 行业动态 更新时间:2024-10-26 22:23:19
本文介绍了如何解析字符串到的ctime结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有解析字符串到时间结构的建立方式?

Is there an established way to parse a string to a Time structure?

我想最好做的是的strftime(...),其中,而不是从时间结构和格式字符串产生一个字符串,我得到的反时间结构从根据所提供的格式字符串解析的串

What I would ideally like to do is the reverse of strftime(...), where instead of producing a string from a time struct and format string, I get a time struct from a string parsed according to the provided format string.

我preFER不通过包括DateTime类来添加额外的开销,如在升压找到或.NET

I would prefer not to add additional overhead by including a DateTime class such as that found in Boost or .NET

推荐答案

解析字符串结构TM相应的方法* 是的 strptime 。

The corresponding method for parsing strings to struct tm * is strptime.

不幸的是,这不是标准的C运行时库的一部分,例如上不存在窗户,但你可以重新使用BSD授权的版本,如这个。

Unfortunately this isn't part of the standard C runtime library and doesn't exist on e.g. windows, but you can reuse a BSD-licensed version, such as this one.

更多推荐

如何解析字符串到的ctime结构?

本文发布于:2023-08-01 08:48:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1266986.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   结构   ctime

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!