c - 如何将日期字符串转换为 tm 结构中的 tm_wday

标签 c

我有一个日期字符串格式,比如“2010-03-01”,我想得到等效于它的“tm_wday”,比如星期一、星期二......

谁能给我一个关于如何在 c 中实现这一点的提示?

最佳答案

检查 strptime()功能:

char *strptime(const char *s, const char *format, struct tm *tm); 

The strptime() function is the converse function to strftime(3) and converts the character string pointed to by s to values which are stored in the tm structure pointed to by tm, using the format specified by format.

关于c - 如何将日期字符串转换为 tm 结构中的 tm_wday,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3386633/

相关文章:

将 bin 文件中的字符串编译为 fgets() 字符串

c - C 中的赋值

c - 为什么我的代码不返回任何东西?

c - 如何将字符串从数组传递到指针,同时也使用结构(在 c 中)

c - C 中的 Int 流

c - 内核可用内存

字符编码问题

c - 矩阵的内存分配

c - 在 C 函数中传递和更改数组内部

c - C中的父线程通知子线程