CSting s="2004-10-5";
int first=s.Find('-');
int second=s.Find('-',first+1);
int year=atoi(s.Left(4));
int month=atoi(s.Mid(first+1,second-first+1));
int day=atoi(s.Mid(second+1,s.GetLength()-second-1));
CTime temp(year,month,day,0,0,0);
本文介绍了一种将特定格式的日期字符串(例如“2004-10-5”)转换为 CTime 对象的方法。该过程涉及使用查找函数确定年、月、日的位置,并通过 atoi 函数将字符串转换为整数,最后创建一个 CTime 对象来表示这个日期。
872

被折叠的 条评论
为什么被折叠?



