在 C++ 中将字符串转换为日期

2021-12-10 00:00:00 string date c++

我知道这可能很简单,但作为 C++,我怀疑它会如此.如何将 01/01/2008 形式的字符串转换为日期以便我可以操作它?我很高兴将字符串分解为日月年组成部分.如果解决方案仅适用于 Windows,也很高兴.

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);

相关文章