在C ++中将字符串转换为日期 [英] Convert a string to a date in C++

查看:464
本文介绍了在C ++中将字符串转换为日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能很简单,但是C ++我怀疑会是。如何将一个格式为01/01/2008的字符串转换为日期,以便我可以操作它?我很高兴打破字符串成日月份成分。

I know this may be simple but being C++ I doubt it will be. How do I convert a string in the form 01/01/2008 to a date so I can manipulate it? I am happy to break the string into the day month year constituents. Also happy if solution is Windows only.

推荐答案

#include <time.h>
char *strptime(const char *buf, const char *format, struct tm *tm);

这篇关于在C ++中将字符串转换为日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆